22 {
23 if(argc < 4) {
24 std::cout<<"trigGpuTest usage: ./trigGpuTest <geo_file.bin> <data_dir> nevents"<<std::endl;
25 return 0;
26 }
27
28
29
30
31 void*
handle = dlopen(
"libTrigInDetCUDA.so", RTLD_LAZY);
32
33 if(!handle) {
34 fprintf(stderr, "cannot load the factory library : %s\n", dlerror());
35 return EXIT_FAILURE;
36 }
37
38 dlerror();
39
40
41
43 int (*getFactoryId)();
45
47 getFactoryId = (int (*)()) dlsym(handle, "getFactoryId");
49
50 std::cout<<"factory library id = "<<std::hex<<getFactoryId()<<std::dec<<std::endl;
51
53
55
56 if(!cfgResult) {
57 std::cout<<"Factory config failed"<<std::endl;
58 dlclose(handle);
59 return -2;
60 }
61
62
63 const size_t bufferOffset = 256;
64
66
67 std::string geoName(argv[1]);
68
69 std::cout<<"reading geometry from file "<<geoName<<std::endl;
70
71 size_t bSize = pBG->
load(geoName);
72
73 std::cout<<"loaded "<<bSize<<" bytes"<<std::endl;
74
75 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
76
77 delete pBG;
78
80
82
83
84 std::string data_path(argv[2]);
85 std::vector<std::string> event_files;
86
87 for(const auto& entry : std::experimental::filesystem::directory_iterator(data_path)) {
88 event_files.push_back(
entry.path());
89 }
90
92
93 std::cout<<
"running the GPU test with "<<
nEvents<<
" events"<<std::endl;
94
96
97 int fileIdx = 0;
98
99 std::ofstream timeFile("results.csv");
100
101 timeFile<<"nsp,nseeds,time"<<std::endl;
102
103 for(
int iEvent=0;iEvent<
nEvents;iEvent++) {
104
105 const std::string&
fileName = event_files[fileIdx];
106
107 fileIdx++;
108 if(fileIdx >= (int)event_files.size()) {
109 fileIdx = 0;
110 }
111
112 std::cout<<
"reading event from file "<<
fileName<<std::endl;
113
114 bSize = pB->
load(fileName);
115
117
119
120 tbb::tick_count tzero = tbb::tick_count::now();
121
122 std::shared_ptr<TrigAccel::OffloadBuffer> pBuff = std::make_shared<TrigAccel::OffloadBuffer>(pB);
123
125
126 if(!pJob) {
127 std::cout<<"ERROR: cannot create work item"<<std::endl;
128 return -3;
129 }
130
132
133 tbb::tick_count tnow=tbb::tick_count::now();
134 tbb::tick_count::interval_t
duration = tnow - tzero;
135 std::cout<<
"triplet making took "<<
duration.seconds()*1000.0<<
" ms"<<std::endl;
136
137 std::shared_ptr<TrigAccel::OffloadBuffer> pOB = pJob->
getOutput();
138
140
141 std::cout<<
"Found "<<pOutput->
m_nSeeds<<
" triplets"<<std::endl;
143
144 delete pJob;
145 }
146
147 timeFile.close();
148
149 delete pB;
150
151 deleteFactory(pW);
152
153 dlclose(handle);
154
155
156
157}
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...
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
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