Skip to content

Commit 75d497a

Browse files
separate BuiltinDispatchInfoBuilder from built_ins.h
We don't need BuiltinDispatchInfoBuilder in every place where built ins are used. specifically in .cpp files generated from kernel binary. Change-Id: Ie739951cdc93873993f78ad14cee656122af51fd Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
1 parent 5bae27a commit 75d497a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+212
-121
lines changed

runtime/api/cl_types.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,8 +22,6 @@
2222

2323
#pragma once
2424
#include "config.h"
25-
26-
#include "CL/cl.h"
2725
#include "runtime/api/dispatch.h"
2826
#include <cstdint>
2927

runtime/built_ins/built_ins.h

Lines changed: 13 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -21,9 +21,9 @@
2121
*/
2222

2323
#pragma once
24+
#include "config.h"
25+
#include "CL/cl.h"
2426
#include "runtime/built_ins/sip.h"
25-
#include "runtime/scheduler/scheduler_kernel.h"
26-
#include "runtime/program/program.h"
2727
#include "runtime/utilities/vec.h"
2828

2929
#include <array>
@@ -33,10 +33,20 @@
3333
#include <mutex>
3434
#include <string>
3535
#include <tuple>
36+
#include <unordered_map>
37+
#include <vector>
3638

3739
namespace OCLRT {
3840
typedef std::vector<char> BuiltinResourceT;
3941

42+
class Context;
43+
class Device;
44+
class Kernel;
45+
struct KernelInfo;
46+
struct MultiDispatchInfo;
47+
class Program;
48+
class SchedulerKernel;
49+
4050
extern const char *mediaKernelsBuildOptions;
4151

4252
enum class EBuiltInOps : uint32_t {
@@ -160,11 +170,6 @@ class BuiltinsLib {
160170
std::mutex mutex;
161171
};
162172

163-
class Context;
164-
class Device;
165-
class Kernel;
166-
class Program;
167-
168173
struct BuiltInKernel {
169174
const char *pSource = nullptr;
170175
Program *pProgram = nullptr;
@@ -231,72 +236,6 @@ class BuiltIns {
231236
bool enableCacheing = true;
232237
};
233238

234-
class MemObj;
235-
236-
class BuiltinDispatchInfoBuilder {
237-
public:
238-
struct BuiltinOpParams {
239-
void *srcPtr = nullptr;
240-
void *dstPtr = nullptr;
241-
MemObj *srcMemObj = nullptr;
242-
MemObj *dstMemObj = nullptr;
243-
GraphicsAllocation *srcSvmAlloc = nullptr;
244-
GraphicsAllocation *dstSvmAlloc = nullptr;
245-
Vec3<size_t> srcOffset = {0, 0, 0};
246-
Vec3<size_t> dstOffset = {0, 0, 0};
247-
Vec3<size_t> size = {0, 0, 0};
248-
size_t srcRowPitch = 0;
249-
size_t dstRowPitch = 0;
250-
size_t srcSlicePitch = 0;
251-
size_t dstSlicePitch = 0;
252-
uint32_t srcMipLevel = 0;
253-
uint32_t dstMipLevel = 0;
254-
};
255-
256-
BuiltinDispatchInfoBuilder(BuiltIns &kernelLib) : kernelsLib(kernelLib) {}
257-
258-
template <typename... KernelsDescArgsT>
259-
void populate(Context &context, Device &device, EBuiltInOps operation, const char *options, KernelsDescArgsT &&... desc);
260-
261-
virtual bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo, const BuiltinOpParams &operationParams) const {
262-
return false;
263-
}
264-
265-
virtual bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo, Kernel *kernel,
266-
const uint32_t dim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset) const {
267-
return false;
268-
}
269-
270-
virtual cl_int validateDispatch(Kernel *kernel, uint32_t inworkDim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset) const {
271-
return CL_SUCCESS;
272-
}
273-
274-
// returns true if argument should be updated in kernel exposed to user code
275-
virtual bool setExplicitArg(uint32_t argIndex, size_t argSize, const void *argVal, cl_int &err) const {
276-
return true;
277-
}
278-
279-
void takeOwnership(Context *context);
280-
void releaseOwnership();
281-
282-
protected:
283-
template <typename KernelNameT, typename... KernelsDescArgsT>
284-
void grabKernels(KernelNameT &&kernelName, Kernel *&kernelDst, KernelsDescArgsT &&... kernelsDesc) {
285-
const KernelInfo *ki = prog->getKernelInfo(kernelName);
286-
cl_int err = 0;
287-
kernelDst = Kernel::create(prog.get(), *ki, &err);
288-
kernelDst->isBuiltIn = true;
289-
usedKernels.push_back(std::unique_ptr<Kernel>(kernelDst));
290-
grabKernels(std::forward<KernelsDescArgsT>(kernelsDesc)...);
291-
}
292-
293-
cl_int grabKernels() { return CL_SUCCESS; }
294-
295-
std::unique_ptr<Program> prog;
296-
std::vector<std::unique_ptr<Kernel>> usedKernels;
297-
BuiltIns &kernelsLib;
298-
};
299-
300239
template <typename HWFamily, EBuiltInOps OpCode>
301240
class BuiltInOp;
302241

runtime/built_ins/built_ins_storage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,6 +22,7 @@
2222

2323
#include <cstdint>
2424
#include "runtime/built_ins/built_ins.h"
25+
#include "runtime/built_ins/builtins_dispatch_builder.h"
2526
#include "os_inc.h"
2627

2728
namespace OCLRT {
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
#include "config.h"
25+
#include "CL/cl.h"
26+
#include "runtime/built_ins/built_ins.h"
27+
#include "runtime/kernel/kernel.h"
28+
#include "runtime/utilities/vec.h"
29+
30+
#include <array>
31+
#include <cstdint>
32+
#include <fstream>
33+
#include <memory>
34+
#include <mutex>
35+
#include <string>
36+
#include <tuple>
37+
#include <vector>
38+
39+
namespace OCLRT {
40+
typedef std::vector<char> BuiltinResourceT;
41+
42+
class Context;
43+
class Device;
44+
class MemObj;
45+
struct MultiDispatchInfo;
46+
class Program;
47+
48+
class BuiltinDispatchInfoBuilder {
49+
public:
50+
struct BuiltinOpParams {
51+
void *srcPtr = nullptr;
52+
void *dstPtr = nullptr;
53+
MemObj *srcMemObj = nullptr;
54+
MemObj *dstMemObj = nullptr;
55+
GraphicsAllocation *srcSvmAlloc = nullptr;
56+
GraphicsAllocation *dstSvmAlloc = nullptr;
57+
Vec3<size_t> srcOffset = {0, 0, 0};
58+
Vec3<size_t> dstOffset = {0, 0, 0};
59+
Vec3<size_t> size = {0, 0, 0};
60+
size_t srcRowPitch = 0;
61+
size_t dstRowPitch = 0;
62+
size_t srcSlicePitch = 0;
63+
size_t dstSlicePitch = 0;
64+
uint32_t srcMipLevel = 0;
65+
uint32_t dstMipLevel = 0;
66+
};
67+
68+
BuiltinDispatchInfoBuilder(BuiltIns &kernelLib) : kernelsLib(kernelLib) {}
69+
70+
template <typename... KernelsDescArgsT>
71+
void populate(Context &context, Device &device, EBuiltInOps operation, const char *options, KernelsDescArgsT &&... desc);
72+
73+
virtual bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo, const BuiltinOpParams &operationParams) const {
74+
return false;
75+
}
76+
77+
virtual bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo, Kernel *kernel,
78+
const uint32_t dim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset) const {
79+
return false;
80+
}
81+
82+
virtual cl_int validateDispatch(Kernel *kernel, uint32_t inworkDim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset) const {
83+
return CL_SUCCESS;
84+
}
85+
86+
// returns true if argument should be updated in kernel exposed to user code
87+
virtual bool setExplicitArg(uint32_t argIndex, size_t argSize, const void *argVal, cl_int &err) const {
88+
return true;
89+
}
90+
91+
void takeOwnership(Context *context);
92+
void releaseOwnership();
93+
94+
protected:
95+
template <typename KernelNameT, typename... KernelsDescArgsT>
96+
void grabKernels(KernelNameT &&kernelName, Kernel *&kernelDst, KernelsDescArgsT &&... kernelsDesc) {
97+
const KernelInfo *ki = prog->getKernelInfo(kernelName);
98+
cl_int err = 0;
99+
kernelDst = Kernel::create(prog.get(), *ki, &err);
100+
kernelDst->isBuiltIn = true;
101+
usedKernels.push_back(std::unique_ptr<Kernel>(kernelDst));
102+
grabKernels(std::forward<KernelsDescArgsT>(kernelsDesc)...);
103+
}
104+
105+
cl_int grabKernels() { return CL_SUCCESS; }
106+
107+
std::unique_ptr<Program> prog;
108+
std::vector<std::unique_ptr<Kernel>> usedKernels;
109+
BuiltIns &kernelsLib;
110+
};
111+
112+
} // namespace OCLRT

runtime/built_ins/vme_dispatch_builder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,7 @@
2525
#include "runtime/accelerators/intel_accelerator.h"
2626
#include "runtime/accelerators/intel_motion_estimation.h"
2727
#include "runtime/built_ins/built_ins.h"
28+
#include "runtime/built_ins/builtins_dispatch_builder.h"
2829
#include "runtime/helpers/dispatch_info_builder.h"
2930
#include "runtime/mem_obj/buffer.h"
3031
#include "runtime/mem_obj/image.h"

runtime/builtin_kernels_simulation/gen8/scheduler_simulation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -20,13 +20,14 @@
2020
* OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23+
#include "config.h"
2324
#include "CL/cl.h"
2425
#include "runtime/builtin_kernels_simulation/opencl_c.h"
2526
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"
2627
#include "runtime/builtin_kernels_simulation/scheduler_simulation.inl"
27-
#include "runtime/memory_manager/graphics_allocation.h"
28-
#include "runtime/gen8/hw_cmds.h"
2928
#include "runtime/execution_model/device_enqueue.h"
29+
#include "runtime/gen8/hw_cmds.h"
30+
#include "runtime/memory_manager/graphics_allocation.h"
3031

3132
using namespace OCLRT;
3233
using namespace BuiltinKernelsSimulation;

runtime/builtin_kernels_simulation/gen9/scheduler_simulation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -20,13 +20,14 @@
2020
* OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23+
#include "config.h"
2324
#include "CL/cl.h"
2425
#include "runtime/builtin_kernels_simulation/opencl_c.h"
2526
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"
2627
#include "runtime/builtin_kernels_simulation/scheduler_simulation.inl"
27-
#include "runtime/memory_manager/graphics_allocation.h"
28-
#include "runtime/gen9/hw_cmds.h"
2928
#include "runtime/execution_model/device_enqueue.h"
29+
#include "runtime/gen9/hw_cmds.h"
30+
#include "runtime/memory_manager/graphics_allocation.h"
3031

3132
using namespace OCLRT;
3233
using namespace BuiltinKernelsSimulation;

runtime/builtin_kernels_simulation/opencl_c.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -21,9 +21,10 @@
2121
*/
2222

2323
#include <cstdint>
24-
#include "runtime/helpers/string.h"
24+
#include "config.h"
2525
#include "CL/cl.h"
2626
#include "opencl_c.h"
27+
#include "runtime/helpers/string.h"
2728

2829
namespace BuiltinKernelsSimulation {
2930

runtime/command_queue/enqueue_common.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,29 @@
2121
*/
2222

2323
#pragma once
24-
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"
2524
#include "hw_cmds.h"
25+
#include "runtime/built_ins/built_ins.h"
26+
#include "runtime/built_ins/builtins_dispatch_builder.h"
27+
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"
2628
#include "runtime/command_queue/command_queue_hw.h"
2729
#include "runtime/command_queue/gpgpu_walker.h"
2830
#include "runtime/command_stream/command_stream_receiver.h"
2931
#include "runtime/event/event_builder.h"
3032
#include "runtime/gtpin/gtpin_notify.h"
31-
#include "runtime/helpers/kernel_commands.h"
33+
#include "runtime/helpers/array_count.h"
3234
#include "runtime/helpers/dispatch_info_builder.h"
35+
#include "runtime/helpers/kernel_commands.h"
36+
#include "runtime/helpers/options.h"
37+
#include "runtime/helpers/task_information.h"
3338
#include "runtime/mem_obj/buffer.h"
3439
#include "runtime/mem_obj/image.h"
3540
#include "runtime/memory_manager/memory_manager.h"
3641
#include "runtime/memory_manager/surface.h"
37-
#include "runtime/built_ins/built_ins.h"
38-
#include "runtime/helpers/array_count.h"
39-
#include "runtime/helpers/options.h"
40-
#include "runtime/helpers/task_information.h"
4142
#include "runtime/program/printf_handler.h"
4243
#include "runtime/program/block_kernel_manager.h"
4344
#include "runtime/utilities/range.h"
44-
#include <new>
4545
#include <memory>
46+
#include <new>
4647

4748
namespace OCLRT {
4849

runtime/command_queue/enqueue_kernel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#pragma once
2424
#include "hw_cmds.h"
25+
#include "runtime/built_ins/builtins_dispatch_builder.h"
2526
#include "runtime/command_queue/command_queue_hw.h"
2627
#include "runtime/command_stream/command_stream_receiver.h"
2728
#include "runtime/command_queue/gpgpu_walker.h"

0 commit comments

Comments
 (0)