Skip to content

Commit ff5633e

Browse files
committed
fix(probes): unique probe_size_counter per probe
1 parent e94392a commit ff5633e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

apps/core/includes/dataexporter/partial_exporter.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <span>
1111
#include <string>
1212
#include <string_view>
13+
#include <unordered_map>
1314
#include <vector>
1415

1516
namespace Core
@@ -68,11 +69,13 @@ namespace Core
6869
*
6970
* @param data A span of constant doubles containing the probe measurements.
7071
*/
71-
void write_probe(std::string_view probe_name, std::span<const double> data);
72+
void write_probe(const std::string& probe_name,
73+
std::span<const double> data);
7274

7375
private:
74-
uint64_t probe_counter_n_element; /**< Counter for the number of probe
75-
elements. */
76+
// uint64_t probe_counter_n_element; /**< Counter for the number of probe
77+
// elements. */
78+
std::unordered_map<std::string, uint64_t> probe_counter_n_element;
7679
};
7780

7881
}; // namespace Core

apps/core/src/case_data.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ namespace Core
4343
const auto [_, n_compartment] = case_data.simulation->getDimensions();
4444
partial_exporter.init_fields(case_data.params.number_exported_result,
4545
n_compartment);
46+
47+
// TODO: so far all probes are active or all probes are inactive
48+
// Find a way to select them without branching in kernels
4649
{
4750
auto probes = Simulation::ProbeAutogeneratedBuffer();
4851
case_data.simulation->setProbes(Simulation::ProbeType::LeavingTime,
4952
std::move(probes));
5053
}
54+
5155
{
5256
auto probes = Simulation::ProbeAutogeneratedBuffer();
5357
case_data.simulation->setProbes(Simulation::ProbeType::DivisionTime,

apps/core/src/dataexporter/partial_exporter.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Core
1515
const ExecInfo& info,
1616
std::string_view _filename,
1717
std::optional<export_metadata_t> user_description)
18-
: DataExporter(info, _filename, std::move(user_description)),
19-
probe_counter_n_element(0)
18+
: DataExporter(info, _filename, std::move(user_description))
19+
2020
{
2121
write_properties(std::nullopt, metadata);
2222
}
@@ -49,10 +49,13 @@ namespace Core
4949
std::vector<unsigned long long> chunk
5050
= { AutoGenerated::probe_buffer_size * sizeof(double) };
5151

52+
uint64_t counter = 0;
5253
for (const auto& name : Simulation::map_probe_name)
5354
{
5455

55-
auto ds_name = IO::format("probes/", name);
56+
const auto ds_name = IO::format("probes/", name);
57+
probe_counter_n_element.insert({ name, counter });
58+
counter += 1;
5659
MultiMatrixDescription probes
5760
= { .name = ds_name,
5861
.dims = { 0 },
@@ -81,13 +84,14 @@ namespace Core
8184
// Change probe_counter_n_element to std::vector<std::size_t> where size is
8285
// number of probe type
8386
void
84-
PartialExporter::write_probe(std::string_view probe_name,
87+
PartialExporter::write_probe(const std::string& probe_name,
8588
std::span<const double> data)
8689
{
8790
std::string data_set_name = IO::format("probes/", probe_name);
91+
auto& counter = this->probe_counter_n_element[probe_name];
8892

89-
append_array(data_set_name, data, probe_counter_n_element);
90-
probe_counter_n_element += data.size();
93+
append_array(data_set_name, data, counter);
94+
counter += data.size();
9195
}
9296

9397
void

0 commit comments

Comments
 (0)