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

Commit 0219aa6

Browse files
authored
Fix GPU compilation issue when nrn_ghk is used in the MOD files (#498)
- nrn_ghk was recently added but `acc routine seq` was missing - nrn_ghk uses celsius which is an extern variable. All extern variables require `acc declare create/copyin` caluse. - As global variables can be initialized after device attachment (celsius in this case), we need to make sure celsius is updated on the device. - Replacing `data` clause with `update device` is sufficient. In this case `data` clause doesn't update value on device when checked in eion.cpp.
1 parent 14ad572 commit 0219aa6

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

coreneuron/apps/main1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
490490

491491
// clang-format off
492492

493-
#pragma acc data copyin(celsius, secondorder) if (compute_gpu)
493+
#pragma acc update device(celsius, secondorder) if (compute_gpu)
494494
// clang-format on
495495
{
496496
double v = corenrn_param.voltage;

coreneuron/mechanism/eion.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ the USEION statement of any model using this ion\n",
189189
#define FARADAY _faraday_codata2018
190190
#define gasconstant _gasconstant_codata2018
191191
#endif
192+
193+
// extern variables require acc declare
194+
#pragma acc declare create(celsius)
195+
192196
#define ktf (1000. * gasconstant * (celsius + 273.15) / FARADAY)
193197

194198
double nrn_nernst(double ci, double co, double z, double celsius) {

coreneuron/mechanism/membfunc.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ extern void nrn_writes_conc(int, int);
110110
extern void nrn_wrote_conc(int, double*, int, int, double**, double, int);
111111
#pragma acc routine seq
112112
double nrn_nernst(double ci, double co, double z, double celsius);
113+
#pragma acc routine seq
114+
extern double nrn_ghk(double v, double ci, double co, double z);
113115
extern void hoc_register_prop_size(int, int, int);
114116
extern void hoc_register_dparam_semantics(int type, int, const char* name);
115117

0 commit comments

Comments
 (0)