You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Support for SHARED build with PGI OpenACC build #141
If we build shared library with OpenACC, we are getting:
cuda_init_device(threadid=1, device 0) dindex=1, api_context=0x95d090
pgi_uacc_cuda_static hostptr=0x2aaaabedc990-0x2aaaabedc998 size=8 name=_ZN10coreneuron14_slist1_ExpSynE flags=0x100
Failing in Thread:1
call to cuModuleGetGlobal returned error 500: Not found
Due to the lack of fix in PGI compiler, I am closing this issue. For now, we are creating static library with nrnivmodl-core and that gets linked to neuron. NEURON users are now supposed use nrnivmodl -coreneuron mod which internally calls nrnivmodl-core and links to CoreNEURON mechanism library. This way we avoid need of shared library support.
As this topics reappears often for practical usage NEURON GPU support (e.g. see internal neuron slack discussion), I am opening this ticket to discuss & prototype strategies going forward. Overall goal is to enable shared library support by avoiding current limitation from the use of global variable + shared library in OpenACC.
The prototype (very much WIP) looks promising and able to run ringtest via python with shared libraries:
$ ls -lrt x86_64/total 1162-rw-r--r-- 1 kumbhar bbp 357 Apr 3 00:52 makemod2c_inc-rw-r--r-- 1 kumbhar bbp 421 Apr 3 00:52 mod_func.cppdrwxr-xr-x 4 kumbhar bbp 4096 Apr 3 00:52 corenrn-rwxr-xr-x 1 kumbhar bbp 1005256 Apr 3 00:53 libcorenrnmech.so-rwxr-xr-x 1 kumbhar bbp 24088 Apr 3 00:53 special-core-rw-r--r-- 1 kumbhar bbp 9638 Apr 3 00:53 halfgap.c-rw-r--r-- 1 kumbhar bbp 5512 Apr 3 00:53 mod_func.o-rw-r--r-- 1 kumbhar bbp 32184 Apr 3 00:53 halfgap.o-rwxr-xr-x 1 kumbhar bbp 36576 Apr 3 00:53 libnrnmech.so-rw-r--r-- 1 kumbhar bbp 16272 Apr 3 00:53 nrnmain.o-rwxr-xr-x 1 kumbhar bbp 34048 Apr 3 00:53 specialkumbhar@ldir01u09:~/workarena/systems/bbpv/repos/bbp/ringtest$ python ringtest.py -coreneuron -gpu -permute 1 -tstop 1numprocs=1[10, 20] [1, 1]nring=16cell per ring=8ncell_per_type=8ntype=160.02s created rings0.00999999s initialized num_mpi=1 num_omp_thread=1 Info : 4 GPUs shared by 1 ranks per node Duke, Yale, and the BlueBrain Project -- Copyright 1984-2020 Version : 1.0 b938894 (2022-04-03 00:44:34 +0200) Additional mechanisms from files exp2syn.mod expsyn.mod halfgap.mod hh.mod netstim.mod passive.mod pattern.mod stim.mod svclmp.mod Memory (MBs) : After mk_mech : Max 202.6094, Min 202.6094, Avg 202.6094 GPU Memory (MBs) : Used = 309.000000, Free = 32201.500000, Total = 32510.500000 Memory (MBs) : After MPI_Init : Max 202.6094, Min 202.6094, Avg 202.6094 GPU Memory (MBs) : Used = 309.000000, Free = 32201.500000, Total = 32510.500000 Memory (MBs) : Before nrn_setup : Max 202.6094, Min 202.6094, Avg 202.6094 GPU Memory (MBs) : Used = 309.000000, Free = 32201.500000, Total = 32510.500000 Setup Done : 0.00 seconds Model size : 1.09 MB Memory (MBs) : After nrn_setup : Max 202.9258, Min 202.9258, Avg 202.9258 GPU Memory (MBs) : Used = 309.000000, Free = 32201.500000, Total = 32510.500000GENERAL PARAMETERS--mpi=true--mpi-lib=--gpu=true--dt=0.025--tstop=1GPU--nwarp=65536--cell-permute=1--cuda-interface=falseINPUT PARAMETERS--voltage=1000--seed=-1--datpath=.--filesdat=files.dat--pattern=--report-conf=--restore=PARALLEL COMPUTATION PARAMETERS--threading=false--skip_mpi_finalize=trueSPIKE EXCHANGE--ms_phases=2--ms_subintervals=2--multisend=false--spk_compress=0--binqueue=falseCONFIGURATION--spikebuf=100000--prcellgid=-1--forwardskip=0--celsius=6.3--mindelay=10--report-buffer-size=4OUTPUT PARAMETERS--dt_io=0.1--outpath=.--checkpoint= Start time (t) = 0 Memory (MBs) : After mk_spikevec_buffer : Max 202.9258, Min 202.9258, Avg 202.9258 GPU Memory (MBs) : Used = 309.000000, Free = 32201.500000, Total = 32510.500000 Memory (MBs) : After nrn_finitialize : Max 267.3008, Min 267.3008, Avg 267.3008 GPU Memory (MBs) : Used = 311.000000, Free = 32199.500000, Total = 32510.500000psolve |=========================================================| t: 1.00 ETA: 0h00m00sSolver Time : 0.0157009 Simulation Statistics Number of cells: 128 Number of compartments: 4576 Number of presyns: 144 Number of input presyns: 0 Number of synapses: 144 Number of point processes: 272 Number of transfer sources: 0 Number of transfer targets: 0 Number of spikes: 0 Number of spikes with non negative gid-s: 03.07s run0.00999999s wrote 0 spikesruntime=3.07 load_balance=0.0% avg_comp_time=0spk_time max=0 min=0gap_time max=0 min=0
Note that just nvprof doesn't work:
$ nvprof python ringtest.py -coreneuron -gpu -permute 1 -tstop 1numprocs=1[10, 20] [1, 1]nring=16cell per ring=8ncell_per_type=8ntype=160.02s created rings0.00999999s initialized==33325== NVPROF is profiling process 33325, command: python ringtest.py -coreneuron -gpu -permute 1 -tstop 1 num_mpi=1 num_omp_thread=1Missing definition of the OpenACC API routine/s in the OpenACC library linked to the application. To work around this issue either force the inclusion of all the OpenACC symbols in the binary or link the OpenACC library dynamically.
One funny behaviour is that when spike exchange is happening then we see segfault if launched with python but the same library/executable works if launched with special:
$ cuda-memcheck x86_64/special -python ringtest.py -coreneuron -gpu -permute 1 -tstop 1.03....Solver Time : 1.91957 Simulation Statistics Number of cells: 128 Number of compartments: 4576 Number of presyns: 144 Number of input presyns: 0 Number of synapses: 144 Number of point processes: 272 Number of transfer sources: 0 Number of transfer targets: 0 Number of spikes: 0 Number of spikes with non negative gid-s: 01.97s run0s wrote 0 spikesruntime=1.97 load_balance=0.0% avg_comp_time=0spk_time max=0 min=0gap_time max=0 min=0========= ERROR SUMMARY: 0 errors
# BUT
$ cuda-memcheck python ringtest.py -coreneuron -gpu -permute 1 -tstop 1.03...========= Host Frame:python [0x108e]================== Invalid __global__ write of size 8========= at 0x00000420 in /gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/ringtest/x86_64/corenrn/mod2c/expsyn.cpp:355:coreneuron::_net_buf_receive_ExpSyn_345_gpu(coreneuron::NrnThread*)========= by thread (14,0,0) in block (0,0,0)========= Address 0x05e94f38 is out of bounds========= Device Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/ringtest/x86_64/corenrn/mod2c/expsyn.cpp:355:coreneuron::_net_buf_receive_ExpSyn_345_gpu(coreneuron::NrnThread*) (coreneuron::_net_buf_receive_ExpSyn_345_gpu(coreneuron::NrnThread*) : 0x420)========= Saved host backtrace up to driver entry point at kernel launch time========= Host Frame:/lib64/libcuda.so.1 [0x20d6ea]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libacccuda.so (__pgi_uacc_cuda_launch3 + 0x1d96) [0x1e418]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libacccuda.so [0x224dc]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libacccuda.so (__pgi_uacc_cuda_launch + 0x13d) [0x2261b]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libacchost.so (__pgi_uacc_launch + 0x1f8) [0x48418]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/ringtest/x86_64/libcorenrnmech.so (_ZN10coreneuron23_net_buf_receive_ExpSynEPNS_9NrnThreadE + 0x55d) [0xc11d]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (_ZN10coreneuron18nrn_deliver_eventsEPNS_9NrnThreadE + 0x95) [0x1ee855]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (_ZN10coreneuron23nrn_fixed_step_lastpartEPNS_9NrnThreadE + 0x188) [0x2b17c8]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so [0x2b1618]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so [0x2af878]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so [0x2af826]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x1b8f5]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x4bf49]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x3e542]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x3e453]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x1b1b3]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so [0x18456]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/nvhpc-22.2-gou6qx/Linux_x86_64/22.2/compilers/lib/libnvomp.so (__kmpc_fork_call + 0x9e) [0x3291e]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (_ZN10coreneuron28nrn_fixed_step_group_minimalEi + 0x145) [0x2af685]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (_ZN10coreneuron17ncs2nrn_integrateEd + 0x41) [0x1f7f41]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (_ZN10coreneuron16BBS_netpar_solveEd + 0xe9) [0x215929]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libcoreneuron.so (run_solve_core + 0x671) [0xbb7b1]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/ringtest/x86_64/libcorenrnmech.so (corenrn_embedded_run + 0x8e) [0x75ce]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so (_Z14nrncore_psolvedi + 0x229) [0x1e6469]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so [0x20fcd1]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so (_Z20hoc_object_componentv + 0xc4e) [0x2aa30e]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so [0x4252fb]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so (_ZN6OcJump7fpycallEPFPvS0_S0_ES0_S0_ + 0x22f) [0x2140af]========= Host Frame:/gpfs/bbp.cscs.ch/home/kumbhar/workarena/systems/bbpv/repos/bbp/nrn/build_gpu/install/lib/libnrniv.so [0x4259b2]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (_PyObject_MakeTpCall + 0x88) [0xb6788]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (_PyEval_EvalFrameDefault + 0x9e38) [0x74958]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 [0x69bc9]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (_PyEval_EvalFrameDefault + 0x6928) [0x71448]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 [0x19d4ac]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (_PyEval_EvalCodeWithName + 0x4e) [0x19d9be]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (PyEval_EvalCodeEx + 0x3b) [0x19da0b]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (PyEval_EvalCode + 0x1b) [0x19da3b]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 [0x1dd59e]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (PyRun_SimpleFileExFlags + 0x191) [0x1defb1]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (Py_RunMain + 0x757) [0x1fc227]========= Host Frame:/gpfs/bbp.cscs.ch/ssd/apps/bsd/2022-01-10/stage_externals/install_gcc-11.2.0-skylake/python-3.9.7-yj5alh/lib/libpython3.9.so.1.0 (Py_BytesMain + 0x47) [0x1fc6e7]========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22555]========= Host Frame:python [0x108e]...
Need to check why net_buf_receive_ExpSyn would fail with python but not special...
EDIT
Issue comes from the following code:
static Memb_list* copy_ml_to_device(const Memb_list* ml, int type) {
// As we never run code for artificial cell inside GPU we don't copy it.int is_art = corenrn.get_is_artificial()[type];
if (is_art) {
returnnullptr;
}
auto d_ml = cnrn_target_copyin(ml);
int n = ml->nodecount;
int szp = corenrn.get_prop_param_size()[type];
int szdp = corenrn.get_prop_dparam_size()[type];
double* dptr = cnrn_target_deviceptr(ml->data);
the dptr is supposed to be device pointer for ml->data (which is pointer inside large nt->_data).
In case of special as an executable, dptr is expected device pointer
In case of python as an executable, dptr is host pointer same as ml->data 🙄 (to be investigated later....)
Activity
pramodk commentedon Jul 12, 2020
This is quite painful ! All the details about the issue in : https://forums.developer.nvidia.com/t/clarification-on-using-openacc-in-a-shared-library/136279
pramodk commentedon Jul 12, 2020
And second example / question : https://forums.developer.nvidia.com/t/problem-with-openacc-with-variable-initialization/134612/2
pramodk commentedon Nov 30, 2020
Due to the lack of fix in PGI compiler, I am closing this issue. For now, we are creating static library with nrnivmodl-core and that gets linked to neuron. NEURON users are now supposed use
nrnivmodl -coreneuron modwhich internally callsnrnivmodl-coreand links to CoreNEURON mechanism library. This way we avoid need of shared library support.pramodk commentedon Apr 2, 2022
As this topics reappears often for practical usage NEURON GPU support (e.g. see internal neuron slack discussion), I am opening this ticket to discuss & prototype strategies going forward. Overall goal is to enable shared library support by avoiding current limitation from the use of global variable + shared library in OpenACC.
See this comment on Nvidia forum. The linked example summarises the key issue i.e. shared library can't be loaded/linked if we use
acc declareclause.Even we separate CPU code vs GPU code completely and build all GPU/OpenACC code into a shared library, it won't help.
I am wondering if we could get rid off
acc decalreand entirely relysomehow.enter dataclausesand mod2c usage is:
note that mod2c global variable usage in generated
.cppfile is at file scope. So we might be able to get away with justenter data copying?pramodk commentedon Apr 2, 2022
One of the example that I am fiddling with in order to find out how close we have to go:
pramodk commentedon Apr 2, 2022
For future reference, with some ongoing patches I am doing to enable shared library, end-up with wall of following errors:
And after spending significant time, this nvforum thread came to rescue: https://forums.developer.nvidia.com/t/separate-compilation-of-mixed-cuda-openacc-code/192701 !! 🙄
The prototype (very much WIP) looks promising and able to run ringtest via python with shared libraries:
Note that just
nvprofdoesn't work:But this seems to be upstream issue with nvprof as reported in AdaptiveCpp/AdaptiveCpp#598 and JuliaGPU/CUDA.jl#1283.
Using
nvprof --openacc-profiling offworks fine:pramodk commentedon Apr 3, 2022
One funny behaviour is that when spike exchange is happening then we see segfault if launched with
pythonbut the same library/executable works if launched withspecial:Need to check why
net_buf_receive_ExpSynwould fail with python but not special...EDITIssue comes from the following code:
the
dptris supposed to be device pointer forml->data(which is pointer inside largent->_data).specialas an executable,dptris expected device pointerpythonas an executable,dptris host pointer same asml->data🙄 (to be investigated later....)Avoid use of global variables in generated code
Avoid use of global variables in generated code
2 remaining items
Avoid use of global variables in generated code
Support for shared libraries in GPU execution (python launch support)
Support for shared libraries in GPU execution (python launch support)
Make legacy scopmath solvers header only, drop kinderiv.py and dimpli…
Support for shared libraries in GPU execution (python launch support)
Support for shared libraries in GPU execution (python launch support)
Support for shared libraries in GPU execution (python launch support)
Support for shared libraries in GPU execution (python launch support)
Avoid use of global variables in generated code (#78)
Support for shared libraries in GPU execution (python launch support) (…
Make legacy scopmath solvers header only, drop kinderiv.py and dimpli…
Support for shared libraries in GPU execution (python launch support) (…