37 using namespace Acts::UnitLiterals;
39 int main(
int argc,
char* argv[]) {
46 std::cout <<
"Read " << spacepoints.size()
47 <<
" spacepoints from file: " << cmdl.
spFile << std::endl;
52 std::vector<const TestSpacePoint*> spView;
53 spView.reserve(spacepoints.size());
54 for (
const auto& sp : spacepoints) {
55 spView.push_back(sp.get());
58 int numPhiNeighbors = 1;
60 std::vector<std::pair<int, int>> zBinNeighborsTop;
61 std::vector<std::pair<int, int>> zBinNeighborsBottom;
64 auto bottomBinFinder = std::make_shared<Acts::BinFinder<TestSpacePoint>>(
65 zBinNeighborsBottom, numPhiNeighbors);
66 auto topBinFinder = std::make_shared<Acts::BinFinder<TestSpacePoint>>(
67 zBinNeighborsTop, numPhiNeighbors);
72 sfConfig.
rMax = 160._mm;
73 sfConfig.deltaRMin = 5._mm;
74 sfConfig.deltaRMax = 160._mm;
75 sfConfig.collisionRegionMin = -250._mm;
76 sfConfig.collisionRegionMax = 250._mm;
77 sfConfig.zMin = -2800._mm;
78 sfConfig.zMax = 2800._mm;
79 sfConfig.maxSeedsPerSpM = 5;
81 sfConfig.cotThetaMax = 7.40627;
82 sfConfig.sigmaScattering = 1.00000;
83 sfConfig.minPt = 500._MeV;
84 sfConfig.impactMax = 10._mm;
87 sfOptions.
beamPos = {-.5_mm, -.5_mm};
94 sfConfig.maxBlockSize = 256;
96 sfConfig = sfConfig.toInternalUnits().calculateDerivedQuantities();
100 gridConfig.
minPt = sfConfig.minPt;
101 gridConfig.
rMax = sfConfig.rMax;
102 gridConfig.
zMax = sfConfig.zMax;
103 gridConfig.
zMin = sfConfig.zMin;
104 gridConfig.
deltaRMax = sfConfig.deltaRMax;
113 float) -> std::pair<Acts::Vector3, Acts::Vector2> {
116 return std::make_pair(
position, covariance);
126 auto grid = Acts::SpacePointGridCreator::createGrid<TestSpacePoint>(
127 gridConfig, gridOpts);
129 spView.begin(), spView.end(), ct, bottomBinFinder, topBinFinder,
132 auto spGroup_end = spGroup.
end();
137 std::cerr <<
"Invalid CUDA device (" << cmdl.
cudaDevice <<
") requested"
141 static constexpr std::size_t MEGABYTES = 1024l * 1024l;
143 if (deviceMemoryAllocation == 0) {
144 deviceMemoryAllocation =
148 std::cout <<
"Allocating " << deviceMemoryAllocation / MEGABYTES
149 <<
" MB memory on device:\n"
159 sfConfig.seedFilter = std::make_unique<Acts::SeedFilter<TestSpacePoint>>(
160 filterConfig, &hostCuts);
166 sfConfig, sfOptions, filterConfig, deviceCuts, cmdl.
cudaDevice);
173 auto start_host = std::chrono::system_clock::now();
175 std::vector<std::vector<Acts::Seed<TestSpacePoint>>> seeds_host;
179 decltype(seedFinder_host)::SeedingState
state;
182 if (spGroup_itr == spGroup.end()) {
185 auto&
group = seeds_host.emplace_back();
186 auto [bottom, middle, top] = *spGroup_itr;
189 std::back_inserter(
group), bottom,
190 middle, top, rMiddleSPRange);
195 auto end_host = std::chrono::system_clock::now();
196 double time_host = std::chrono::duration_cast<std::chrono::milliseconds>(
197 end_host - start_host)
201 std::cout <<
"Done with the seedfinding on the host" << std::endl;
209 auto start_device = std::chrono::system_clock::now();
211 std::vector<std::vector<Acts::Seed<TestSpacePoint>>> seeds_device;
213 spacePointData.
resize(spView.size());
218 if (spGroup_itr == spGroup_end) {
221 auto [bottom, middle, top] = *spGroup_itr;
223 spacePointData, spGroup.grid(), bottom, middle, top));
227 auto end_device = std::chrono::system_clock::now();
228 double time_device = std::chrono::duration_cast<std::chrono::milliseconds>(
229 end_device - start_device)
232 std::cout <<
"Done with the seedfinding on the device" << std::endl;
239 std::size_t nSeeds_host = 0, nSeeds_device = 0;
240 for (
const auto& seeds : seeds_host) {
241 nSeeds_host += seeds.size();
243 for (
const auto& seeds : seeds_device) {
244 nSeeds_device += seeds.size();
249 std::size_t nMatch = 0;
250 double matchPercentage = 0.0;
252 assert(seeds_host.size() == seeds_device.size());
253 for (
size_t i = 0;
i < seeds_host.size();
i++) {
255 const auto& seeds_in_host_region = seeds_host[
i];
256 const auto& seeds_in_device_region = seeds_device[
i];
258 for (
const auto& host_seed : seeds_in_host_region) {
259 assert(host_seed.sp().size() == 3);
261 for (
const auto& device_seed : seeds_in_device_region) {
262 assert(device_seed.sp().size() == 3);
263 if ((*(host_seed.sp()[0]) == *(device_seed.sp()[0])) &&
264 (*(host_seed.sp()[1]) == *(device_seed.sp()[1])) &&
265 (*(host_seed.sp()[2]) == *(device_seed.sp()[2]))) {
272 matchPercentage = (100.0 * nMatch) / nSeeds_host;
276 std::cout << std::endl;
277 std::cout <<
"-------------------------- Results ---------------------------"
279 std::cout <<
"| | Host | Device | Speedup/agreement |"
281 std::cout <<
"--------------------------------------------------------------"
283 std::cout <<
"| Time [s] | " << std::setw(10)
285 << std::setw(10) << time_device <<
" | " << std::setw(10)
288 <<
" |" << std::endl;
289 std::cout <<
"| Seeds | " << std::setw(10)
291 <<
" | " << std::setw(10) << nSeeds_device <<
" | "
294 <<
" |" << std::endl;
295 std::cout <<
"--------------------------------------------------------------"
297 std::cout << std::endl;