Skip to content

Commit

Permalink
Merge branch 'v1.1.0-rc.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alazzaro committed Apr 3, 2019
2 parents d90c0ec + 801ea06 commit 219e64f
Show file tree
Hide file tree
Showing 80 changed files with 83,904 additions and 6,075 deletions.
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
default_language_version:
python: python3.6

exclude: '^tools/(prettify/fprettify|build_utils/fypp)'
fail_fast: false
repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.24.0
hooks:
- id: yapf
language_version: "python3"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: flake8
language_version: "python2"
exclude: '^src/acc/libsmm_acc/libcusmm/(tune|predict)_'
- id: flake8
language_version: "python3"
- id: check-ast
stages: [manual]
language_version: "python2"
exclude: '^src/acc/libsmm_acc/libcusmm/(tune|predict)_'
- id: check-ast
stages: [manual]
language_version: "python3"
- repo: local
hooks:
- id: check-header
name: check file headers
entry: ./.pre-commit/check_header.py --verbose
language: script
types: [text]
exclude: '^tools/'
90 changes: 90 additions & 0 deletions .pre-commit/check_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
####################################################################################################
# Copyright (C) by the DBCSR developers group - All rights reserved #
# This file is part of the DBCSR library. #
# #
# For information on the license, see the LICENSE file. #
# For further information please visit https://dbcsr.cp2k.org #
# SPDX-License-Identifier: GPL-2.0+ #
####################################################################################################

import argparse
import re
import mmap
import sys
from os import path
from contextlib import contextmanager

TYPES = {
'c_cpp': ['.c', 'h', '.cc', '.hh', '.cxx', '.hpp', '.cu'],
'python': ['.py'],
'fortran': ['.F', '.f', '.f90', '.f03'],
}

# max number of lines allowed between header and top of file
ALLOWED_LINES = 5

# some assumed max line length to terminate early for large files
MAX_LINE_LENGTH = 128


@contextmanager
def mmap_open(name, mode='r'):
access = mmap.ACCESS_READ if mode == 'r' else mmap.ACCESS_WRITE
with open(name, mode + 'b') as fhandle:
fmapped = mmap.mmap(fhandle.fileno(), 0, access=access)
yield fmapped
fmapped.close()


def check_header(header_dir, files, verbose=False):
retval = 0
header_re = {}
header_len = {}

for headertype in TYPES:
with open(path.join(header_dir, headertype), 'rb') as fhandle:
header_content = fhandle.read()
header_re[headertype] = re.compile(re.escape(header_content))
header_len[headertype] = len(header_content)

ext_map = {e: t for t, exts in TYPES.items() for e in exts}

for fpath in files:
_, fext = path.splitext(fpath)

if fext not in ext_map:
if verbose:
print("? {} ... unknown file type, ignoring".format(fpath))
continue

with mmap_open(fpath) as fmapped:
header_type = ext_map[fext]
match = header_re[header_type].search(fmapped, 0, ALLOWED_LINES * MAX_LINE_LENGTH + header_len[header_type])

if not match:
print("✗ {} ... required header not found".format(fpath))
retval = 1
continue

lines_above = fmapped[0:match.start()].splitlines()
if len(lines_above) > ALLOWED_LINES:
print("✗ {} ... header not within first {} lines".format(fpath, ALLOWED_LINES))
retval = 1
continue

if verbose:
print("✓ {}".format(fpath))

sys.exit(retval)


if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Check files for header presence")
parser.add_argument('files', metavar='FILE', type=str, nargs='+', help="files to check")
parser.add_argument('--verbose', '-v', action='store_true', default=False)
args = parser.parse_args()

header_dir = path.join(path.dirname(path.abspath(__file__)), 'headers')
check_header(header_dir, args.files, args.verbose)
8 changes: 8 additions & 0 deletions .pre-commit/headers/c_cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*------------------------------------------------------------------------------------------------*
* Copyright (C) by the DBCSR developers group - All rights reserved *
* This file is part of the DBCSR library. *
* *
* For information on the license, see the LICENSE file. *
* For further information please visit https://dbcsr.cp2k.org *
* SPDX-License-Identifier: GPL-2.0+ *
*------------------------------------------------------------------------------------------------*/
8 changes: 8 additions & 0 deletions .pre-commit/headers/fortran
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!--------------------------------------------------------------------------------------------------!
! Copyright (C) by the DBCSR developers group - All rights reserved !
! This file is part of the DBCSR library. !
! !
! For information on the license, see the LICENSE file. !
! For further information please visit https://dbcsr.cp2k.org !
! SPDX-License-Identifier: GPL-2.0+ !
!--------------------------------------------------------------------------------------------------!
8 changes: 8 additions & 0 deletions .pre-commit/headers/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
####################################################################################################
# Copyright (C) by the DBCSR developers group - All rights reserved #
# This file is part of the DBCSR library. #
# #
# For information on the license, see the LICENSE file. #
# For further information please visit https://dbcsr.cp2k.org #
# SPDX-License-Identifier: GPL-2.0+ #
####################################################################################################
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ env:
- USE_MPI=OFF USE_OPENMP=ON USE_SMM=libxsmm
- USE_MPI=OFF USE_OPENMP=OFF USE_SMM=libxsmm

matrix:
include:
- os: linux
python: 3.6

matrix:
exclude:
- os: osx
Expand Down Expand Up @@ -87,7 +92,12 @@ jobs: # the following jobs inherit only the first OS
- name: "Run pre-commit hook on changed files"
script:
- set -o pipefail
- git diff --name-only --diff-filter=AM HEAD...$TRAVIS_BRANCH | xargs pre-commit run --files
# fetch remotes first to ensure that referenced branches (other than the default) are available
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch
# yapf requires python3.6.4+
- pyenv global 3.6.7 2.7.15
- git diff --name-only --diff-filter=AM HEAD "origin/${TRAVIS_BRANCH}" | xargs pre-commit run --files
- name: "Run pre-commit hook 'check-ast' on all files"
script:
- pre-commit run --hook-stage manual --all-files check-ast
Expand All @@ -96,7 +106,9 @@ jobs: # the following jobs inherit only the first OS
if: tag IS present
script:
# do an in-source config for simplicity since we are not building anything here
- cmake .
- mkdir -p build
- cd build
- cmake ..
- make dist
deploy:
provider: releases
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ endif ()

get_filename_component(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)

# if the fortran compiler command is a CRAY wrapper, find out what the underlying compiler is
if (Fortran_COMPILER_NAME MATCHES "ftn")
execute_process(COMMAND ftn -craype-verbose OUTPUT_VARIABLE ftn_verbose_OUT ERROR_QUIET)
separate_arguments(ftn_verbose_OUT NATIVE_COMMAND "${ftn_verbose_OUT}")
list(GET ftn_verbose_OUT 0 Fortran_COMPILER_NAME)
endif ()

# Depending on the fortran compiler, set the appropriate compiler flags
if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops")
Expand Down
63 changes: 59 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ endif
dirs makedep \
default_target $(LIBRARY) all \
toolversions \
toolflags \
doxify doxifyclean \
pretty prettyclean doxygen/clean doxygen \
install clean realclean help \
Expand Down Expand Up @@ -144,7 +145,7 @@ dirs:
@mkdir -p $(LIBDIR)

version:
@echo "DCBSR Version: "$(MAJOR)"."$(MINOR)"."$(PATCH)" ("$(DATE)")"
@echo "DBCSR Version: "$(MAJOR)"."$(MINOR)"."$(PATCH)" ("$(DATE)")"
OTHER_HELP += "version : Print DBCSR version"

toolversions:
Expand All @@ -158,6 +159,11 @@ else
$(FC) --version
endif
endif
ifneq ($(CXX),)
@echo "========== CXX =========="
$(CXX) --version
@echo ""
endif
ifneq ($(CC),)
@echo "=========== CC ==========="
ifeq (Cray,$(shell $(CC) -V 2>&1 | head -n1 | cut -d' ' -f1))
Expand All @@ -168,6 +174,11 @@ else
$(CC) --version
endif
endif
ifneq ($(LD),)
@echo "========== LD =========="
$(LD) --version
@echo ""
endif
ifneq ($(NVCC),)
@echo "========== NVCC =========="
$(NVCC) --version
Expand All @@ -186,6 +197,40 @@ endif

OTHER_HELP += "toolversions : Print versions of build tools"

toolflags:
ifneq ($(FCFLAGS),)
@echo "========== FCFLAGS =========="
@echo $(FCFLAGS)
@echo ""
endif
ifneq ($(CXXFLAGS),)
@echo "========== CXXFLAGS =========="
@echo $(CXXFLAGS)
@echo ""
endif
ifneq ($(CFLAGS),)
@echo "========== CFLAGS =========="
@echo $(CFLAGS)
@echo ""
endif
ifneq ($(LDFLAGS),)
@echo "========== LDFLAGS =========="
@echo $(LDFLAGS)
@echo ""
endif
ifneq ($(NVFLAGS),)
@echo "========== NVFLAGS =========="
@echo $(NVFLAGS)
@echo ""
endif
ifneq ($(GPUVER),)
@echo "========== GPUVER =========="
@echo $(GPUVER)
@echo ""
endif

OTHER_HELP += "toolflags : Print flags used with build tools"

else
# stage 2: Include $(OBJDIR)/all.dep, expand target all, and get list of dependencies.
all: $(foreach e, $(BIN_NAMES), $(e))
Expand Down Expand Up @@ -222,6 +267,14 @@ help:
@echo "================= Other Targets ================="
@printf "%s\n" $(OTHER_HELP) | awk -F ':' '{printf "%-28s%s\n", $$1, $$2}'
@echo "help Print this help text"
@echo "================= Variables ====================="
@echo "For convenience, some variables can be set during compilation,"
@echo "e.g. make VARIABLE=value (multiple variables are possible):"
@echo "MPI=0 : disable MPI compilation"
@echo "GNU=0 : disable GNU compiler compilation and enable Intel compiler compilation"
@echo "CHECKS=1 : enable GNU compiler checks and DBCSR asserts"
@echo "CINT=1 : generate the C interface"
@echo "GPU=1 : enable GPU support"

ifeq ($(INCLUDE_DEPS),)
install: $(LIBRARY)
Expand All @@ -239,12 +292,12 @@ install: $(LIBRARY)
else
install:
@printf " ... modules ..."
@if [[ -n "$(wildcard $(addprefix $(OBJDIR)/, $(PUBLICFILES:.F=.mod)))" ]] ; then \
@if [ -n "$(wildcard $(addprefix $(OBJDIR)/, $(PUBLICFILES:.F=.mod)))" ] ; then \
cp $(addprefix $(OBJDIR)/, $(PUBLICFILES:.F=.mod)) $(PREFIX)/include ; \
echo " done." ; \
else echo " no modules were installed!" ; fi
@printf " ... headers ..."
@if [[ -n "$(PUBLICHEADERS)" ]] ; then \
@if [ -n "$(PUBLICHEADERS)" ] ; then \
cp $(PUBLICHEADERS) $(PREFIX)/include ; \
echo " done." ; \
else echo " no headers were installed!" ; fi
Expand All @@ -266,6 +319,8 @@ test:
OTHER_HELP += "test : Run the unittests available in tests/"

clean:
rm -f $(TESTSDIR)/libcusmm_libcusmm_unittest_multiply.cu
rm -f $(TESTSDIR)/libcusmm_timer_multiply.cu
rm -rf $(OBJDIR)
rm -f $(LIBCUSMM_ABS_DIR)/parameters.h $(LIBCUSMM_ABS_DIR)/cusmm_kernels.h $(LIBCUSMM_ABS_DIR)/*.so
OTHER_HELP += "clean : Remove intermediate object and mod files, but not the libraries and executables"
Expand Down Expand Up @@ -439,7 +494,7 @@ FYPPFLAGS ?= -n
$(CXX) -c $(CXXFLAGS) $<

libcusmm.o: libcusmm.cpp parameters.h cusmm_kernels.h
$(CXX) -c $(CXXFLAGS) -DARCH_NUMBER=$(ARCH_NUMBER) $<
$(CXX) -c $(CXXFLAGS) $(CXXOMPFLAGS) -DARCH_NUMBER=$(ARCH_NUMBER) $<

%.o: %.cu
$(NVCC) -c $(NVFLAGS) -I'$(SRCDIR)' $<
Expand Down
20 changes: 13 additions & 7 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
#
# For convenience, some variables can be set during compilation,
# e.g. make `VARIABLE=value` (multiple variables are possible):
# 1) MPI=0 : disable MPI compilation
# 2) GNU=0 : disable GNU compiler compilation and enable Intel compiler compilation
# 3) CHECKS=1 : enable GNU compiler checks and DBCSR asserts
# 4) CINT=1 : generate the C interface
# 5) GPU=1 : enable GPU support
# 1) OMP=0 : disable OpenMP compilation
# 2) MPI=0 : disable MPI compilation
# 3) GNU=0 : disable GNU compiler compilation and enable Intel compiler compilation
# 4) CHECKS=1 : enable GNU compiler checks and DBCSR asserts
# 5) CINT=1 : generate the C interface
# 6) GPU=1 : enable GPU support
#

#######################################################################################
Expand Down Expand Up @@ -136,15 +137,20 @@ endif

ifneq (0,$(GNU)) # DEFAULT, just edit...
CXXFLAGS += -std=c++11
FCFLAGS += -fopenmp -std=f2003 -ffree-form -fimplicit-none -ffree-line-length-512
FCFLAGS += -std=f2003 -ffree-form -fimplicit-none -ffree-line-length-512
OPTFLAGS += -O3 -g -fno-omit-frame-pointer -funroll-loops
else
# Intel compiler flags
CXXFLAGS += -std=c++11
FCFLAGS += -fopenmp -free
FCFLAGS += -free
OPTFLAGS += -O2 -g
endif

ifneq (0,$(OMP)) # using OpenMP
CXXOMPFLAGS = -fopenmp
FCFLAGS += -fopenmp
endif

OPTFLAGS +=
CFLAGS += $(OPTFLAGS)
CXXFLAGS += $(OPTFLAGS)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ You absolutely need:
* a Fortran compiler which supports at least Fortran 2003 (respectively 2008+TS when using the C-bindings)
* a LAPACK implementation (reference, OpenBLAS-bundled and MKL have been tested)
* a BLAS implementation (reference, OpenBLAS-bundled and MKL have been tested)
* a Python version installed (2.7 or 3.6+ have been tested)
* a Python version installed (2.7 or 3.6+ have been tested) with Numpy

Optionally:

* [libxsmm](https://github.com/hfp/libxsmm) (1.8.2+ with make-only, 1.10+ with cmake) for Small Matrix Multiplication acceleration
* [CMake](https://cmake.org/) (3.10+)

To build with CUDA support you further need:
To build [libcusmm](src/acc/libsmm_acc/libcusmm) (DBCSR's CUDA backend), you further need:

* CUDA Toolkit
* a C++ compiler which supports at least C++11 standard

We test against GNU and Intel compilers on Linux systems.
We test against GNU and Intel compilers on Linux systems, GNU compiler on MacOS systems.

## Getting started

Expand Down
Loading

0 comments on commit 219e64f

Please sign in to comment.