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

Bug fix for the GPU execution of BBP model: issue with mechanism data offset - #590

Merged
pramodk merged 3 commits into
masterfrom
pramodk/channel-benchmark-gpu-fix
Jul 19, 2021
Merged

pramodk merged 3 commits into
masterfrom
pramodk/channel-benchmark-gpu-fix

Conversation

@pramodk

@pramodk pramodk commented Jul 16, 2021

Copy link
Copy Markdown
Collaborator
* Analysis of the bug:
  - Blue Brain model (channel-benchmark) was showing diferent spikes
    after few timesteps. Spikes were shifted and initially appeared
    to be floating point discrepencies.
  - Closely looking into NET_RECEIVE method revealed that the mechanism
    data accessed in net_receieve function was wrong. Somehow accessing
    variables like NMDA_ratio was showing wrong values. The nrn_state()
    had correct values.
  - The net_receieve function was accessing ml->data inside OpenACC loop.
    Accessing ml->data was providing different pointer inside OpenACC loop.
* Fix for the bug:
  - some mechanisms can have dparam semantics for diam data and it is
    added into nt->data (after matrix elements).
  - When calculating offert for mechanism data, this extra semantics
    data was not considered. Adjusting the offset fixes the issue.
  - Additionally, we do not need to rely on offset but we can use
    acc_deviceptr to find corresponding device pointer directly.
    This is more reliable than manually calculating offset.

See initial fix in a7a95c9 and then simplification in 0ac3ab9.

How to Run?

Run channel benchmark on CPU vs GPU and compare spikes

export SIM_TIME=100
export NUM_CELLS=100
export PRCELL_GID=1

srun -n 1 dplace ./cpu/x86_64/special -mpi -c arg_tstop=$SIM_TIME -c arg_dump_coreneuron_model=1 -c arg_target_count=$NUM_CELLS -c arg_prcell_gid=$PRCELL_GID $HOC_LIBRARY_PATH/init.hoc 2>&1 | tee neuron.log
srun -n 1 dplace ./cpu/x86_64/special-core -e $SIM_TIME --mpi -d coredat --prcellgid $PRCELL_GID 2>&1 | tee coreneuron.log
mv out.dat out.dat.cpu
srun -n 1 dplace ./gpu/x86_64/special-core -e $SIM_TIME --mpi -d coredat --prcellgid $PRCELL_GID --gpu --cell-permute=1 2>&1 | tee coreneuron.gpu.log
mv out.dat out.dat.gpu
diff out.dat out.dat.cpu out.dat out.dat.gpu

Test System
BB5 + GPU

Use certain branches for the SimulationStack CI

CI_BRANCHES:NEURON_BRANCH=master,

pramodk added 3 commits July 17, 2021 08:08
… offset

* Analysis of the bug:
  - Blue Brain model (channel-benchmark) was showing diferent spikes
    after few timesteps. Spikes were shifted and initially appeared
    to be floating point discrepencies.
  - Closely looking into NET_RECEIVE method revealed that the mechanism
    data accessed in net_receieve function was wrong. Somehow accessing
    variables like NMDA_ratio was showing wrong values. The nrn_state()
    had correct values.
  - The net_receieve function was accessing ml->data inside OpenACC loop.
    Accessing ml->data was providing different pointer inside OpenACC loop.
* Fix for the bug:
  - some mechanisms can have dparam semantics for diam data and it is
    added into nt->data (after matrix elements).
  - When calculating offert for mechanism data, this extra semantics
    data was not considered. Adjusting the offset fixes the issue.
  - Additionally, we do not need to rely on offset but we can use
    acc_deviceptr to find corresponding device pointer directly.
    This is more reliable than manually calculating offset.
@pramodk
pramodk force-pushed the pramodk/channel-benchmark-gpu-fix branch from bbb6f60 to 55b4708 Compare July 17, 2021 06:09

@olupton olupton left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The CI failure looks like #586 to me, so I think we can ignore it for now.

(I won't be sad when this nrn_acc_manager code is replaced!)

@iomaganaris iomaganaris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Nasty bug and good catch!
+1 to Olli's comment

@pramodk
pramodk merged commit 838b9bf into master Jul 19, 2021
@pramodk
pramodk deleted the pramodk/channel-benchmark-gpu-fix branch July 19, 2021 09:19
pramodk added a commit to neuronsimulator/nrn that referenced this pull request Nov 2, 2022
… offset (BlueBrain/CoreNeuron#590)

* Analysis of the bug:
  - Blue Brain model (channel-benchmark) was showing diferent spikes
    after few timesteps. Spikes were shifted and initially appeared
    to be floating point discrepencies.
  - Closely looking into NET_RECEIVE method revealed that the mechanism
    data accessed in net_receieve function was wrong. Somehow accessing
    variables like NMDA_ratio was showing wrong values. The nrn_state()
    had correct values.
  - The net_receieve function was accessing ml->data inside OpenACC loop.
    Accessing ml->data was providing different pointer inside OpenACC loop.
* Fix for the bug:
  - some mechanisms can have dparam semantics for diam data and it is
    added into nt->data (after matrix elements).
  - When calculating offert for mechanism data, this extra semantics
    data was not considered. Adjusting the offset fixes the issue.
  - Additionally, we do not need to rely on offset but we can use
    acc_deviceptr to find corresponding device pointer directly.
    This is more reliable than manually calculating offset.
* Rely on acc_deviceptr (reliable) than manually calculating offsets (fragile)

CoreNEURON Repo SHA: BlueBrain/CoreNeuron@838b9bf
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants