CLRX  1
An unofficial OpenCL extensions designed for Radeon GPUs
CLHelper.h
Go to the documentation of this file.
1 /*
2  * CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
3  * Copyright (C) 2014-2017 Mateusz Szpakowski
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
23 #ifndef __CLRX_CLHELPER_H__
24 #define __CLRX_CLHELPER_H__
25 
26 #include <CLRX/Config.h>
27 #include <CL/cl.h>
28 #include <CLRX/amdasm/Commons.h>
29 #include <CLRX/utils/Containers.h>
30 #include <CLRX/utils/CString.h>
31 #include <CLRX/utils/Utilities.h>
32 #include <CLRX/utils/GPUId.h>
33 
34 
35 namespace CLRX
36 {
37 
39 class CLError: public Exception
40 {
41 private:
42  cl_int error;
43 public:
45  CLError();
46 
48  explicit CLError(const char* _description);
49 
51  CLError(cl_int _error, const char* _description);
52 
54  virtual ~CLError() noexcept;
55 
57  const char* what() const noexcept;
58 
60  int code() const
61  { return error; }
62 };
63 
65 extern cl_platform_id chooseCLPlatformForCLRX();
66 
67 enum : Flags
68 {
71 };
72 
74 struct CLAsmSetup
75 {
80  bool is64Bit;
82 };
83 
85 extern CLAsmSetup assemblerSetupForCLDevice(cl_device_id clDevice, Flags flags = 0);
86 
88 extern Array<cxbyte> createBinaryForOpenCL(const CLAsmSetup& asmSetup,
89  const char* sourceCode, size_t sourceCodeLen = 0);
90 
92 extern cl_program createProgramForCLDevice(cl_context clContext, cl_device_id clDevice,
93  const CLAsmSetup& asmSetup, const Array<cxbyte>& binary,
94  CString* buildLog = nullptr);
95 
97 extern cl_program createProgramForCLDevice(cl_context clContext, cl_device_id clDevice,
98  const CLAsmSetup& asmSetup, const char* sourceCode, size_t sourceCodeLen = 0,
99  CString* buildLog = nullptr);
100 
101 };
102 
103 #endif
cl_program createProgramForCLDevice(cl_context clContext, cl_device_id clDevice, const CLAsmSetup &asmSetup, const Array< cxbyte > &binary, CString *buildLog=nullptr)
create (build program) binary for OpenCL device
common definitions for assembler and disassembler
int code() const
get OpenCL error code
Definition: CLHelper.h:60
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
BinaryFormat
binary for Disassembler
Definition: Commons.h:33
structure that holds assembler setup for OpenCL programs
Definition: CLHelper.h:74
an array class
Definition: Containers.h:38
Configuration header.
Array< cxbyte > createBinaryForOpenCL(const CLAsmSetup &asmSetup, const char *sourceCode, size_t sourceCodeLen=0)
create program binary for OpenCL
bool is64Bit
if binary is 64-bit
Definition: CLHelper.h:80
force using AMD OpenCL 2.0 binary format
Definition: CLHelper.h:69
virtual ~CLError() noexcept
destructor
BinaryFormat binaryFormat
binary format
Definition: CLHelper.h:77
main namespace
Definition: AsmDefs.h:38
error class based on std::exception
Definition: CLHelper.h:39
unsigned int cxuint
unsigned int
Definition: Config.h:223
CLAsmSetup assemblerSetupForCLDevice(cl_device_id clDevice, Flags flags=0)
get assembler setup(compile assembler code) binary for OpenCL device
const char * what() const noexcept
get what
GPUDeviceType
type of GPU device
Definition: GPUId.h:51
CString options
OpenCL base options.
Definition: CLHelper.h:81
utilities for other libraries and programs
exception class
Definition: Utilities.h:58
force using AMD OpenCL 1.2 binary format
Definition: CLHelper.h:70
GPU identification utilities.
cxuint driverVersion
driver version
Definition: CLHelper.h:78
cl_platform_id chooseCLPlatformForCLRX()
choose suitable OpenCL platform for CLRX assembler programs
GPUDeviceType deviceType
device typ
Definition: CLHelper.h:76
cxuint llvmVersion
LLVM version.
Definition: CLHelper.h:79
simple C-string container
Definition: CString.h:38
containers and other utils for other libraries and programs
C-style string class.