Skip to content

Commit 7cc32d4

Browse files
authored
Merge pull request #332 from hz-b/startEventID
remove startEventID
2 parents 07daa3b + 27c21e4 commit 7cc32d4

22 files changed

+45
-94
lines changed

Intern/rayx-core/src/Shader/DynamicElements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void dynamicElements(int gid, InvState& inv) {
7171
}
7272

7373
// store recorded events count
74-
auto eventsCount = static_cast<int>(inv.nextEventIndex - inv.pushConstants.startEventID);
74+
auto eventsCount = static_cast<int>(inv.nextEventIndex);
7575
eventsCount = std::max(0, std::min(static_cast<int>(inv.pushConstants.maxEvents), eventsCount));
7676
inv.outputRayCounts[gid] = eventsCount;
7777
}

Intern/rayx-core/src/Shader/Helper.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void init(InvState& inv) {
1111

1212
// TODO(Sven): dont waste time with initializing
1313
// sets all output rays controlled by this shader call to ETYPE_UNINIT.
14-
for (uint32_t i = uint32_t(inv.pushConstants.startEventID); i < inv.pushConstants.maxEvents; i++) {
14+
for (uint32_t i = uint32_t(0); i < inv.pushConstants.maxEvents; i++) {
1515
inv.outputRays[output_index(i, inv)].m_eventType = ETYPE_UNINIT;
1616
}
1717
inv.nextEventIndex = 0;
@@ -32,18 +32,13 @@ uint64_t rayId(InvState& inv) { return uint64_t(inv.pushConstants.rayIdStart) +
3232
// Typically used as `outputRays[output_index(i)]`.
3333
RAYX_FN_ACC
3434
uint32_t output_index(uint32_t i, InvState& inv) {
35-
return uint32_t(inv.globalInvocationId) * uint32_t(inv.pushConstants.maxEvents - inv.pushConstants.startEventID) + i -
36-
uint32_t(inv.pushConstants.startEventID);
35+
return uint32_t(inv.globalInvocationId) * uint32_t(inv.pushConstants.maxEvents) + i;
3736
}
3837

3938
// record an event and store it in the next free spot in outputRays.
4039
// `r` will typically be ray, or some related ray.
4140
RAYX_FN_ACC
4241
void recordEvent(Ray r, double w, InvState& inv) {
43-
if (inv.nextEventIndex < inv.pushConstants.startEventID) {
44-
inv.nextEventIndex += 1;
45-
return;
46-
}
4742
if (inv.finalized) {
4843
return;
4944
}

Intern/rayx-core/src/Shader/InvocationState.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct PushConstants { // TODO(Jannis): PushConstants is not an expressive name
1616
double randomSeed;
1717
double maxEvents;
1818
double sequential;
19-
double startEventID;
2019
};
2120

2221
struct _debug_struct {

Intern/rayx-core/src/Tracer/DeviceTracer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class RAYX_API DeviceTracer {
3030
public:
3131
virtual ~DeviceTracer() = default;
3232

33-
virtual BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1,
34-
int startEventID = 0) = 0;
33+
virtual BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1) = 0;
3534

3635
protected:
3736
PushConstants m_pushConstants;

Intern/rayx-core/src/Tracer/SimpleTracer.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class SimpleTracer : public DeviceTracer {
4848
public:
4949
SimpleTracer(int deviceIndex);
5050

51-
BundleHistory trace(const Beamline&, Sequential sequential, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents,
52-
int startEventID) override;
51+
BundleHistory trace(const Beamline&, Sequential sequential, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents) override;
5352

5453
private:
5554
struct TraceResult {
@@ -124,8 +123,7 @@ template <typename Acc>
124123
SimpleTracer<Acc>::SimpleTracer(int deviceIndex) : m_deviceIndex(deviceIndex) {}
125124

126125
template <typename Acc>
127-
BundleHistory SimpleTracer<Acc>::trace(const Beamline& b, Sequential seq, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents,
128-
int startEventID) {
126+
BundleHistory SimpleTracer<Acc>::trace(const Beamline& b, Sequential seq, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents) {
129127
RAYX_PROFILE_FUNCTION_STDOUT();
130128
RAYX_VERB << "maxEvents: " << maxEvents;
131129

@@ -153,7 +151,7 @@ BundleHistory SimpleTracer<Acc>::trace(const Beamline& b, Sequential seq, uint64
153151
auto q = Queue(acc);
154152

155153
const auto firstBatchSize = static_cast<Idx>(glm::min(rays.size(), maxBatchSize));
156-
const auto maxOutputEventsCount = static_cast<Idx>(maxBatchSize * (maxEvents - startEventID));
154+
const auto maxOutputEventsCount = static_cast<Idx>(maxBatchSize * maxEvents);
157155
const auto initialCompactEventsSize = static_cast<Idx>(maxBatchSize * glm::min(2u, maxEvents));
158156
resizeBufferIfNeeded(q, m_batchOutput.compactEvents, initialCompactEventsSize);
159157
resizeBufferIfNeeded(q, m_batchOutput.compactEventCounts, firstBatchSize);
@@ -184,8 +182,7 @@ BundleHistory SimpleTracer<Acc>::trace(const Beamline& b, Sequential seq, uint64
184182
.numRays = (double)rays.size(),
185183
.randomSeed = randomSeed,
186184
.maxEvents = (double)maxEvents,
187-
.sequential = sequential,
188-
.startEventID = (double)startEventID};
185+
.sequential = sequential};
189186

190187
const auto inputRays = rays.data() + rayIdStart;
191188
transferToBuffer(q, cpu, m_batchInput.rays, inputRays, static_cast<Idx>(batchSize));

Intern/rayx-core/src/Tracer/Tracer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ Tracer::Tracer(const DeviceConfig& deviceConfig) {
5353
}
5454
}
5555

56-
BundleHistory Tracer::trace(const Beamline& beamline, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT, uint32_t maxEvents,
57-
int startEventID) {
58-
return m_deviceTracer->trace(beamline, sequential, max_batch_size, THREAD_COUNT, maxEvents, startEventID);
56+
BundleHistory Tracer::trace(const Beamline& beamline, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT, uint32_t maxEvents) {
57+
return m_deviceTracer->trace(beamline, sequential, max_batch_size, THREAD_COUNT, maxEvents);
5958
}
6059

6160
/// Get the last event for each ray of the bundle.

Intern/rayx-core/src/Tracer/Tracer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class RAYX_API Tracer {
2727
// This will call the trace implementation of a subclass
2828
// See `BundleHistory` for information about the return value.
2929
// `max_batch_size` corresponds to the maximal number of rays that will be put into `traceRaw` in one batch.
30-
BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1,
31-
int startEventID = 0);
30+
BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1);
3231

3332
static int defaultMaxEvents(const Beamline* beamline = nullptr);
3433

Intern/rayx-core/src/Writer/CSVWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Cell doubleToCell(double x) {
5656
return strToCell(s.c_str());
5757
}
5858

59-
void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, int startEventID) {
59+
void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format) {
6060
std::ofstream file(filename);
6161

6262
// write the header of the CSV file:
@@ -79,7 +79,7 @@ void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, cons
7979
if (i > 0) {
8080
file << DELIMITER;
8181
}
82-
double d = format[i].get_double(static_cast<uint32_t>(ray_id), static_cast<int>(event_id) + startEventID, event);
82+
double d = format[i].get_double(static_cast<uint32_t>(ray_id), static_cast<int>(event_id), event);
8383
file << doubleToCell(d).buf;
8484
}
8585
file << '\n';

Intern/rayx-core/src/Writer/CSVWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "Tracer/Tracer.h"
99
#include "Writer/Writer.h"
1010

11-
void RAYX_API writeCSV(const RAYX::BundleHistory&, const std::string& filename, const Format& format, int startEventID = 0);
11+
void RAYX_API writeCSV(const RAYX::BundleHistory&, const std::string& filename, const Format& format);
1212

1313
// loadCSV only works for csv files created using FULL_FORMAT.
1414
RAYX::BundleHistory RAYX_API loadCSV(const std::string& filename);

Intern/rayx-core/src/Writer/H5Writer.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int count(const RAYX::BundleHistory& hist) {
2020
}
2121

2222
// Re-formats `hist` into a bunch of doubles using the format.
23-
std::vector<double> toDoubles(const RAYX::BundleHistory& hist, const Format& format, int startEventID) {
23+
std::vector<double> toDoubles(const RAYX::BundleHistory& hist, const Format& format) {
2424
std::vector<double> output;
2525
output.reserve(count(hist) * format.size());
2626

@@ -29,19 +29,18 @@ std::vector<double> toDoubles(const RAYX::BundleHistory& hist, const Format& for
2929
for (uint32_t event_id = 0; event_id < ray_hist.size(); event_id++) {
3030
const RAYX::Ray& event = ray_hist[event_id];
3131
for (uint32_t i = 0; i < format.size(); i++) {
32-
double next = format[i].get_double(ray_id, event_id + startEventID, event);
32+
double next = format[i].get_double(ray_id, event_id, event);
3333
output.push_back(next);
3434
}
3535
}
3636
}
3737
return output;
3838
}
3939

40-
void writeH5(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, std::vector<std::string> elementNames,
41-
int startEventID) {
40+
void writeH5(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, std::vector<std::string> elementNames) {
4241
HighFive::File file(filename, HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate);
4342

44-
auto doubles = toDoubles(hist, format, startEventID);
43+
auto doubles = toDoubles(hist, format);
4544

4645
try {
4746
// write data
@@ -78,15 +77,12 @@ RAYX::BundleHistory fromDoubles(const std::vector<double>& doubles, const Format
7877
RAYX::RayHistory rayHist;
7978
rayHist.reserve(8); // Estimate: assume 8 events per ray on average
8079

81-
const double startEventID = doubles[1];
8280
const double* data = doubles.data();
8381

8482
for (size_t i = 0; i < numRays; ++i) {
8583
const double* rayData = data + i * formatSize;
8684

87-
double eventId = rayData[1];
88-
89-
if (eventId == startEventID && !rayHist.empty()) {
85+
if (!rayHist.empty()) {
9086
bundleHist.push_back(std::move(rayHist));
9187
rayHist.clear();
9288
rayHist.reserve(8);
@@ -120,7 +116,7 @@ RAYX::BundleHistory fromDoubles(const std::vector<double>& doubles, const Format
120116
return bundleHist;
121117
}
122118

123-
RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format, std::unique_ptr<uint32_t> startEventID) {
119+
RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format) {
124120
RAYX_PROFILE_FUNCTION_STDOUT();
125121
RAYX::BundleHistory rays;
126122

@@ -138,9 +134,6 @@ RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format
138134
RAYX_WARN << "No rays found in " << filename;
139135
return rays;
140136
}
141-
if (startEventID) {
142-
*startEventID = static_cast<uint32_t>(doubles[1]);
143-
}
144137
rays = fromDoubles(doubles, format);
145138
RAYX_VERB << "Loaded " << rays.size() << " rays from " << filename;
146139

0 commit comments

Comments
 (0)