Skip to content

Commit

Permalink
Fixed message maps type: #16
Browse files Browse the repository at this point in the history
Fixed size_t/uint64_t mixing in message maps because not everywhere size_t == uint64_t
  • Loading branch information
maxkost committed Dec 5, 2024
1 parent 85710a0 commit 8216164
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* @kaspersky_support A. Vartenkov
* @date 07.11.2023
* @license Apache 2.0
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
Expand Down Expand Up @@ -57,7 +57,7 @@ void calculate_delta_synapse_projection(
*/
template <class DeltaLikeSynapse>
void calculate_projection_part(
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<size_t, size_t> &message_in_data,
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<knp::core::Step, size_t> &message_in_data,
MessageQueue &future_messages, uint64_t step_n, size_t part_start, size_t part_size, std::mutex &mutex)
{
calculate_projection_part_impl(projection, message_in_data, future_messages, step_n, part_start, part_size, mutex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* @kaspersky_support Artiom N.
* @date 21.02.2023
* @license Apache 2.0
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Expand Down Expand Up @@ -49,7 +49,7 @@ using MessageQueue = std::unordered_map<uint64_t, knp::core::messaging::Synaptic

template <class DeltaLikeSynapse>
void calculate_projection_part_impl(
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<size_t, size_t> &message_in_data,
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<knp::core::Step, size_t> &message_in_data,
MessageQueue &future_messages, uint64_t step_n, size_t part_start, size_t part_size, std::mutex &mutex);


Expand Down Expand Up @@ -129,7 +129,7 @@ MessageQueue::const_iterator calculate_delta_synapse_projection_data(

template <class DeltaLikeSynapse>
void calculate_projection_part_impl(
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<size_t, size_t> &message_in_data,
knp::core::Projection<DeltaLikeSynapse> &projection, const std::unordered_map<knp::core::Step, size_t> &message_in_data,
MessageQueue &future_messages, uint64_t step_n, size_t part_start, size_t part_size, std::mutex &mutex)
{
size_t part_end = std::min(part_start + part_size, projection.size());
Expand Down Expand Up @@ -191,7 +191,7 @@ void calculate_projection_part_impl(
*/
inline std::unordered_map<uint64_t, size_t> convert_spikes(const core::messaging::SpikeMessage &message)
{
std::unordered_map<size_t, size_t> result;
std::unordered_map<knp::core::Step, size_t> result;
for (auto neuron_idx : message.neuron_indexes_)
{
auto iter = result.find(neuron_idx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::vector<knp::core::messaging::SpikeMessage> convert_node_time_arrays_to_mess
{
if (nodes.size() != timestamps.size()) throw std::runtime_error("Different array sizes: nodes and timestamps.");
using Message = knp::core::messaging::SpikeMessage;
std::unordered_map<size_t, Message> message_map; // This is a result buffer.
std::unordered_map<knp::core::Step, Message> message_map; // This is a result buffer.
for (size_t i = 0; i < timestamps.size(); ++i)
{
auto step = static_cast<knp::core::Step>(timestamps[i] / time_per_step);
Expand Down

0 comments on commit 8216164

Please sign in to comment.