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

Commit a56aa84

Browse files
authored
Update voltage vector from GPU to CPU if trajectories are recorded (#357)
- NEURON can request various trajectories from CoreNEURON - In this implementation we are just updating voltage vector and satisfy the use case of olfactory 3d-bulb model - We will need more fine grain approach (for future PR)
1 parent b1ee4fa commit a56aa84

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

coreneuron/gpu/nrn_acc_manager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,21 @@ void update_nrnthreads_on_device(NrnThread* threads, int nthreads) {
752752
#endif
753753
}
754754

755+
/**
756+
* Copy voltage vector from GPU to CPU
757+
*
758+
* \todo Currently we are copying all voltage vector from GPU
759+
* to CPU. We need fine-grain implementation to copy
760+
* only requested portion of the voltage vector.
761+
*/
762+
void update_voltage_from_gpu(NrnThread* nt) {
763+
if (nt->compute_gpu && nt->end > 0) {
764+
double* voltage = nt->_actual_v;
765+
int num_voltage = nrn_soa_padded_size(nt->end, 0);
766+
#pragma acc update host(voltage[0 : num_voltage])
767+
}
768+
}
769+
755770
void update_matrix_from_gpu(NrnThread* _nt) {
756771
#ifdef _OPENACC
757772
if (_nt->compute_gpu && (_nt->end > 0)) {

coreneuron/gpu/nrn_acc_manager.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void update_matrix_to_gpu(NrnThread* _nt);
2020
void update_net_receive_buffer(NrnThread* _nt);
2121
void realloc_net_receive_buffer(NrnThread* nt, Memb_list* ml);
2222
void update_net_send_buffer_on_host(NrnThread* nt, NetSendBuffer_t* nsb);
23+
void update_voltage_from_gpu(NrnThread* nt);
2324
void init_gpu();
2425

2526
} // namespace coreneuron

coreneuron/sim/fadvance_core.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ void nrncore2nrn_send_values(NrnThread* nth) {
286286

287287
TrajectoryRequests* tr = nth->trajec_requests;
288288
if (tr) {
289+
// \todo Check if user has requested voltages for this NrnThread object.
290+
// Currently we are updating voltages if there is any trajectory
291+
// requested by NEURON.
292+
update_voltage_from_gpu(nth);
293+
289294
if (tr->varrays) { // full trajectories into Vector data
290295
double** va = tr->varrays;
291296
int vs = tr->vsize++;

0 commit comments

Comments
 (0)