Skip to content

Commit

Permalink
Merge branch 'release-2.0.0-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
pseewald committed Apr 15, 2019
2 parents b959158 + 0c80b80 commit 785869f
Show file tree
Hide file tree
Showing 76 changed files with 11,472 additions and 1,781 deletions.
42 changes: 42 additions & 0 deletions .ci/daint.cscs.ch/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
pipeline {
agent any

stages {
stage('prepare') {
steps {
checkout scm
}
}
stage('build') {
steps {
run_batch("0:15:00")
}
}
stage('test') {
steps {
run_batch("1:00:00")
}
}
}
}

def run_batch(timelimit) {
def (account, basename) = env.JOB_NAME.split('/')
// avoid using the shell for variable expansion to
// get the final command displayed in Jenkins
try {
sh """
sbatch --wait \
--time="${timelimit}" \
--account="${account}" \
--job-name="${basename}" \
--output="sbatch.${env.BUILD_TAG}.${env.STAGE_NAME}.out" \
.ci/daint.cscs.ch/${env.STAGE_NAME}.sh
"""
}
finally {
echo readFile("sbatch.${env.BUILD_TAG}.${env.STAGE_NAME}.out")
}
}

// vim: set filetype=groovy ts=4 sw=4 tw=0 :
36 changes: 36 additions & 0 deletions .ci/daint.cscs.ch/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -l

#SBATCH --export=ALL
#SBATCH --exclusive
#SBATCH --constraint="mc"
#SBATCH --partition="cscsci"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --cpus-per-task=3
#SBATCH --ntasks-per-core=1 # 1=no HT, 2=HT

set -o errexit
set -o nounset
set -o pipefail

module swap PrgEnv-cray PrgEnv-gnu
module load daint-gpu cudatoolkit CMake/3.12.0
module unload cray-libsci_acc

set -o xtrace # do not set earlier to avoid noise from module

umask 0002 # make sure group members can access the data

mkdir --mode=0775 -p "${SCRATCH}/${BUILD_TAG}"
cd "${SCRATCH}/${BUILD_TAG}"

cmake \
-DUSE_CUDA=ON \
-DUSE_CUBLAS=ON \
-DWITH_GPU=P100 \
-DMPIEXEC_EXECUTABLE="$(command -v srun)" \
-DTEST_MPI_RANKS=${SLURM_NTASKS} \
-DTEST_OMP_THREADS=${SLURM_CPUS_PER_TASK} \
"${WORKSPACE}" |& tee -a "${STAGE_NAME}.out"

make VERBOSE=1 -j |& tee -a "${STAGE_NAME}.out"
34 changes: 34 additions & 0 deletions .ci/daint.cscs.ch/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -l

#SBATCH --export=ALL
#SBATCH --exclusive
#SBATCH --constraint="gpu"
#SBATCH --partition="cscsci"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --cpus-per-task=3
#SBATCH --ntasks-per-core=1 # 1=no HT, 2=HT

set -o errexit
set -o nounset
set -o pipefail

module swap PrgEnv-cray PrgEnv-gnu
module load daint-gpu cudatoolkit CMake/3.12.0
module unload cray-libsci_acc

set -o xtrace # do not set earlier to avoid noise from module

umask 0002 # make sure group members can access the data

mkdir --mode=0775 -p "${SCRATCH}/${BUILD_TAG}"
cd "${SCRATCH}/${BUILD_TAG}"

export CRAY_CUDA_MPS=1 # enable the CUDA proxy for MPI+CUDA
export OMP_PROC_BIND=TRUE # set thread affinity
# OMP_NUM_THREADS is set by cmake

# document the current environment
env |& tee -a "${STAGE_NAME}.out"

env CTEST_OUTPUT_ON_FAILURE=1 make test |& tee -a "${STAGE_NAME}.out"
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
max-line-length = 120
max-line-length = 128
# ignore whitespaces in array slices (https://github.com/PyCQA/pycodestyle/issues/373)
ignore = E203,W503
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ default_language_version:
exclude: '^tools/(prettify/fprettify|build_utils/fypp)'
fail_fast: false
repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.24.0
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: yapf
- id: black
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: flake8
language_version: "python3"
- id: check-ast
stages: [manual]
language_version: "python3"
Expand Down
36 changes: 22 additions & 14 deletions .pre-commit/check_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from contextlib import contextmanager

TYPES = {
'c_cpp': ['.c', 'h', '.cc', '.hh', '.cxx', '.hpp', '.cu'],
'python': ['.py'],
'fortran': ['.F', '.f', '.f90', '.f03'],
"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
Expand All @@ -30,9 +30,9 @@


@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:
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()
Expand All @@ -44,7 +44,7 @@ def check_header(header_dir, files, verbose=False):
header_len = {}

for headertype in TYPES:
with open(path.join(header_dir, headertype), 'rb') as fhandle:
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)
Expand All @@ -61,16 +61,22 @@ def check_header(header_dir, files, verbose=False):

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

Expand All @@ -80,11 +86,13 @@ def check_header(header_dir, files, verbose=False):
sys.exit(retval)


if __name__ == '__main__':
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)
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')
header_dir = path.join(path.dirname(path.abspath(__file__)), "headers")
check_header(header_dir, args.files, args.verbose)
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ jobs: # the following jobs inherit only the first OS
- make test
- bash <(curl -s https://codecov.io/bash)
- name: "Run pre-commit hook on changed files"
if: tag IS NOT present
script:
- set -o pipefail
# 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+
# ensure python 3.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
- pre-commit run --all-files
- name: "Run pre-commit hook 'check-ast' on all files"
if: tag IS NOT present
script:
- pre-commit run --hook-stage manual --all-files check-ast
- stage: release
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cmake_dependent_option(WITH_C_API "Build the C API (ISO_C_BINDINGS)" ON "USE_MPI
cmake_dependent_option(WITH_EXAMPLES "Build the examples" ON "USE_MPI" OFF) # all examples require MPI

set(TEST_MPI_RANKS "auto" CACHE STRING "Number of MPI ranks for testing")
set(TEST_OMP_THREADS 2 CACHE STRING "Number of OpenMP threads for testing")

set(USE_SMM "blas" CACHE STRING "Small Matrix Multiplication implementation to use (default: blas)")
set_property(CACHE USE_SMM PROPERTY STRINGS blas libxsmm)
Expand Down Expand Up @@ -96,7 +97,7 @@ if (Fortran_COMPILER_NAME MATCHES "ftn")
endif ()

# Depending on the fortran compiler, set the appropriate compiler flags
if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
if (Fortran_COMPILER_NAME MATCHES "^gfortran.*")
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops")
set(CMAKE_CXX_FLAGS_COVERAGE "-O0 -fprofile-arcs -ftest-coverage")
Expand All @@ -114,15 +115,15 @@ if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage")
endif ()
endif ()
elseif (Fortran_COMPILER_NAME MATCHES "ifort.*")
elseif (Fortran_COMPILER_NAME MATCHES "^ifort.*")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -debug")
set(CMAKE_Fortran_FLAGS "-free -stand f03 -fpp")
# Disable the line-length-extension warning #5268
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -diag-disable=5268")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -debug")
set(F2008_COMPILER_FLAGS "-stand f08")
elseif (Fortran_COMPILER_NAME MATCHES "pgfortran.*")
elseif (Fortran_COMPILER_NAME MATCHES "^pgf.*")
set(CMAKE_CXX_FLAGS_RELEASE "-fast")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_Fortran_FLAGS "-Mfreeform -Mextend -Mallocatable=03")
Expand All @@ -134,8 +135,8 @@ else ()
Unknown compiler, trying with just '-O2'/'-O0 -g'.\n\
You will most likely have to pass additonal options for free-form Fortran 2003/2008 for your compiler!\n\
Please open an issue at https://github.com/cp2k/dbcsr/issues with the reported compiler name and the required flags.")
message("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message("Fortran_COMPILER_NAME: " ${Fortran_COMPILER_NAME})
message("-- Fortran_COMPILER_NAME: " ${Fortran_COMPILER_NAME})
message("-- CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})

set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
Expand Down
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Contributing to DBCSR
The core of DBCSR is written in Fortran. All other languages must be supported through bindings.

There is a single [API](https://github.com/cp2k/dbcsr/blob/develop/src/dbcsr_api.F) file for DBCSR, which is provided for external usage only. **Do not use the API for any internal DBCSR development!** Packages build on top of DBCSR, for example [DBCSR Tensors](https://github.com/cp2k/dbcsr/tree/develop/src/tensors), **must only use** the DBCSR API.
There is a single [API](./src/dbcsr_api.F) file for DBCSR, which is provided for external usage only. **Do not use the API for any internal DBCSR development!** Packages build on top of DBCSR, for example [DBCSR Tensors](./src/tensors), **must only use** the DBCSR API. Note that any change in the APIs will require a major release of the library.

We support Make and CMake for compilation, please keep the build system updated when adding/removing files. When adding new functions, it is extremely important to provide simple test programs, aka "unit tests", to check whether these functions are performing as they should. The directory [test](https://github.com/cp2k/dbcsr/tree/develop/tests) serves as infrastructure for that. If you do not feel comfortable with integrating these tests with the build system, please notify the other developers.
We support Make and CMake for compilation, please keep the build system updated when adding/removing files. When adding new functions, it is extremely important to provide simple test programs, aka "unit tests", to check whether these functions are performing as they should. The directory [test](./tests) serves as infrastructure for that. If you do not feel comfortable with integrating these tests with the build system, please notify the other developers.

It is also appreciated to have examples (under the directory [examples](https://github.com/cp2k/dbcsr/tree/develop/examples)). They must be independent of the DBCSR compilation and only use the DBCSR API.
It is also appreciated to have examples (under the directory [examples](./examples)). They must be independent of the DBCSR compilation and only use the DBCSR APIs.

DBCSR developers can find additional information on the [Development](https://github.com/cp2k/dbcsr/wiki/Development) wiki page.

Expand All @@ -19,10 +19,11 @@ Please make sure that you follow the following code conventions (based on [CP2K
3. Every static variable should be marked with the `SAVE` attribute.
4. Every Fortran module should contain the line `IMPLICIT NONE`.
5. Every conversion that might change value should be explicit.
6. Each `.F` file should contain either a `PROGRAM` or a single `MODULE`, whose name matches the filename. Then, it should start with the DBCSR header. Note that the name of the modules must be unique, even across different directories!
7. Use the routines from [MPI wrappers](https://github.com/cp2k/dbcsr/tree/develop/src/mpi) instead of calling MPI directly.
6. Each `.F` file should contain either a `PROGRAM` or a single `MODULE`, whose name must start with the `dbcsr_` suffix and matches the filename. Then, it should start with the DBCSR header. Note that the name of the modules must be unique, even across different directories!
7. Use the routines from [MPI wrappers](./src/mpi) instead of calling MPI directly.
8. Don't use `UNIT=*` in `WRITE` or `PRINT` statements. Instead request a unit from the logger: `iw=dbcsr_logger_get_default_unit_nr()` and write only if you actually received a unit: `IF(iw>0) WRITE (UNIT=iw, ,,,)`.
9. Avoid to use `STOP`. Prefer the DBCSR error handlers: `DBCSR_WARN`, `DBCSR_ABORT`, `DBCSR_ASSERT`.
10. Each preprocessor flag should start with two underscores and be documented in the [Makefile.inc](https://github.com/cp2k/dbcsr/blob/develop/Makefile.inc).
10. Each preprocessor flag should start with two underscores and be documented in the [Makefile.inc](./Makefile.inc).
11. All routines in the API must start with the `dbcsr_` namespace. For submodules API (e.g. [DBCSR Tensors](./src/tensors)), each function has to start with the `dbcsr_<unique ID of the submodule>_` namespace.

**Most important, please avoid to commit dead code and useless comments!**
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ The configuration flags are (default first):
## Contributing to DBCSR

Your contribution to the project is welcome!
Please see [Contributing.md](https://github.com/cp2k/dbcsr/blob/develop/CONTRIBUTING.md) and this [wiki page](https://github.com/cp2k/dbcsr/wiki/Development). For any help, please notify the other developers.
Please see [Contributing.md](./CONTRIBUTING.md) and this [wiki page](https://github.com/cp2k/dbcsr/wiki/Development). For any help, please notify the other developers.
8 changes: 4 additions & 4 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR = 1
MINOR = 1
PATCH = 0
MAJOR = 2
MINOR = 0
PATCH = 0-alpha
# A specific DATE (YYYY-MM-DD) fixes an official release, otherwise
# it is considered Development version.
DATE = 2019-04-08
DATE = 2019-04-15
Loading

0 comments on commit 785869f

Please sign in to comment.