Project
Loading...
Searching...
No Matches
GPUReconstructionOCLIncludesHost.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#ifndef GPURECONSTRUCTIONOCLINCLUDESHOST_H
16#define GPURECONSTRUCTIONOCLINCLUDESHOST_H
17
18#define GPUCA_GPUTYPE_OPENCL
19#define __OPENCL_HOST__
20
21#define CL_TARGET_OPENCL_VERSION 220
22#include <CL/opencl.h>
23#include <CL/cl_ext.h>
24#include <vector>
25#include <string>
26#include <memory>
27
28typedef cl_half half;
29
30#include "GPULogging.h"
31
34#include "GPUCommonHelpers.h"
35
36using namespace o2::gpu;
37
38#include <cstring>
39#include <unistd.h>
40#include <typeinfo>
41#include <cstdlib>
42
43namespace o2::gpu
44{
46 cl_platform_id platform;
47 cl_device_id device;
48 cl_context context;
49 cl_command_queue command_queue[constants::GPU_MAX_STREAMS];
50 cl_mem mem_gpu;
52 cl_mem mem_host;
53 cl_program program;
54
55 std::vector<cl_kernel> kernels;
56};
57} // namespace o2::gpu
58
59template <typename T, typename... Args>
60inline int64_t GPUReconstructionOCL::OCLsetKernelParameters_helper(cl_kernel& kernel, int32_t i, const T& firstParameter, const Args&... restOfParameters)
61{
62 int64_t retVal = clSetKernelArg(kernel, i, sizeof(T), &firstParameter);
63 if (retVal) {
64 return retVal;
65 }
66 if constexpr (sizeof...(restOfParameters) > 0) {
67 return OCLsetKernelParameters_helper(kernel, i + 1, restOfParameters...);
68 }
69 return 0;
70}
71
72template <typename... Args>
73inline int64_t GPUReconstructionOCL::OCLsetKernelParameters(cl_kernel& kernel, const Args&... args)
74{
75 return OCLsetKernelParameters_helper(kernel, 0, args...);
76}
77
78inline int64_t GPUReconstructionOCL::clExecuteKernelA(cl_command_queue queue, cl_kernel krnl, size_t local_size, size_t global_size, cl_event* pEvent, cl_event* wait, cl_int nWaitEvents)
79{
80 return clEnqueueNDRangeKernel(queue, krnl, 1, nullptr, &global_size, &local_size, wait == nullptr ? 0 : nWaitEvents, wait, pEvent);
81}
82
83#endif // GPURECONSTRUCTIONOCLINCLUDESHOST_H
int32_t i
int32_t retVal
cl_command_queue command_queue[constants::GPU_MAX_STREAMS]