Skip to content

Commit

Permalink
Revert to unsighed types.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenhater committed Feb 21, 2024
1 parent 9d25ce6 commit 883065e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions arbor/communication/dry_run_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace arb {

struct dry_run_context_impl {
using count_type = typename gathered_vector<spike>::count_type;

explicit dry_run_context_impl(unsigned num_ranks, unsigned num_cells_per_tile):
num_ranks_(num_ranks), num_cells_per_tile_(num_cells_per_tile) {};
Expand All @@ -19,12 +20,11 @@ struct dry_run_context_impl {
}
gathered_vector<spike>
gather_spikes(const std::vector<spike>& local_spikes) const {
using count_type = typename gathered_vector<spike>::count_type;

count_type local_size = local_spikes.size();

std::vector<spike> gathered_spikes;
gathered_spikes.reserve(std::size_t{local_size}*num_ranks_);
gathered_spikes.reserve(local_size*num_ranks_);

for (count_type i = 0; i < num_ranks_; i++) {
util::append(gathered_spikes, local_spikes);
Expand All @@ -47,25 +47,24 @@ struct dry_run_context_impl {
void remote_ctrl_send_done() const {}
gathered_vector<cell_gid_type>
gather_gids(const std::vector<cell_gid_type>& local_gids) const {
std::size_t local_size = local_gids.size();
count_type local_size = local_gids.size();

std::vector<cell_gid_type> gathered_gids;
gathered_gids.reserve(local_size*num_ranks_);

for (size_t i = 0; i < num_ranks_; i++) {
for (count_type i = 0; i < num_ranks_; i++) {
util::append(gathered_gids, local_gids);
}

for (size_t i = 0; i < num_ranks_; i++) {
for (count_type i = 0; i < num_ranks_; i++) {
for (std::size_t j = i*local_size; j < (i+1)*local_size; j++){
gathered_gids[j] += num_cells_per_tile_*i;
}
}

using count_type = typename gathered_vector<cell_gid_type>::count_type;
std::vector<count_type> partition;
for (std::size_t i = 0; i <= num_ranks_; i++) {
partition.push_back(static_cast<count_type>(i*local_size));
for (count_type i = 0; i <= num_ranks_; i++) {
partition.push_back(i*local_size);
}

return gathered_vector<cell_gid_type>(std::move(gathered_gids), std::move(partition));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_sde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class sde_recipe: public simple_recipe_base {
// generic advance method used for all pertinent mechanisms
// first argument indicates the number of random variables
void advance_common(unsigned int n_rv, arb_mechanism_ppack* pp) {
auto width = static_cast<size_t>(pp->width);
auto width = pp->width;
arb_value_type* ptr = archive_ptr->claim(width*n_rv);

Check failure

Code scanning / CodeQL

Multiplication result converted to larger type High test

Multiplication result may overflow 'unsigned int' before it is converted to 'size_t'.
for (arb_size_type j=0; j<n_rv; ++j) {
for (arb_size_type i=0; i<width; ++i) {
Expand Down

0 comments on commit 883065e

Please sign in to comment.