diff --git a/VERSION.cmake b/VERSION.cmake index bcce37153..8451e5e61 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -6,5 +6,5 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. -set ( ${PROJECT_NAME}_VERSION_STR "0.12.2" ) +set ( ${PROJECT_NAME}_VERSION_STR "0.12.3" ) diff --git a/bamboo/CLANG-env.sh b/bamboo/CLANG-env.sh index 231bea37e..600367f14 100644 --- a/bamboo/CLANG-env.sh +++ b/bamboo/CLANG-env.sh @@ -4,6 +4,11 @@ if [[ ! $(command -v module > /dev/null 2>&1) ]]; then . /usr/local/apps/module/init/bash fi + module unload grib_api module unload eccodes -module switch gnu clang/3.6.2 +module unload emos +module unload fftw +module unload libemos + +module switch gnu clang diff --git a/bamboo/CLANG-flags.cmake b/bamboo/CLANG-flags.cmake index f9725b61f..260e632c3 100644 --- a/bamboo/CLANG-flags.cmake +++ b/bamboo/CLANG-flags.cmake @@ -3,3 +3,4 @@ set( ENABLE_MPI OFF CACHE BOOL "Disable MPI under Clang compilat set( ENABLE_TRANS ON CACHE BOOL "Enable TRANS" ) set( ENABLE_ATLAS_TEST_GRIDSPEC ON CACHE BOOL "Enable atlas_test_gridspec") set( ENABLE_BOUNDSCHECKING ON CACHE BOOL "Enable bounds checking") +set( ENABLE_TESSELATION OFF CACHE BOOL "Disable CGAL" ) # cgal is old in leap42 diff --git a/bamboo/INTEL-env.sh b/bamboo/INTEL-env.sh index 797aadb3d..84571e0fb 100644 --- a/bamboo/INTEL-env.sh +++ b/bamboo/INTEL-env.sh @@ -8,4 +8,5 @@ module unload eccodes module unload emos module unload fftw module unload libemos + module switch gnu intel/16.0.3 diff --git a/bamboo/INTEL-flags.cmake b/bamboo/INTEL-flags.cmake index 5e5ba3d69..f869c68d8 100644 --- a/bamboo/INTEL-flags.cmake +++ b/bamboo/INTEL-flags.cmake @@ -3,3 +3,4 @@ set( ENABLE_MPI OFF CACHE BOOL "Disable MPI under Intel compilat set( ENABLE_TRANS ON CACHE BOOL "Enable TRANS" ) set( ENABLE_ATLAS_TEST_GRIDSPEC ON CACHE BOOL "Enable atlas_test_gridspec") set( ENABLE_BOUNDSCHECKING ON CACHE BOOL "Enable bounds checking") +set( ENABLE_TESSELATION OFF CACHE BOOL "Disable CGAL" ) # cgal is old in leap42 diff --git a/bamboo/opensuse131-env.sh b/bamboo/leap42-env.sh similarity index 100% rename from bamboo/opensuse131-env.sh rename to bamboo/leap42-env.sh diff --git a/bamboo/opensuse131-flags.cmake b/bamboo/leap42-flags.cmake similarity index 79% rename from bamboo/opensuse131-flags.cmake rename to bamboo/leap42-flags.cmake index 3c609675f..c3167eda8 100644 --- a/bamboo/opensuse131-flags.cmake +++ b/bamboo/leap42-flags.cmake @@ -3,3 +3,4 @@ set( ENABLE_MPI OFF CACHE BOOL "Disable MPI" ) set( ENABLE_TRANS ON CACHE BOOL "Enable TRANS" ) set( ENABLE_ATLAS_TEST_GRIDSPEC ON CACHE BOOL "Enable atlas_test_gridspec") set( ENABLE_BOUNDSCHECKING ON CACHE BOOL "Enable bounds checking") +set( ENABLE_TESSELATION OFF CACHE BOOL "Disable CGAL" ) # cgal is old in leap42 diff --git a/src/apps/atlas-benchmark.cc b/src/apps/atlas-benchmark.cc index f323a5aa8..c54365a56 100644 --- a/src/apps/atlas-benchmark.cc +++ b/src/apps/atlas-benchmark.cc @@ -209,7 +209,7 @@ void AtlasBenchmark::execute(const Args& args) haloexchange_timer = TimerStats("halo-exchange"); if( omp_threads > 0 ) - omp_set_num_threads(omp_threads); + atlas_omp_set_num_threads(omp_threads); Log::info() << "atlas-benchmark\n" << endl; Log::info() << Library::instance().info() << endl; @@ -219,7 +219,7 @@ void AtlasBenchmark::execute(const Args& args) Log::info() << " niter: " << niter << endl; Log::info() << endl; Log::info() << " MPI tasks: "< +#else +extern "C" void omp_set_num_threads(int num_threads); +extern "C" int omp_get_num_threads(void); +extern "C" int omp_get_max_threads(void); +extern "C" int omp_get_thread_num(void); +extern "C" int omp_get_num_procs(void); +extern "C" int omp_in_parallel(void); +extern "C" int omp_set_dynamic(int dynamic_threads); +extern "C" int omp_get_dynamic(void); +extern "C" void omp_set_nested(int nested); +extern "C" int omp_get_nested(void); +#endif -#ifndef _OPENMP // We need openmp stubs - -#include -#include -#include "eckit/exception/Exceptions.h" - +#ifdef ATLAS_HAVE_OMP extern "C" { - -void omp_set_num_threads(int num_threads) -{ +#pragma weak omp_set_num_threads +#pragma weak omp_get_num_threads +#pragma weak omp_get_max_threads +#pragma weak omp_get_thread_num +#pragma weak omp_get_num_procs +#pragma weak omp_in_parallel +#pragma weak omp_set_dynamic +#pragma weak omp_get_dynamic +#pragma weak omp_set_nested +#pragma weak omp_get_nested } -int omp_get_num_threads(void) -{ - return 1; -} -int omp_get_max_threads(void) -{ - return 1; -} -int omp_get_thread_num(void) -{ - return 0; -} -int omp_get_num_procs(void) -{ - return 1; -} -int omp_in_parallel(void) -{ - return 0; -} -void omp_set_dynamic(int dynamic_threads) -{ -} -int omp_get_dynamic(void) -{ - return 0; -} -void omp_set_nested(int nested) -{ -} -int omp_get_nested(void) -{ - return 0; -} -void omp_set_schedule(omp_sched_t kind, int modifier) -{ -} -void omp_get_schedule(omp_sched_t *kind, int *modifier) -{ - *kind = omp_sched_static; - *modifier = 0; -} -int omp_get_thread_limit(void) -{ - return 1; -} -void omp_set_max_active_levels(int max_active_levels) -{ -} -int omp_get_max_active_levels(void) -{ - return 0; -} -int omp_get_level(void) -{ - return 0; -} -int omp_get_ancestor_thread_num(int level) -{ - if (level == 0) - { - return 0; - } - else - { - return -1; - } -} -int omp_get_team_size(int level) -{ - if (level == 0) - { - return 1; - } - else - { - return -1; - } -} -int omp_get_active_level(void) -{ - return 0; -} -int omp_in_final(void) -{ - return 1; -} -struct __omp_lock -{ - int lock; -}; -enum { UNLOCKED = -1, INIT, LOCKED }; -void omp_init_lock(omp_lock_t *arg) -{ -struct __omp_lock *lock = (struct __omp_lock *)arg; - lock->lock = UNLOCKED; -} -void omp_destroy_lock(omp_lock_t *arg) -{ -struct __omp_lock *lock = (struct __omp_lock *)arg; - lock->lock = INIT; -} -void omp_set_lock(omp_lock_t *arg) -{ -struct __omp_lock *lock = (struct __omp_lock *)arg; - if (lock->lock == UNLOCKED) - { - lock->lock = LOCKED; - } - else if (lock->lock == LOCKED) - { - fprintf(stderr, -"error: deadlock in using lock variable\n"); - exit(1); - } - else - { - fprintf(stderr, "error: lock not initialized\n"); - exit(1); - } -} -void omp_unset_lock(omp_lock_t *arg) -{ -struct __omp_lock *lock = (struct __omp_lock *)arg; - if (lock->lock == LOCKED) - { - lock->lock = UNLOCKED; - } - else if (lock->lock == UNLOCKED) - { - fprintf(stderr, "error: lock not set\n"); - exit(1); - } - else - { - fprintf(stderr, "error: lock not initialized\n"); - exit(1); - } -} -int omp_test_lock(omp_lock_t *arg) -{ -struct __omp_lock *lock = (struct __omp_lock *)arg; - if (lock->lock == UNLOCKED) - { - lock->lock = LOCKED; - return 1; - } - else if (lock->lock == LOCKED) - { - return 0; - } - else - { - fprintf(stderr, "error: lock not initialized\n"); - exit(1); - } - return -1; -} -struct __omp_nest_lock -{ - short owner; -short count; -}; -enum { NOOWNER = -1, MASTER = 0 }; -void omp_init_nest_lock(omp_nest_lock_t *arg) +#endif + +void atlas_omp_set_num_threads(int num_threads) { -struct __omp_nest_lock *nlock=(struct __omp_nest_lock *)arg; -nlock->owner = NOOWNER; - nlock->count = 0; +#ifdef ATLAS_HAVE_OMP + if( omp_set_num_threads ) omp_set_num_threads(num_threads); +#endif } -void omp_destroy_nest_lock(omp_nest_lock_t *arg) + +int atlas_omp_get_num_threads(void) { -struct __omp_nest_lock *nlock=(struct __omp_nest_lock *)arg; - nlock->owner = NOOWNER; - nlock->count = UNLOCKED; +#ifdef ATLAS_HAVE_OMP + if( omp_get_num_threads ) return omp_get_num_threads(); +#endif + return 1; } -void omp_set_nest_lock(omp_nest_lock_t *arg) + +int atlas_omp_get_max_threads(void) { -struct __omp_nest_lock *nlock=(struct __omp_nest_lock *)arg; - if (nlock->owner == MASTER && nlock->count >= 1) - { - nlock->count++; - } - else if (nlock->owner == NOOWNER && nlock->count == 0) - { - nlock->owner = MASTER; - nlock->count = 1; - } - else - { - fprintf(stderr, -"error: lock corrupted or not initialized\n"); - exit(1); - } +#ifdef ATLAS_HAVE_OMP + if( omp_get_max_threads ) return omp_get_max_threads(); +#endif + return 1; } -void omp_unset_nest_lock(omp_nest_lock_t *arg) + +int atlas_omp_get_thread_num(void) { -struct __omp_nest_lock *nlock=(struct __omp_nest_lock *)arg; - if (nlock->owner == MASTER && nlock->count >= 1) - { - nlock->count--; - if (nlock->count == 0) - { - nlock->owner = NOOWNER; - } - } - else if (nlock->owner == NOOWNER && nlock->count == 0) - { - fprintf(stderr, "error: lock not set\n"); - exit(1); - } - else - { - fprintf(stderr, -"error: lock corrupted or not initialized\n"); - exit(1); - } +#ifdef ATLAS_HAVE_OMP + if( omp_get_thread_num ) return omp_get_thread_num(); +#endif + return 0; } -int omp_test_nest_lock(omp_nest_lock_t *arg) + +int atlas_omp_get_num_procs(void) { -struct __omp_nest_lock *nlock=(struct __omp_nest_lock *)arg; - omp_set_nest_lock(arg); - return nlock->count; +#ifdef ATLAS_HAVE_OMP + if( omp_get_num_procs ) return omp_get_num_procs(); +#endif + return 1; } -double omp_get_wtime(void) + +int atlas_omp_in_parallel(void) { - throw eckit::NotImplemented("omp_get_wtime()\n" - "This function does not provide a working" - "wallclock timer. Replace it with a version" - "customized for the target machine", Here() ); - return 0.0; +#ifdef ATLAS_HAVE_OMP + if( omp_in_parallel ) return omp_in_parallel(); +#endif + return 0; } -double omp_get_wtick(void) -{ - throw eckit::NotImplemented("omp_get_wtick()\n" - "This function does not provide a working" - "clock tick function. Replace it with" - "a version customized for the target machine.", Here() ); - return 365. * 86400.; +void atlas_omp_set_dynamic(int dynamic_threads) +{ +#ifdef ATLAS_HAVE_OMP + if( omp_set_dynamic ) omp_set_dynamic(dynamic_threads); +#endif } +int atlas_omp_get_dynamic(void) +{ +#ifdef ATLAS_HAVE_OMP + if( omp_get_dynamic ) return omp_get_dynamic(); +#endif + return 0; } +void atlas_omp_set_nested(int nested) +{ +#ifdef ATLAS_HAVE_OMP + if( omp_set_nested ) omp_set_nested(nested); #endif +} +int atlas_omp_get_nested(void) +{ +#ifdef ATLAS_HAVE_OMP + if( omp_get_nested ) return omp_get_nested(); #endif + return 0; +} -#endif diff --git a/src/atlas/parallel/omp/omp.h b/src/atlas/parallel/omp/omp.h index 0297a6210..3cca7c0de 100644 --- a/src/atlas/parallel/omp/omp.h +++ b/src/atlas/parallel/omp/omp.h @@ -8,62 +8,27 @@ * does it submit to any jurisdiction. */ -#ifndef atlas_omp_h -#define atlas_omp_h +#pragma once #include "atlas/library/config.h" -#ifdef ATLAS_HAVE_OMP -#include -#else -/// Minimal set of stubs (see atlas_omp.cc) -inline void omp_set_num_threads(int num_threads) -{ -} -inline int omp_get_num_threads(void) -{ - return 1; -} -inline int omp_get_max_threads(void) -{ - return 1; -} -inline int omp_get_thread_num(void) -{ - return 0; -} -inline int omp_get_num_procs(void) -{ - return 1; -} -inline int omp_in_parallel(void) -{ - return 0; -} -inline void omp_set_dynamic(int dynamic_threads) -{ -} -inline int omp_get_dynamic(void) -{ - return 0; -} -inline void omp_set_nested(int nested) -{ -} -inline int omp_get_nested(void) -{ - return 0; -} +void atlas_omp_set_num_threads(int num_threads); +int atlas_omp_get_num_threads(void); +int atlas_omp_get_max_threads(void); +int atlas_omp_get_thread_num(void); +int atlas_omp_get_num_procs(void); +int atlas_omp_in_parallel(void); +void atlas_omp_set_dynamic(int dynamic_threads); +int atlas_omp_get_dynamic(void); +void atlas_omp_set_nested(int nested); +int atlas_omp_get_nested(void); -#endif - -#define ATLAS_STR(x) #x -#define ATLAS_STRINGIFY(x) ATLAS_STR(x) -#define ATLAS_CONCATENATE(X,Y) X Y #ifdef ATLAS_HAVE_OMP +#define __ATLAS_OMP_STR(x) #x +#define __ATLAS_OMP_STRINGIFY(x) __ATLAS_OMP_STR(x) #define atlas_omp_pragma(x) \ - _Pragma( ATLAS_STRINGIFY( x ) ) + _Pragma( __ATLAS_OMP_STRINGIFY( x ) ) #else #define atlas_omp_pragma(x) #endif @@ -74,23 +39,24 @@ inline int omp_get_nested(void) #define atlas_omp_critical atlas_omp_pragma(omp critical) template -class atlas_scoped_helper +class atlas_omp_scoped_helper { public: - atlas_scoped_helper(T p): value(p), once_(true) {} + atlas_omp_scoped_helper(T p): value(p), once_(true) {} bool once() const { return once_; } void done() { once_=false; } T value; private: bool once_; }; -#define atlas_scoped(T,VAR,VAL) \ - for( atlas_scoped_helper VAR(VAL); VAR.once(); VAR.done() ) + +#define __atlas_omp_scoped(T,VAR,VAL) \ + for( atlas_omp_scoped_helper VAR(VAL); VAR.once(); VAR.done() ) #define atlas_omp_critical_ordered \ - atlas_scoped(const size_t, _nthreads, omp_get_num_threads()) \ + __atlas_omp_scoped(const size_t, _nthreads, atlas_omp_get_num_threads()) \ atlas_omp_pragma( omp for ordered schedule(static,1) )\ for( size_t _thread=0; _thread<_nthreads.value; ++_thread )\ atlas_omp_pragma( omp ordered ) -#endif +#undef __atlas_omp_scoped diff --git a/src/atlas_f/CMakeLists.txt b/src/atlas_f/CMakeLists.txt index 523e9c2bd..869275107 100644 --- a/src/atlas_f/CMakeLists.txt +++ b/src/atlas_f/CMakeLists.txt @@ -11,7 +11,7 @@ function( fortranize file ) file( WRITE "${file}" "${result}" ) endfunction() -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../atlas/library/defines.h.in +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/defines.h.in ${CMAKE_CURRENT_BINARY_DIR}/../atlas/atlas_f.h ) install( FILES diff --git a/src/atlas_f/defines.h.in b/src/atlas_f/defines.h.in new file mode 100644 index 000000000..859c804e5 --- /dev/null +++ b/src/atlas_f/defines.h.in @@ -0,0 +1,56 @@ +#ifndef atlas_library_defines_h +#define atlas_library_defines_h + +#if 0 +// Do not use cmakedefine as this file needs to be included by fortran as well +#endif + +#if @CGAL_FOUND@ +#define CGAL_FOUND +#endif + +#if @ATLAS_HAVE_OMP@ +#define ATLAS_HAVE_OMP +#endif + +#if @ATLAS_HAVE_TESSELATION@ +#define ATLAS_HAVE_TESSELATION +#endif + +#if @ATLAS_HAVE_FORTRAN@ +#define ATLAS_HAVE_FORTRAN +#endif + +#if @ATLAS_HAVE_TRANS@ +#define ATLAS_HAVE_TRANS +#endif + +#if @ATLAS_HAVE_EIGEN@ +#define ATLAS_HAVE_EIGEN +#endif + +#if @ATLAS_HAVE_GRIDTOOLS_STORAGE@ +#define ATLAS_HAVE_GRIDTOOLS_STORAGE +#define BOOST_RESULT_OF_USE_TR1 +#define ATLAS_GRIDTOOLS_STORAGE_BACKEND_HOST @ATLAS_GRIDTOOLS_STORAGE_BACKEND_HOST@ +#define ATLAS_GRIDTOOLS_STORAGE_BACKEND_CUDA @ATLAS_GRIDTOOLS_STORAGE_BACKEND_CUDA@ +#endif + +#ifdef __CUDACC__ +#define ATLAS_HOST_DEVICE __host__ __device__ +#define ATLAS_DEVICE __device__ +#define ATLAS_HOST __host__ +#else +#define ATLAS_HOST_DEVICE +#define ATLAS_DEVICE +#define ATLAS_HOST +#endif + +#define ATLAS_BITS_GLOBAL @ATLAS_BITS_GLOBAL@ + +#if @ATLAS_HAVE_BOUNDSCHECKING@ +#define ATLAS_ARRAYVIEW_BOUNDS_CHECKING +#define ATLAS_INDEXVIEW_BOUNDS_CHECKING +#endif + +#endif \ No newline at end of file