Skip to content

Commit 0868f4f

Browse files
committed
[SYCL] Changing all PI APIs to the standard format of returning pi_result.
Signed-off-by: Garima Gupta <garima.gupta@intel.com>
1 parent 884459b commit 0868f4f

File tree

12 files changed

+217
-102
lines changed

12 files changed

+217
-102
lines changed

sycl/doc/SYCLPluginInterface.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ These APIs match semantics of the corresponding OpenCL APIs exactly.
120120
For example:
121121

122122
```
123-
pi_program piclProgramCreateWithSource(
123+
pi_result piclProgramCreateWithSource(
124124
pi_context context,
125125
pi_uint32 count,
126126
const char ** strings,
127127
const size_t * lengths,
128-
pi_result * errcode);
128+
pi_program * ret_program);
129129
```
130130

131131
### PI Extension mechanism
132132

133133
TBD This section describes a mechanism for SYCL or other runtimes to detect
134134
availability of and obtain interfaces beyond those defined by the PI dispatch.
135135

136-
TBD Add API to query PI version supported by plugin at runtime.
136+
TBD Add API to query PI version supported by plugin at runtime.

sycl/include/CL/sycl/detail/pi.h

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ pi_result piextGetDeviceFunctionPointer(
446446
//
447447
// Context
448448
//
449-
pi_context piContextCreate( // TODO: change interface to return error code instead
449+
pi_result piContextCreate(
450450
const cl_context_properties * properties, // TODO: untie from OpenCL
451451
pi_uint32 num_devices,
452452
const pi_device * devices,
@@ -456,7 +456,7 @@ pi_context piContextCreate( // TODO: change interface to return error code inste
456456
size_t cb,
457457
void * user_data),
458458
void * user_data,
459-
pi_result * result);
459+
pi_context * retcontext);
460460

461461
pi_result piContextGetInfo(
462462
pi_context context,
@@ -494,20 +494,20 @@ pi_result piQueueFinish(pi_queue command_queue);
494494
//
495495
// Memory
496496
//
497-
pi_mem piMemBufferCreate( // TODO: change interface to return error code
497+
pi_result piMemBufferCreate(
498498
pi_context context,
499499
pi_mem_flags flags,
500500
size_t size,
501501
void * host_ptr,
502-
pi_result * errcode_ret);
502+
pi_mem * ret_mem);
503503

504-
pi_mem piMemImageCreate( // TODO: change interface to return error code
504+
pi_result piMemImageCreate(
505505
pi_context context,
506506
pi_mem_flags flags,
507507
const pi_image_format * image_format,
508508
const pi_image_desc * image_desc,
509509
void * host_ptr,
510-
pi_result * errcode_ret);
510+
pi_mem * ret_mem);
511511

512512
pi_result piMemGetInfo(
513513
pi_mem mem,
@@ -529,10 +529,12 @@ pi_result piMemRetain(
529529
pi_result piMemRelease(
530530
pi_mem mem);
531531

532-
pi_mem piMemBufferPartition( // TODO: change interface to return error code
533-
pi_mem context, pi_mem_flags flags,
534-
pi_buffer_create_type buffer_create_type, void *buffer_create_info,
535-
pi_result *errcode_ret);
532+
pi_result piMemBufferPartition(
533+
pi_mem buffer,
534+
pi_mem_flags flags,
535+
pi_buffer_create_type buffer_create_type,
536+
void * buffer_create_info,
537+
pi_mem * ret_mem);
536538
//
537539
// Program
538540
//
@@ -542,21 +544,21 @@ pi_result piProgramCreate(
542544
size_t length,
543545
pi_program * res_program);
544546

545-
pi_program piclProgramCreateWithBinary( // TODO: change to return pi_result
547+
pi_result piclProgramCreateWithSource(
548+
pi_context context,
549+
pi_uint32 count,
550+
const char ** strings,
551+
const size_t * lengths,
552+
pi_program * ret_program);
553+
554+
pi_result piclProgramCreateWithBinary(
546555
pi_context context,
547556
pi_uint32 num_devices,
548557
const pi_device * device_list,
549558
const size_t * lengths,
550559
const unsigned char ** binaries,
551560
pi_int32 * binary_status,
552-
pi_result * errcode_ret);
553-
554-
pi_program piclProgramCreateWithSource( // TODO: change to return pi_result
555-
pi_context context,
556-
pi_uint32 count,
557-
const char ** strings,
558-
const size_t * lengths,
559-
pi_result * errcode);
561+
pi_program * ret_program);
560562

561563
pi_result piProgramGetInfo(
562564
pi_program program,
@@ -565,7 +567,7 @@ pi_result piProgramGetInfo(
565567
void * param_value,
566568
size_t * param_value_size_ret);
567569

568-
pi_program piProgramLink( // TODO: change interface to return error code
570+
pi_result piProgramLink(
569571
pi_context context,
570572
pi_uint32 num_devices,
571573
const pi_device * device_list,
@@ -575,7 +577,7 @@ pi_program piProgramLink( // TODO: change interface to return error code
575577
void (* pfn_notify)(pi_program program,
576578
void * user_data),
577579
void * user_data,
578-
pi_result * errcode_ret);
580+
pi_program * ret_program);
579581

580582
pi_result piProgramCompile(
581583
pi_program program,
@@ -611,10 +613,10 @@ pi_result piProgramRelease(pi_program program);
611613
//
612614
// Kernel
613615
//
614-
pi_kernel piKernelCreate( // TODO: change interface to return error code
616+
pi_result piKernelCreate(
615617
pi_program program,
616618
const char * kernel_name,
617-
pi_result * errcode_ret);
619+
pi_kernel * ret_kernel);
618620

619621
pi_result piKernelSetArg(
620622
pi_kernel kernel,
@@ -654,9 +656,9 @@ pi_result piKernelRelease(pi_kernel kernel);
654656
//
655657
// Events
656658
//
657-
pi_event piEventCreate( // TODO: change to return pi_result
659+
pi_result piEventCreate(
658660
pi_context context,
659-
pi_result * errcode_ret);
661+
pi_event * ret_event);
660662

661663
pi_result piEventGetInfo(
662664
pi_event event,
@@ -860,7 +862,7 @@ pi_result piEnqueueMemImageWrite(
860862
const pi_event * event_wait_list,
861863
pi_event * event);
862864

863-
pi_result piEnqueueMemImageCopy(
865+
pi_result piEnqueueMemImageCopy(
864866
pi_queue command_queue,
865867
pi_mem src_image,
866868
pi_mem dst_image,
@@ -881,7 +883,7 @@ pi_result piEnqueueMemImageFill(
881883
const pi_event * event_wait_list,
882884
pi_event * event);
883885

884-
void * piEnqueueMemBufferMap( // TODO: change to return pi_result
886+
pi_result piEnqueueMemBufferMap(
885887
pi_queue command_queue,
886888
pi_mem buffer,
887889
pi_bool blocking_map,
@@ -891,7 +893,7 @@ void * piEnqueueMemBufferMap( // TODO: change to return pi_result
891893
pi_uint32 num_events_in_wait_list,
892894
const pi_event * event_wait_list,
893895
pi_event * event,
894-
pi_result * errcode_ret);
896+
void* * ret_map);
895897

896898
pi_result piEnqueueMemUnmap(
897899
pi_queue command_queue,

sycl/include/CL/sycl/detail/program_impl.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ class program_impl {
8484
Programs.push_back(Prg->Program);
8585
}
8686
RT::PiResult Err = PI_SUCCESS;
87-
PI_CALL_RESULT((Program = RT::piProgramLink(
87+
Err = PI_CALL_RESULT(RT::piProgramLink(
8888
detail::getSyclObjImpl(Context)->getHandleRef(),
8989
Devices.size(), Devices.data(),
9090
LinkOptions.c_str(), Programs.size(),
91-
Programs.data(), nullptr, nullptr, &Err), Err));
91+
Programs.data(), nullptr, nullptr, &Program));
9292
PI_CHECK_THROW(Err, compile_program_error);
9393
}
9494
}
@@ -230,10 +230,10 @@ class program_impl {
230230
info::device::is_linker_available>(Devices);
231231
vector_class<RT::PiDevice> Devices(get_pi_devices());
232232
RT::PiResult Err;
233-
PI_CALL_RESULT((Program = RT::piProgramLink(
233+
Err = PI_CALL_RESULT(RT::piProgramLink(
234234
detail::getSyclObjImpl(Context)->getHandleRef(),
235235
Devices.size(), Devices.data(), LinkOptions.c_str(),
236-
1, &Program, nullptr, nullptr, &Err), Err));
236+
1, &Program, nullptr, nullptr, &Program));
237237
PI_CHECK_THROW(Err, compile_program_error);
238238
this->LinkOptions = LinkOptions;
239239
BuildOptions = LinkOptions;
@@ -347,12 +347,11 @@ class program_impl {
347347

348348
void create_cl_program_with_source(const string_class &Source) {
349349
assert(!Program && "This program already has an encapsulated cl_program");
350-
RT::PiResult Err;
351350
const char *Src = Source.c_str();
352351
size_t Size = Source.size();
353-
PI_CALL((Program = RT::piclProgramCreateWithSource(
352+
PI_CALL(RT::piclProgramCreateWithSource(
354353
detail::getSyclObjImpl(Context)->getHandleRef(),
355-
1, &Src, &Size, &Err), Err));
354+
1, &Src, &Size, &Program));
356355
}
357356

358357
void compile(const string_class &Options) {
@@ -415,8 +414,8 @@ class program_impl {
415414
RT::PiKernel get_pi_kernel(const string_class &KernelName) const {
416415
RT::PiKernel Kernel;
417416
RT::PiResult Err;
418-
Err = PI_CALL_RESULT((Kernel = RT::piKernelCreate(
419-
Program, KernelName.c_str(), &Err), Err));
417+
Err = PI_CALL_RESULT(
418+
RT::piKernelCreate(Program, KernelName.c_str(), &Kernel));
420419
if (Err == PI_RESULT_INVALID_KERNEL_NAME) {
421420
throw invalid_object_error(
422421
"This instance of program does not contain the kernel requested");

0 commit comments

Comments
 (0)