-
Notifications
You must be signed in to change notification settings - Fork 61
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
Polish CodeQL and do some chores #2255
Changes from 7 commits
e6d0e14
61fff65
9f5d14e
8b0c6f9
a170cfa
da0d437
d48759d
9d25ce6
883065e
2e2f329
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
#include <algorithm> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <arbor/spike.hpp> | ||
|
||
#include "distributed_context.hpp" | ||
#include "label_resolution.hpp" | ||
#include "threading/threading.hpp" | ||
#include "util/rangeutil.hpp" | ||
|
||
namespace arb { | ||
|
@@ -26,7 +24,7 @@ struct dry_run_context_impl { | |
count_type local_size = local_spikes.size(); | ||
|
||
std::vector<spike> gathered_spikes; | ||
gathered_spikes.reserve(local_size*num_ranks_); | ||
gathered_spikes.reserve(std::size_t{local_size}*num_ranks_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't change the (effective) maximum size of the gathered_spikes vector without also changing the range of the indices in the loop 35-37. We ultimately make a partition of the indices into the variable
|
||
|
||
for (count_type i = 0; i < num_ranks_; i++) { | ||
util::append(gathered_spikes, local_spikes); | ||
|
@@ -49,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 { | ||
using count_type = typename gathered_vector<cell_gid_type>::count_type; | ||
|
||
count_type local_size = local_gids.size(); | ||
size_t local_size = local_gids.size(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and all other instance in that file. |
||
|
||
std::vector<cell_gid_type> gathered_gids; | ||
gathered_gids.reserve(local_size*num_ranks_); | ||
|
||
for (count_type i = 0; i < num_ranks_; i++) { | ||
for (size_t i = 0; i < num_ranks_; i++) { | ||
util::append(gathered_gids, local_gids); | ||
} | ||
|
||
for (count_type i = 0; i < num_ranks_; i++) { | ||
for (count_type j = i*local_size; j < (i+1)*local_size; j++){ | ||
for (size_t i = 0; i < num_ranks_; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 more |
||
for (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 (count_type i = 0; i <= num_ranks_; i++) { | ||
for (size_t i = 0; i <= num_ranks_; i++) { | ||
partition.push_back(static_cast<count_type>(i*local_size)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no point doing everything in |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,8 +138,8 @@ using time_type = double; | |
constexpr time_type terminal_time = std::numeric_limits<time_type>::max(); | ||
|
||
// For holding counts and indexes into generated sample data. | ||
|
||
using sample_size_type = std::int32_t; | ||
using sample_index_type = std::int32_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this type actually used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It -- currently -- isn't, but it's useful when we are considering things like: sample_size_type a = ..., b = ..., c = a - b; due to the potential overflow. |
||
using sample_size_type = std::uint32_t; | ||
|
||
// Enumeration for execution back-end targets, as specified in domain decompositions. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,11 +75,13 @@ int indent_manip::xindex() { | |
|
||
static void apply_indent_prefix(std::ios& s, int index) { | ||
if (auto pbuf = dynamic_cast<prefixbuf*>(s.rdbuf())) { | ||
indent_stack* stack_ptr = static_cast<indent_stack*>(s.pword(index)); | ||
unsigned tabwidth = s.iword(index); | ||
|
||
unsigned tabs = (!stack_ptr || stack_ptr->empty())? 0: stack_ptr->top(); | ||
pbuf->prefix = std::string(tabs*tabwidth, ' '); | ||
if (auto ptr = static_cast<indent_stack*>(s.pword(index)); ptr && !ptr->empty()) { | ||
unsigned n_tab = ptr->top(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Argh! This is terribly misleading formatting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I knew you were going to love it. Isn't it beautiful how the second line of the condition and the first line of the body line up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has a certain horrible charm to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed it. |
||
unsigned width = s.iword(index); | ||
pbuf->prefix = std::string(n_tab*width, ' '); | ||
|
||
} else { | ||
pbuf->prefix = std::string(); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes to make CodeQL happy, or just for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readability. I can get behind
a*b + c
for similarities with mathematical notation, but=
,==
, and especially-
tend to merge visually into one token. Or: Too similar tosnake_case
for my liking.As much of the code, especially newer parts is in this style, I tend to adjust these expression in passing when editing files. Same for removing redundant headers, which my IDE picks up on these days.