Skip to content

Commit 7a4ecd1

Browse files
committed
Add new simple kernel and method to adjust WALKER command parameters
Change-Id: Id0591908353ca744c44c7bab4e27db8332289a68
1 parent 6aa9b36 commit 7a4ecd1

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

runtime/command_queue/gpgpu_walker.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ class GpgpuWalkerHelper {
201201

202202
static void dispatchOnDeviceWaitlistSemaphores(LinearStream *commandStream, Device &currentDevice,
203203
cl_uint numEventsInWaitList, const cl_event *eventWaitList);
204+
205+
static void adjustWalkerData(LinearStream *commandStream,
206+
WALKER_TYPE<GfxFamily> *walkerCmd,
207+
const Kernel &kernel,
208+
const DispatchInfo &dispatchInfo);
204209
};
205210

206211
template <typename GfxFamily>

runtime/command_queue/gpgpu_walker_base.inl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,11 @@ void GpgpuWalkerHelper<GfxFamily>::setupTimestampPacket(
189189
}
190190
}
191191

192+
template <typename GfxFamily>
193+
void GpgpuWalkerHelper<GfxFamily>::adjustWalkerData(LinearStream *commandStream,
194+
WALKER_TYPE<GfxFamily> *walkerCmd,
195+
const Kernel &kernel,
196+
const DispatchInfo &dispatchInfo) {
197+
}
198+
192199
} // namespace OCLRT

runtime/command_queue/hardware_interface.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ void HardwareInterface<GfxFamily>::dispatchWalker(
226226
localIdsGenerationByRuntime, inlineDataProgrammingRequired,
227227
*kernel.getKernelInfo().patchInfo.threadPayload);
228228

229+
GpgpuWalkerHelper<GfxFamily>::adjustWalkerData(commandStream, walkerCmd, kernel, dispatchInfo);
230+
229231
dispatchWorkarounds(commandStream, commandQueue, kernel, false);
230232
currentDispatchIndex++;
231233
}

unit_tests/fixtures/simple_arg_kernel_fixture.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "gtest/gtest.h"
1010
#include "CL/cl.h"
1111
#include "runtime/device/device.h"
12+
#include "runtime/helpers/array_count.h"
1213
#include "runtime/helpers/file_io.h"
1314
#include "runtime/kernel/kernel.h"
1415
#include "runtime/program/program.h"
@@ -187,7 +188,7 @@ class SimpleKernelFixture : public ProgramFixture {
187188
public:
188189
using ProgramFixture::SetUp;
189190
SimpleKernelFixture() {
190-
kernelsCount = sizeof(kernels) / sizeof(Kernel *);
191+
kernelsCount = arrayCount(kernels);
191192
}
192193

193194
protected:
@@ -212,34 +213,33 @@ class SimpleKernelFixture : public ProgramFixture {
212213
false);
213214
ASSERT_EQ(CL_SUCCESS, retVal);
214215

215-
for (uint32_t i = 0; i < kernelsCount; i++) {
216+
for (size_t i = 0; i < kernelsCount; i++) {
216217
if ((1 << i) & kernelIds) {
217218
std::string kernelName("simple_kernel_");
218219
kernelName.append(std::to_string(i));
219-
kernels[i] = Kernel::create<MockKernel>(
220+
kernels[i].reset(Kernel::create<MockKernel>(
220221
pProgram,
221222
*pProgram->getKernelInfo(kernelName.c_str()),
222-
&retVal);
223+
&retVal));
223224
ASSERT_NE(nullptr, kernels[i]);
224225
ASSERT_EQ(CL_SUCCESS, retVal);
225226
}
226227
}
227228
}
228229

229230
virtual void TearDown() {
230-
for (uint32_t i = 0; i < kernelsCount; i++) {
231+
for (size_t i = 0; i < kernelsCount; i++) {
231232
if (kernels[i]) {
232-
delete kernels[i];
233-
kernels[i] = nullptr;
233+
kernels[i].reset(nullptr);
234234
}
235235
}
236236

237237
ProgramFixture::TearDown();
238238
}
239239

240-
uint32_t kernelsCount;
240+
size_t kernelsCount;
241241
cl_int retVal = CL_SUCCESS;
242-
Kernel *kernels[5] = {};
242+
std::unique_ptr<Kernel> kernels[6] = {};
243243
uint32_t kernelIds = 0;
244244
};
245245

unit_tests/kernel/kernel_tests.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,25 @@ TEST_F(KernelFromBinaryTests, BuiltInIsSetToFalseForRegularKernels) {
395395
EXPECT_FALSE(isBuiltIn);
396396

397397
delete pKernel;
398+
pKernel = nullptr;
399+
400+
pKernelInfo = pProgram->getKernelInfo("simple_kernel_5");
401+
402+
pKernel = Kernel::create(
403+
pProgram,
404+
*pKernelInfo,
405+
&retVal);
406+
407+
ASSERT_EQ(CL_SUCCESS, retVal);
408+
ASSERT_NE(nullptr, pKernel);
409+
410+
// get builtIn property
411+
isBuiltIn = pKernel->isBuiltIn;
412+
413+
EXPECT_FALSE(isBuiltIn);
414+
415+
delete pKernel;
416+
pKernel = nullptr;
398417
}
399418

400419
TEST(PatchInfo, Constructor) {

unit_tests/test_files/simple_kernels.cl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*
66
*/
77

8+
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
9+
810
__kernel void simple_kernel_0(
911
const uint arg0,
1012
const float arg1,
@@ -42,3 +44,7 @@ __kernel void simple_kernel_3(
4244

4345
__kernel void simple_kernel_4() {
4446
}
47+
48+
__kernel void simple_kernel_5(__global uint *dst) {
49+
atomic_inc(dst);
50+
}

0 commit comments

Comments
 (0)