Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check for occurrences of multiple pre-post synapses #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove check for occurrences of multiple pre-post synapses
This check is only required when one of the `SynapticPathway` objects of
the `Synapses` object does not use atomics and has synaptic effect mode
`target`. Since we use atomics by default now, I removed the check. If
we ever want to be able to not use atomics, we need to reactivate the
multi occurrence check here accordingly (see comments in code of this
commit).
  • Loading branch information
denisalevi committed Nov 1, 2022
commit 958e31f2a5d72e37617470b4ed6d1783bc1a7642
2 changes: 2 additions & 0 deletions brian2cuda/templates/synapses.cu
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ printf("INFO _run_kernel_{{codeobj_name}}: Using %d threads per bundle\n", num_t
num_loops = 1;

{% elif synaptic_effects == "target" %}{# not uses_atomics #}
LOG_ERROR("Internal error, check this line with git blame in brian2cuda source code: %s(%d)\n", __FILE__, __LINE__);
exit(1);
// Synaptic effects modify target group variables but NO source group variables.
num_blocks = num_parallel_blocks;
num_loops = 1;
Expand Down
10 changes: 9 additions & 1 deletion brian2cuda/templates/synapses_create_array.cu
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ CUDA_CHECK_MEMORY();
// update the total number of synapses
{{N}} = newsize;

{# We don't care about ocurrences of multiple source-target pairs if we have
not multisynaptic indices in the model and are using atomics in
synapses.cu. Unfortunately, we don't know here if we are using atomics
in synapses.cu. Need to find a way to expose that boolean here via
CudaGenerator, where it is set. But for now, we assume, synapses.cu uses
atomics (else there an error is raised there) #}
{% if multisynaptic_index %}
// Check for occurrence of multiple source-target pairs in synapses ("synapse number")
std::map<std::pair<int32_t, int32_t>, int32_t> source_target_count;
for (int _i=0; _i<newsize; _i++)
Expand All @@ -121,7 +128,8 @@ for (int _i=0; _i<newsize; _i++)
{% endif %}
}
}
// Check
{% endif %}

// copy changed host data to device
dev{{_dynamic_N_incoming}} = {{_dynamic_N_incoming}};
dev{{_dynamic_N_outgoing}} = {{_dynamic_N_outgoing}};
Expand Down
8 changes: 8 additions & 0 deletions brian2cuda/templates/synapses_create_generator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ std::cout << std::endl;
// Also update the total number of synapses
{{N}} = newsize;

{# We don't care about ocurrences of multiple source-target pairs if we have
not multisynaptic indices in the model and are using atomics in
synapses.cu. Unfortunately, we don't know here if we are using atomics
in synapses.cu. Need to find a way to expose that boolean here via
CudaGenerator, where it is set. But for now, we assume, synapses.cu uses
atomics (else there an error is raised there) #}
{% if multisynaptic_index %}
// Check for occurrence of multiple source-target pairs in synapses ("synapse number")
std::map<std::pair<int32_t, int32_t>, int32_t> source_target_count;
for (int _i=0; _i<newsize; _i++)
Expand All @@ -447,6 +454,7 @@ std::cout << std::endl;
{% endif %}
}
}
{% endif %}

// copy changed host data to device
dev{{_dynamic_N_incoming}} = {{_dynamic_N_incoming}};
Expand Down