Project
Loading...
Searching...
No Matches
GPUReconstructionCUDAInternals.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15// All CUDA-header related stuff goes here, so we can run CING over GPUReconstructionCUDA
16
17#ifndef GPURECONSTRUCTIONCUDAINTERNALS_H
18#define GPURECONSTRUCTIONCUDAINTERNALS_H
19
20#include <cuda.h>
21#include "GPULogging.h"
22#include <vector>
23#include <memory>
24#include <string>
25#include "GPUCommonHelpers.h"
26
27namespace o2::gpu
28{
29
31 std::vector<std::unique_ptr<CUmodule>> kernelModules; // module for RTC compilation
32 std::vector<std::unique_ptr<CUfunction>> kernelFunctions; // vector of ptrs to RTC kernels
33 cudaStream_t Streams[constants::GPU_MAX_STREAMS]; // Pointer to array of CUDA Streams
34
35 static void getArgPtrs(const void** pArgs) {}
36 template <typename T, typename... Args>
37 static void getArgPtrs(const void** pArgs, const T& arg, const Args&... args)
38 {
39 *pArgs = &arg;
40 getArgPtrs(pArgs + 1, args...);
41 }
42};
43
45{
46 public:
47 GPUDebugTiming(bool d, GPUReconstructionProcessing::deviceEvent* t, cudaStream_t* s, const GPUReconstructionProcessing::krnlSetupTime& x, GPUReconstructionCUDA* r) : mDeviceTimers(t), mStreams(s), mXYZ(x), mRec(r), mDo(d)
48 {
49 if (mDo) {
50 if (mDeviceTimers) {
51 mRec->GPUChkErr(cudaEventRecord(mDeviceTimers[0].get<cudaEvent_t>(), mStreams[mXYZ.x.stream]));
52 } else {
53 mTimer.ResetStart();
54 }
55 }
56 }
58 {
59 if (mDo && mXYZ.t == 0.) {
60 if (mDeviceTimers) {
61 mRec->GPUChkErr(cudaEventRecord(mDeviceTimers[1].get<cudaEvent_t>(), mStreams[mXYZ.x.stream]));
62 mRec->GPUChkErr(cudaEventSynchronize(mDeviceTimers[1].get<cudaEvent_t>()));
63 float v;
64 mRec->GPUChkErr(cudaEventElapsedTime(&v, mDeviceTimers[0].get<cudaEvent_t>(), mDeviceTimers[1].get<cudaEvent_t>()));
65 mXYZ.t = v * 1.e-3f;
66 } else {
67 mRec->GPUChkErr(cudaStreamSynchronize(mStreams[mXYZ.x.stream]));
68 mXYZ.t = mTimer.GetCurrentElapsedTime();
69 }
70 }
71 }
72
73 private:
75 cudaStream_t* mStreams;
78 HighResTimer mTimer;
79 bool mDo;
80};
81
82static_assert(std::is_convertible_v<cudaEvent_t, void*>, "CUDA event type incompatible to deviceEvent");
83
84} // namespace o2::gpu
85
86#endif
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
double GetCurrentElapsedTime(bool reset=false)
Definition timer.cxx:117
void ResetStart()
Definition timer.cxx:70
GPUDebugTiming(bool d, GPUReconstructionProcessing::deviceEvent *t, cudaStream_t *s, const GPUReconstructionProcessing::krnlSetupTime &x, GPUReconstructionCUDA *r)
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
cudaStream_t Streams[constants::GPU_MAX_STREAMS]
static void getArgPtrs(const void **pArgs, const T &arg, const Args &... args)
std::vector< std::unique_ptr< CUmodule > > kernelModules
std::vector< std::unique_ptr< CUfunction > > kernelFunctions