This repository was archived by the owner on Mar 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525#include < cstddef>
2626
2727namespace coreneuron {
28+ #define cnrn_target_deviceptr (h_ptr ) [&]() { std::cout << #h_ptr << std::endl; return cnrn_target_deviceptr2 (h_ptr);}()
29+
2830template <typename T>
29- T* cnrn_target_deviceptr ( const T* h_ptr) {
31+ T* cnrn_target_deviceptr2 ( T* h_ptr) {
3032#if defined(CORENEURON_ENABLE_GPU) && !defined(CORENEURON_PREFER_OPENMP_OFFLOAD) && defined(_OPENACC)
31- return static_cast <T*>(acc_deviceptr (const_cast <T*>( h_ptr) ));
33+ return static_cast <T*>(acc_deviceptr (h_ptr));
3234#elif defined(CORENEURON_ENABLE_GPU) && defined(CORENEURON_PREFER_OPENMP_OFFLOAD) && defined(_OPENMP)
33- return static_cast <T*>(omp_get_mapped_ptr (const_cast <T*>(h_ptr), omp_get_default_device ()));
35+ if (omp_get_mapped_ptr (h_ptr, omp_get_default_device ()) == nullptr ) {
36+ throw std::runtime_error (" here" );
37+ }
38+ T *d_ptr = nullptr ;
39+
40+ nrn_pragma_omp (target data use_device_ptr (h_ptr))
41+ {
42+ d_ptr = h_ptr;
43+ }
44+
45+ return d_ptr;
3446#else
3547 throw std::runtime_error (" cnrn_target_deviceptr() not implemented without OpenACC/OpenMP and gpu build" );
3648#endif
You can’t perform that action at this time.
0 commit comments