Skip to content

Commit

Permalink
Add unique read_csv in utility (cms-patatrack#87)
Browse files Browse the repository at this point in the history
* Add unique `read_csv` in utility

* Update benchmarking scripts
  • Loading branch information
sbaldu authored Feb 7, 2025
1 parent 816f15c commit e73a582
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 58 deletions.
2 changes: 1 addition & 1 deletion benchmark/dataset_size/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "CLUEstering/DataFormats/Points.hpp"
#include "CLUEstering/DataFormats/alpaka/PointsAlpaka.hpp"

#include "read_csv.hpp"
#include "CLUEstering/utility/read_csv.hpp"

#include <pybind11/embed.h>
#include <pybind11/stl_bind.h>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/profiling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "CLUEstering/DataFormats/Points.hpp"
#include "CLUEstering/DataFormats/alpaka/PointsAlpaka.hpp"

#include "read_csv.hpp"
#include "CLUEstering/utility/read_csv.hpp"

namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
void run(const std::string& input_file) {
Expand Down
46 changes: 0 additions & 46 deletions benchmark/profiling/read_csv.hpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@

#ifndef read_csv_hpp
#define read_csv_hpp
#pragma once

#include <fstream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "CLUEstering/DataFormats/alpaka/AlpakaVecArray.hpp"

using clue::VecArray;

template <typename T, size_t NDim>
std::vector<T> read_csv(const std::string& file_path) {
std::fstream file(file_path);
Expand All @@ -20,9 +14,9 @@ std::vector<T> read_csv(const std::string& file_path) {
}
auto n_points = std::count(
std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), '\n');

std::vector<float> coords((NDim + 1) * n_points);

file = std::fstream(file_path);
// discard the header
std::string buffer;
getline(file, buffer);
Expand All @@ -42,5 +36,3 @@ std::vector<T> read_csv(const std::string& file_path) {

return coords;
}

#endif

0 comments on commit e73a582

Please sign in to comment.