Skip to content

Commit 7dc7a73

Browse files
committed
address comment
1 parent 9a2caa1 commit 7dc7a73

File tree

14 files changed

+82
-78
lines changed

14 files changed

+82
-78
lines changed

include/ur_api.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5216,7 +5216,6 @@ urKernelCreateWithNativeHandle(
52165216
/// each dimension.
52175217
/// - The application may call this function from simultaneous threads for
52185218
/// the same context.
5219-
/// - The implementation of this function should be thread-safe.
52205219
///
52215220
/// @returns
52225221
/// - ::UR_RESULT_SUCCESS
@@ -5235,14 +5234,14 @@ UR_APIEXPORT ur_result_t UR_APICALL
52355234
urKernelGetSuggestedLocalWorkSize(
52365235
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel
52375236
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
5238-
uint32_t workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
5237+
uint32_t numWorkDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
52395238
///< and work-group work-items
5240-
const size_t *pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify
5239+
const size_t *pGlobalWorkOffset, ///< [in] pointer to an array of numWorkDim unsigned values that specify
52415240
///< the offset used to calculate the global ID of a work-item
5242-
const size_t *pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify
5241+
const size_t *pGlobalWorkSize, ///< [in] pointer to an array of numWorkDim unsigned values that specify
52435242
///< the number of global work-items in workDim that will execute the
52445243
///< kernel function
5245-
size_t *pSuggestedLocalWorkSize ///< [out] pointer to an array of workDim unsigned values that specify
5244+
size_t *pSuggestedLocalWorkSize ///< [out] pointer to an array of numWorkDim unsigned values that specify
52465245
///< suggested local work size that will contain the result of the query
52475246
);
52485247

@@ -9793,7 +9792,7 @@ typedef struct ur_kernel_create_with_native_handle_params_t {
97939792
typedef struct ur_kernel_get_suggested_local_work_size_params_t {
97949793
ur_kernel_handle_t *phKernel;
97959794
ur_queue_handle_t *phQueue;
9796-
uint32_t *pworkDim;
9795+
uint32_t *pnumWorkDim;
97979796
const size_t **ppGlobalWorkOffset;
97989797
const size_t **ppGlobalWorkSize;
97999798
size_t **ppSuggestedLocalWorkSize;

include/ur_print.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11339,9 +11339,9 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1133911339
*(params->phQueue));
1134011340

1134111341
os << ", ";
11342-
os << ".workDim = ";
11342+
os << ".numWorkDim = ";
1134311343

11344-
os << *(params->pworkDim);
11344+
os << *(params->pnumWorkDim);
1134511345

1134611346
os << ", ";
1134711347
os << ".pGlobalWorkOffset = ";

scripts/core/kernel.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ ordinal: "0"
543543
details:
544544
- "Query a suggested local work size for a kernel given a global size for each dimension."
545545
- "The application may call this function from simultaneous threads for the same context."
546-
- "The implementation of this function should be thread-safe."
547546
params:
548547
- type: $x_kernel_handle_t
549548
name: hKernel
@@ -554,25 +553,25 @@ params:
554553
desc: |
555554
[in] handle of the queue object
556555
- type: uint32_t
557-
name: workDim
556+
name: numWorkDim
558557
desc: |
559558
[in] number of dimensions, from 1 to 3, to specify the global
560559
and work-group work-items
561560
- type: const size_t*
562561
name: pGlobalWorkOffset
563562
desc: |
564-
[in] pointer to an array of workDim unsigned values that specify
563+
[in] pointer to an array of numWorkDim unsigned values that specify
565564
the offset used to calculate the global ID of a work-item
566565
- type: const size_t*
567566
name: pGlobalWorkSize
568567
desc: |
569-
[in] pointer to an array of workDim unsigned values that specify
568+
[in] pointer to an array of numWorkDim unsigned values that specify
570569
the number of global work-items in workDim that will execute the
571570
kernel function
572571
- type: size_t*
573572
name: pSuggestedLocalWorkSize
574573
desc: |
575-
[out] pointer to an array of workDim unsigned values that specify
574+
[out] pointer to an array of numWorkDim unsigned values that specify
576575
suggested local work size that will contain the result of the query
577576
returns:
578577
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE

source/adapters/cuda/kernel.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
397397
ur_result_t Result = UR_RESULT_SUCCESS;
398398
size_t ThreadsPerBlock[3] = {};
399399

400-
try {
401-
// Set the active context here as guessLocalWorkSize needs an active context
402-
ScopedContext Active(Context);
400+
// Set the active context here as guessLocalWorkSize needs an active context
401+
ScopedContext Active(Context);
403402

404-
guessLocalWorkSize(Device, ThreadsPerBlock, pGlobalWorkSize, workDim,
405-
hKernel);
403+
guessLocalWorkSize(Device, ThreadsPerBlock, pGlobalWorkSize, workDim,
404+
hKernel);
406405

407-
std::copy(ThreadsPerBlock, ThreadsPerBlock + workDim,
408-
pSuggestedLocalWorkSize);
409-
} catch (ur_result_t Err) {
410-
Result = Err;
411-
}
406+
std::copy(ThreadsPerBlock, ThreadsPerBlock + workDim,
407+
pSuggestedLocalWorkSize);
412408
return Result;
413409
}

source/adapters/level_zero/kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ ur_result_t getSuggestedLocalWorkSize(ur_queue_handle_t hQueue,
9393
WG[I] = GroupSize[I];
9494
}
9595
logger::debug(
96-
"getSuggestedLocalWorkSize: using computed WG size = {{{}, {}, {}}}", WG[0],
97-
WG[1], WG[2]);
96+
"getSuggestedLocalWorkSize: using computed WG size = {{{}, {}, {}}}",
97+
WG[0], WG[1], WG[2]);
9898
}
9999

100100
return UR_RESULT_SUCCESS;

source/adapters/null/ur_nullddi.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,17 +2622,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
26222622
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel
26232623
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
26242624
uint32_t
2625-
workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
2626-
///< and work-group work-items
2625+
numWorkDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
2626+
///< and work-group work-items
26272627
const size_t *
2628-
pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify
2628+
pGlobalWorkOffset, ///< [in] pointer to an array of numWorkDim unsigned values that specify
26292629
///< the offset used to calculate the global ID of a work-item
26302630
const size_t *
2631-
pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify
2631+
pGlobalWorkSize, ///< [in] pointer to an array of numWorkDim unsigned values that specify
26322632
///< the number of global work-items in workDim that will execute the
26332633
///< kernel function
26342634
size_t *
2635-
pSuggestedLocalWorkSize ///< [out] pointer to an array of workDim unsigned values that specify
2635+
pSuggestedLocalWorkSize ///< [out] pointer to an array of numWorkDim unsigned values that specify
26362636
///< suggested local work size that will contain the result of the query
26372637
) try {
26382638
ur_result_t result = UR_RESULT_SUCCESS;
@@ -2642,7 +2642,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
26422642
d_context.urDdiTable.Kernel.pfnGetSuggestedLocalWorkSize;
26432643
if (nullptr != pfnGetSuggestedLocalWorkSize) {
26442644
result = pfnGetSuggestedLocalWorkSize(
2645-
hKernel, hQueue, workDim, pGlobalWorkOffset, pGlobalWorkSize,
2645+
hKernel, hQueue, numWorkDim, pGlobalWorkOffset, pGlobalWorkSize,
26462646
pSuggestedLocalWorkSize);
26472647
} else {
26482648
// generic implementation

source/adapters/opencl/kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
429429

430430
CL_RETURN_ON_FAILURE(clGetCommandQueueInfo(
431431
cl_adapter::cast<cl_command_queue>(hQueue), CL_QUEUE_DEVICE,
432-
sizeof(cl_device_id), &Device, NULL));
432+
sizeof(cl_device_id), &Device, nullptr));
433433

434434
CL_RETURN_ON_FAILURE(clGetDeviceInfo(
435-
Device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &Platform, NULL));
435+
Device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &Platform, nullptr));
436436

437437
auto GetKernelSuggestedLocalWorkSizeFuncPtr =
438438
(clGetKernelSuggestedLocalWorkSizeKHR_fn)
439439
clGetExtensionFunctionAddressForPlatform(
440440
Platform, "clGetKernelSuggestedLocalWorkSizeKHR");
441-
if (GetKernelSuggestedLocalWorkSizeFuncPtr == nullptr)
441+
if (!GetKernelSuggestedLocalWorkSizeFuncPtr)
442442
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
443443

444444
CL_RETURN_ON_FAILURE(GetKernelSuggestedLocalWorkSizeFuncPtr(

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,17 +2794,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
27942794
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel
27952795
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
27962796
uint32_t
2797-
workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
2798-
///< and work-group work-items
2797+
numWorkDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
2798+
///< and work-group work-items
27992799
const size_t *
2800-
pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify
2800+
pGlobalWorkOffset, ///< [in] pointer to an array of numWorkDim unsigned values that specify
28012801
///< the offset used to calculate the global ID of a work-item
28022802
const size_t *
2803-
pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify
2803+
pGlobalWorkSize, ///< [in] pointer to an array of numWorkDim unsigned values that specify
28042804
///< the number of global work-items in workDim that will execute the
28052805
///< kernel function
28062806
size_t *
2807-
pSuggestedLocalWorkSize ///< [out] pointer to an array of workDim unsigned values that specify
2807+
pSuggestedLocalWorkSize ///< [out] pointer to an array of numWorkDim unsigned values that specify
28082808
///< suggested local work size that will contain the result of the query
28092809
) {
28102810
auto pfnGetSuggestedLocalWorkSize =
@@ -2815,14 +2815,14 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
28152815
}
28162816

28172817
ur_kernel_get_suggested_local_work_size_params_t params = {
2818-
&hKernel, &hQueue, &workDim,
2818+
&hKernel, &hQueue, &numWorkDim,
28192819
&pGlobalWorkOffset, &pGlobalWorkSize, &pSuggestedLocalWorkSize};
28202820
uint64_t instance =
28212821
context.notify_begin(UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE,
28222822
"urKernelGetSuggestedLocalWorkSize", &params);
28232823

28242824
ur_result_t result = pfnGetSuggestedLocalWorkSize(
2825-
hKernel, hQueue, workDim, pGlobalWorkOffset, pGlobalWorkSize,
2825+
hKernel, hQueue, numWorkDim, pGlobalWorkOffset, pGlobalWorkSize,
28262826
pSuggestedLocalWorkSize);
28272827

28282828
context.notify_end(UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE,

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,17 +3863,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
38633863
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel
38643864
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
38653865
uint32_t
3866-
workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
3867-
///< and work-group work-items
3866+
numWorkDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
3867+
///< and work-group work-items
38683868
const size_t *
3869-
pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify
3869+
pGlobalWorkOffset, ///< [in] pointer to an array of numWorkDim unsigned values that specify
38703870
///< the offset used to calculate the global ID of a work-item
38713871
const size_t *
3872-
pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify
3872+
pGlobalWorkSize, ///< [in] pointer to an array of numWorkDim unsigned values that specify
38733873
///< the number of global work-items in workDim that will execute the
38743874
///< kernel function
38753875
size_t *
3876-
pSuggestedLocalWorkSize ///< [out] pointer to an array of workDim unsigned values that specify
3876+
pSuggestedLocalWorkSize ///< [out] pointer to an array of numWorkDim unsigned values that specify
38773877
///< suggested local work size that will contain the result of the query
38783878
) {
38793879
auto pfnGetSuggestedLocalWorkSize =
@@ -3916,7 +3916,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
39163916
}
39173917

39183918
ur_result_t result = pfnGetSuggestedLocalWorkSize(
3919-
hKernel, hQueue, workDim, pGlobalWorkOffset, pGlobalWorkSize,
3919+
hKernel, hQueue, numWorkDim, pGlobalWorkOffset, pGlobalWorkSize,
39203920
pSuggestedLocalWorkSize);
39213921

39223922
return result;

source/loader/ur_ldrddi.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,17 +3455,17 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
34553455
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel
34563456
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
34573457
uint32_t
3458-
workDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
3459-
///< and work-group work-items
3458+
numWorkDim, ///< [in] number of dimensions, from 1 to 3, to specify the global
3459+
///< and work-group work-items
34603460
const size_t *
3461-
pGlobalWorkOffset, ///< [in] pointer to an array of workDim unsigned values that specify
3461+
pGlobalWorkOffset, ///< [in] pointer to an array of numWorkDim unsigned values that specify
34623462
///< the offset used to calculate the global ID of a work-item
34633463
const size_t *
3464-
pGlobalWorkSize, ///< [in] pointer to an array of workDim unsigned values that specify
3464+
pGlobalWorkSize, ///< [in] pointer to an array of numWorkDim unsigned values that specify
34653465
///< the number of global work-items in workDim that will execute the
34663466
///< kernel function
34673467
size_t *
3468-
pSuggestedLocalWorkSize ///< [out] pointer to an array of workDim unsigned values that specify
3468+
pSuggestedLocalWorkSize ///< [out] pointer to an array of numWorkDim unsigned values that specify
34693469
///< suggested local work size that will contain the result of the query
34703470
) {
34713471
ur_result_t result = UR_RESULT_SUCCESS;
@@ -3485,7 +3485,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
34853485
hQueue = reinterpret_cast<ur_queue_object_t *>(hQueue)->handle;
34863486

34873487
// forward to device-platform
3488-
result = pfnGetSuggestedLocalWorkSize(hKernel, hQueue, workDim,
3488+
result = pfnGetSuggestedLocalWorkSize(hKernel, hQueue, numWorkDim,
34893489
pGlobalWorkOffset, pGlobalWorkSize,
34903490
pSuggestedLocalWorkSize);
34913491

0 commit comments

Comments
 (0)