Apply suggestions from code review
Co-authored-by: Wiebe van Breukelen <breukelen@astron.nl>
This commit is contained in:
@@ -57,6 +57,10 @@ static void benchmark_cosf(benchmark::State &state) {
|
||||
reinterpret_cast<float *>(backend.allocate_memory(N * sizeof(float)));
|
||||
float *c =
|
||||
reinterpret_cast<float *>(backend.allocate_memory(N * sizeof(float)));
|
||||
|
||||
if (!x || !c) {
|
||||
throw std::runtime_error("Buffer allocation failed");
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
state.counters["init_ms"] =
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(end - start)
|
||||
@@ -91,6 +95,9 @@ static void benchmark_sincosf(benchmark::State &state) {
|
||||
reinterpret_cast<float *>(backend.allocate_memory(N * sizeof(float)));
|
||||
float *c =
|
||||
reinterpret_cast<float *>(backend.allocate_memory(N * sizeof(float)));
|
||||
if (!x || !s || !c) {
|
||||
throw std::runtime_error("Buffer allocation failed");
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
state.counters["init_ms"] =
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(end - start)
|
||||
|
||||
@@ -12,10 +12,10 @@ public:
|
||||
virtual void init(size_t n = 0) {}
|
||||
|
||||
virtual void *allocate_memory(size_t bytes) const {
|
||||
return std::malloc(bytes);
|
||||
return static_cast<void*>(new uint8_t[bytes]);
|
||||
};
|
||||
|
||||
virtual void free_memory(void *ptr) const { std::free(ptr); };
|
||||
virtual void free_memory(void *ptr) const { delete[] ptr; };
|
||||
|
||||
// Compute sine for n elements
|
||||
virtual void compute_sinf(size_t n, const float *x, float *s) const = 0;
|
||||
|
||||
Reference in New Issue
Block a user