Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 9b88683

Browse files
authored
Minor changes to compile with OpenACC and latest cuda + pgi compiler: (#107)
* Minor changes to compile with OpenACC and latest cuda + pgi compiler: - acc routine seq in header causes pgi compiler internal errors - sm_20 is outdated, keep minimum sm_30 and add sm_60 * Update README and fix issue with disabling cuda modules
1 parent 513e648 commit 9b88683

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ if(ENABLE_OPENACC)
236236
endif(CUDA_FOUND)
237237
else(ENABLE_CUDA_MODULES)
238238
message(INFO "Support for CUDA modules (e.g. Random123) is disabled!")
239+
add_definitions(-DCUDA_MODULES_DISABLED)
239240
endif(ENABLE_CUDA_MODULES)
240241

241242
ELSE(ENABLE_OPENACC)

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,25 @@ CoreNEURON has support for GPUs using the OpenACC programming model when enabled
6262

6363
```bash
6464
module purge
65-
module load pgi/pgi64/16.5 pgi/mpich/16.5 #change pgi and cuda modules
66-
module load cuda/6.0
65+
module purge all
66+
module load pgi/18.4 cuda/9.0.176 cmake/3.5 #change pgi and cuda modules
6767

6868
export CC=mpicc
6969
export CXX=mpicxx
7070

7171
cmake .. -DADDITIONAL_MECHPATH="/path/of/folder/with/mod_files" -DCMAKE_C_FLAGS:STRING="-O2" -DCMAKE_CXX_FLAGS:STRING="-O2" -DCOMPILE_LIBRARY_TYPE=STATIC -DCMAKE_INSTALL_PREFIX=$EXPER_DIR/install/ -DCUDA_HOST_COMPILER=`which gcc` -DCUDA_PROPAGATE_HOST_FLAGS=OFF -DENABLE_SELECTIVE_GPU_PROFILING=ON -DENABLE_OPENACC=ON
7272
```
7373

74-
Note that the CUDA Toolkit version should be compatible with PGI compiler installed on your system. Otherwise you have to add extra C/C++ flags. For example, if we are using CUDA Toolkit 7.5 installation but PGI default target is CUDA 7.0 then we have to add :
74+
Note that the CUDA Toolkit version should be compatible with PGI compiler installed on your system. Otherwise you have to add extra C/C++ flags. For example, if we are using CUDA Toolkit 9.0 installation but PGI default target is CUDA 8.0 then we have to add :
7575

7676
```bash
77-
-DCMAKE_C_FLAGS:STRING="-O2 -ta=tesla:cuda7.5" -DCMAKE_CXX_FLAGS:STRING="-O2 -ta=tesla:cuda7.5"
77+
-DCMAKE_C_FLAGS:STRING="-O2 -ta=tesla:cuda9.0" -DCMAKE_CXX_FLAGS:STRING="-O2 -ta=tesla:cuda9.0"
78+
```
79+
80+
If there are large functions / procedures in MOD file that are not inlined by compiler, one can pass additional c/c++ compiler flags:
81+
82+
```bash
83+
-Minline=size:1000,levels:100,totalsize:40000,maxsize:4000
7884
```
7985

8086
CoreNEURON uses the Random123 library written in CUDA. If you are **not using `NrnRandom123`** in your model and have issues with CUDA compilation/linking (or CUDA Toolkit is not installed), you can disable the CUDA dependency using the CMake option `-DENABLE_CUDA_MODULES=OFF` :

coreneuron/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ set(link_reportinglib)
272272

273273
#@TODO: CMake should have option for arch
274274
if(ENABLE_OPENACC AND ENABLE_CUDA_MODULES)
275-
cuda_add_library("cudacoreneuron" ${coreneuron_cuda_files} OPTIONS -arch=sm_20)
275+
cuda_add_library("cudacoreneuron" ${coreneuron_cuda_files} OPTIONS
276+
-gencode=arch=compute_30,code=sm_30
277+
-gencode=arch=compute_60,code=sm_60)
276278
set(link_cudacoreneuron cudacoreneuron)
277279
endif()
278280

coreneuron/mech/mod2c_core_thread.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ extern int nrn_kinetic_steer(int, SparseObj*, double*, _threadargsproto_);
114114

115115
// derived from nrn/src/scopmath/euler.c
116116
// updated for aos/soa layout index
117-
#pragma acc routine seq
118117
static inline int euler_thread(int neqn, int* var, int* der, DIFUN fun, _threadargsproto_) {
119118
double dt = _nt->_dt;
120119
int i;

coreneuron/utils/randoms/nrnran123.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ size_t nrnran123_state_size() {
4848

4949
void nrnran123_set_globalindex(uint32_t gix) {
5050
k.v[0] = gix;
51-
#if (defined(__CUDACC__) || defined(_OPENACC))
51+
#if (defined(__CUDACC__) || defined(_OPENACC)) && !defined(CUDA_MODULES_DISABLED)
5252
nrnran123_set_gpu_globalindex(gix);
5353
#endif
5454
}

0 commit comments

Comments
 (0)