21 {
22 if(argc < 4) {
23 std::cout<<"trigGpuTest usage: ./trigGpuTest <geo_file.bin> <data_dir> nevents"<<std::endl;
24 return 0;
25 }
26
27
28
29
30 void* handle = dlopen("libTrigInDetCUDA.so", RTLD_LAZY);
31
32 if(!handle) {
33 fprintf(stderr, "cannot load the factory library : %s\n", dlerror());
34 return EXIT_FAILURE;
35 }
36
37 dlerror();
38
39
40
42 int (*getFactoryId)();
44
46 getFactoryId = (int (*)()) dlsym(handle, "getFactoryId");
48
49 std::cout<<"factory library id = "<<std::hex<<getFactoryId()<<std::dec<<std::endl;
50
52
54
55 if(!cfgResult) {
56 std::cout<<"Factory config failed"<<std::endl;
57 dlclose(handle);
58 return -2;
59 }
60
61
62 const size_t bufferOffset = 256;
63
65
66 std::string geoName(argv[1]);
67
68 std::cout<<"reading geometry from file "<<geoName<<std::endl;
69
70 size_t bSize = pBG->
load(geoName);
71
72 std::cout<<"loaded "<<bSize<<" bytes"<<std::endl;
73
74 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
75
76 delete pBG;
77
79
81
82
83 std::string data_path(argv[2]);
84 std::vector<std::string> event_files;
85
86 for(const auto& entry : std::experimental::filesystem::directory_iterator(data_path)) {
87 event_files.push_back(
entry.path());
88 }
89
91
92 std::cout<<
"running the GPU test with "<<
nEvents<<
" events"<<std::endl;
93
95
96 int fileIdx = 0;
97
98 std::ofstream timeFile("results.csv");
99
100 timeFile<<"nsp,nseeds,time"<<std::endl;
101
102 for(
int iEvent=0;iEvent<
nEvents;iEvent++) {
103
104 const std::string&
fileName = event_files[fileIdx];
105
106 fileIdx++;
107 if(fileIdx >= (int)event_files.size()) {
108 fileIdx = 0;
109 }
110
111 std::cout<<
"reading event from file "<<
fileName<<std::endl;
112
113 bSize = pB->
load(fileName);
114
116
118
119 tbb::tick_count tzero = tbb::tick_count::now();
120
121 std::shared_ptr<TrigAccel::OffloadBuffer> pBuff = std::make_shared<TrigAccel::OffloadBuffer>(pB);
122
124
125 if(!pJob) {
126 std::cout<<"ERROR: cannot create work item"<<std::endl;
127 return -3;
128 }
129
131
132 tbb::tick_count tnow=tbb::tick_count::now();
133 tbb::tick_count::interval_t
duration = tnow - tzero;
134 std::cout<<
"triplet making took "<<
duration.seconds()*1000.0<<
" ms"<<std::endl;
135
136 std::shared_ptr<TrigAccel::OffloadBuffer> pOB = pJob->
getOutput();
137
139
140 std::cout<<
"Found "<<pOutput->
m_nSeeds<<
" triplets"<<std::endl;
142
143 delete pJob;
144 }
145
146 timeFile.close();
147
148 delete pB;
149
150 deleteFactory(pW);
151
152 dlclose(handle);
153
154
155
156}
virtual Work * createWork(int, std::shared_ptr< OffloadBuffer > data)=0
virtual bool configure()=0
virtual std::shared_ptr< OffloadBuffer > getOutput()=0
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
struct TrigAccel::SeedMakingJob SEED_MAKING_JOB
struct TrigAccel::OutputSeedStorage OUTPUT_SEED_STORAGE
struct TrigAccel::SpacePointStorage SPACEPOINT_STORAGE
size_t load(const std::string &name)
SPACEPOINT_STORAGE m_data