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

Commit 8c9e6a7

Browse files
committed
Added stream id vector in NrnThread
1 parent d03c45f commit 8c9e6a7

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

coreneuron/io/phase2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,9 @@ void Phase2::populate(NrnThread& nt, const UserParams& userParams) {
875875
* greater than number of omp threads.
876876
*/
877877
#if defined(_OPENMP)
878-
nt.stream_id = omp_get_thread_num();
878+
const auto omp_thread_num = omp_get_thread_num();
879+
nt.stream_id = omp_thread_num;
880+
nt.streams[nt.stream_id] = omp_thread_num;
879881
#endif
880882

881883
int shadow_rhs_cnt = 0;

coreneuron/sim/multicore.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ void nrn_threads_create(int n) {
106106
for (int i = 0; i < nrn_nthread; ++i) {
107107
NrnThread& nt = nrn_threads[i];
108108
nt.id = i;
109+
#if defined(_OPENMP)
110+
nt.streams.reserve(omp_get_num_threads());
111+
#endif
109112
for (int j = 0; j < BEFORE_AFTER_SIZE; ++j) {
110113
nt.tbl[j] = nullptr;
111114
}

coreneuron/sim/multicore.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ struct NrnThread: public MemoryManaged {
130130

131131
NrnThreadBAList* tbl[BEFORE_AFTER_SIZE]; /* wasteful since almost all empty */
132132

133-
int shadow_rhs_cnt = 0; /* added to facilitate the NrnThread transfer to GPU */
134-
int compute_gpu = 0; /* define whether to compute with gpus */
135-
int stream_id = 0; /* define where the kernel will be launched on GPU stream */
133+
int shadow_rhs_cnt = 0; /* added to facilitate the NrnThread transfer to GPU */
134+
int compute_gpu = 0; /* define whether to compute with gpus */
135+
int stream_id = 0; /* define where the kernel will be launched on GPU stream */
136+
std::vector<int> streams; /* vector of stream ids needed for async execution of OpenMP in multiple streams */
136137
int _net_send_buffer_size = 0;
137138
int _net_send_buffer_cnt = 0;
138139
int* _net_send_buffer = nullptr;

0 commit comments

Comments
 (0)