source: CLRX/CLRadeonExtender/trunk/samples/CLUtils.h @ 3450

Last change on this file since 3450 was 3450, checked in by matszpk, 2 years ago

CLRadeonExtender: Add new library: CLRXCLHelper that facilitate creating binary/program for OpenCL. Use CLRXCLHelper in samples.

File size: 2.0 KB
Line 
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 */
19
20#ifndef __CLRXSAMPLES_CLUTILS_H__
21#define __CLRXSAMPLES_CLUTILS_H__
22
23#include <cstdio>
24#include <string>
25#include <vector>
26#include <exception>
27#include <CLRX/clhelper/CLHelper.h>
28#include <CL/cl.h>
29
30class CLFacade
31{
32protected:
33    cl_device_id device;
34    cl_context context;
35    cl_command_queue queue;
36    cl_program program;
37    // mem object to retain and release while destructing
38    std::vector<cl_mem> memObjects;
39    std::vector<cl_kernel> kernels;
40   
41    cl_uint computeUnits;
42    size_t maxWorkGroupSize;
43   
44    void getKernelInfo(cl_kernel kernel, size_t& workGroupSize,
45               size_t& workGroupSizeMultiple);
46   
47    void callNDRangeKernel(cl_kernel kernel, cl_uint workDim, const size_t* offset,
48               const size_t* workSize, const size_t* localSize);
49public:
50    // return true if application should immediately return
51    static bool parseArgs(const char* progName, const char* usagePart, int argc,
52                  const char** argv, cl_uint& deviceIndex, cxuint& useCL);
53   
54    explicit CLFacade(cl_uint deviceIndex, const char* sourceCode,
55                      const char* kernelNames = nullptr, cxuint useCL = 0);
56    ~CLFacade();
57};
58
59#endif
Note: See TracBrowser for help on using the repository browser.