Skip to content

[SYCL] Changing all PI APIs to the standard format of returning pi_result #776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sycl/doc/SYCLPluginInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ These APIs match semantics of the corresponding OpenCL APIs exactly.
For example:

```
pi_program piclProgramCreateWithSource(
pi_result piclProgramCreateWithSource(
pi_context context,
pi_uint32 count,
const char ** strings,
const size_t * lengths,
pi_result * errcode);
pi_program * ret_program);
```

### PI Extension mechanism

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

TBD Add API to query PI version supported by plugin at runtime.
TBD Add API to query PI version supported by plugin at runtime.
58 changes: 30 additions & 28 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ pi_result piextGetDeviceFunctionPointer(
//
// Context
//
pi_context piContextCreate( // TODO: change interface to return error code instead
pi_result piContextCreate(
const cl_context_properties * properties, // TODO: untie from OpenCL
pi_uint32 num_devices,
const pi_device * devices,
Expand All @@ -456,7 +456,7 @@ pi_context piContextCreate( // TODO: change interface to return error code inste
size_t cb,
void * user_data),
void * user_data,
pi_result * result);
pi_context * ret_context);

pi_result piContextGetInfo(
pi_context context,
Expand Down Expand Up @@ -494,20 +494,20 @@ pi_result piQueueFinish(pi_queue command_queue);
//
// Memory
//
pi_mem piMemBufferCreate( // TODO: change interface to return error code
pi_result piMemBufferCreate(
pi_context context,
pi_mem_flags flags,
size_t size,
void * host_ptr,
pi_result * errcode_ret);
pi_mem * ret_mem);

pi_mem piMemImageCreate( // TODO: change interface to return error code
pi_result piMemImageCreate(
pi_context context,
pi_mem_flags flags,
const pi_image_format * image_format,
const pi_image_desc * image_desc,
void * host_ptr,
pi_result * errcode_ret);
pi_mem * ret_mem);

pi_result piMemGetInfo(
pi_mem mem,
Expand All @@ -529,10 +529,12 @@ pi_result piMemRetain(
pi_result piMemRelease(
pi_mem mem);

pi_mem piMemBufferPartition( // TODO: change interface to return error code
pi_mem context, pi_mem_flags flags,
pi_buffer_create_type buffer_create_type, void *buffer_create_info,
pi_result *errcode_ret);
pi_result piMemBufferPartition(
pi_mem buffer,
pi_mem_flags flags,
pi_buffer_create_type buffer_create_type,
void * buffer_create_info,
pi_mem * ret_mem);
//
// Program
//
Expand All @@ -542,21 +544,21 @@ pi_result piProgramCreate(
size_t length,
pi_program * res_program);

pi_program piclProgramCreateWithBinary( // TODO: change to return pi_result
pi_result piclProgramCreateWithSource(
pi_context context,
pi_uint32 count,
const char ** strings,
const size_t * lengths,
pi_program * ret_program);

pi_result piclProgramCreateWithBinary(
pi_context context,
pi_uint32 num_devices,
const pi_device * device_list,
const size_t * lengths,
const unsigned char ** binaries,
pi_int32 * binary_status,
pi_result * errcode_ret);

pi_program piclProgramCreateWithSource( // TODO: change to return pi_result
pi_context context,
pi_uint32 count,
const char ** strings,
const size_t * lengths,
pi_result * errcode);
pi_program * ret_program);

pi_result piProgramGetInfo(
pi_program program,
Expand All @@ -565,7 +567,7 @@ pi_result piProgramGetInfo(
void * param_value,
size_t * param_value_size_ret);

pi_program piProgramLink( // TODO: change interface to return error code
pi_result piProgramLink(
pi_context context,
pi_uint32 num_devices,
const pi_device * device_list,
Expand All @@ -575,7 +577,7 @@ pi_program piProgramLink( // TODO: change interface to return error code
void (* pfn_notify)(pi_program program,
void * user_data),
void * user_data,
pi_result * errcode_ret);
pi_program * ret_program);

pi_result piProgramCompile(
pi_program program,
Expand Down Expand Up @@ -611,10 +613,10 @@ pi_result piProgramRelease(pi_program program);
//
// Kernel
//
pi_kernel piKernelCreate( // TODO: change interface to return error code
pi_result piKernelCreate(
pi_program program,
const char * kernel_name,
pi_result * errcode_ret);
pi_kernel * ret_kernel);

pi_result piKernelSetArg(
pi_kernel kernel,
Expand Down Expand Up @@ -654,9 +656,9 @@ pi_result piKernelRelease(pi_kernel kernel);
//
// Events
//
pi_event piEventCreate( // TODO: change to return pi_result
pi_result piEventCreate(
pi_context context,
pi_result * errcode_ret);
pi_event * ret_event);

pi_result piEventGetInfo(
pi_event event,
Expand Down Expand Up @@ -860,7 +862,7 @@ pi_result piEnqueueMemImageWrite(
const pi_event * event_wait_list,
pi_event * event);

pi_result piEnqueueMemImageCopy(
pi_result piEnqueueMemImageCopy(
pi_queue command_queue,
pi_mem src_image,
pi_mem dst_image,
Expand All @@ -881,7 +883,7 @@ pi_result piEnqueueMemImageFill(
const pi_event * event_wait_list,
pi_event * event);

void * piEnqueueMemBufferMap( // TODO: change to return pi_result
pi_result piEnqueueMemBufferMap(
pi_queue command_queue,
pi_mem buffer,
pi_bool blocking_map,
Expand All @@ -891,7 +893,7 @@ void * piEnqueueMemBufferMap( // TODO: change to return pi_result
pi_uint32 num_events_in_wait_list,
const pi_event * event_wait_list,
pi_event * event,
pi_result * errcode_ret);
void* * ret_map);

pi_result piEnqueueMemUnmap(
pi_queue command_queue,
Expand Down
17 changes: 8 additions & 9 deletions sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class program_impl {
Programs.push_back(Prg->Program);
}
RT::PiResult Err = PI_SUCCESS;
PI_CALL_RESULT((Program = RT::piProgramLink(
Err = PI_CALL_RESULT(RT::piProgramLink(
detail::getSyclObjImpl(Context)->getHandleRef(),
Devices.size(), Devices.data(),
LinkOptions.c_str(), Programs.size(),
Programs.data(), nullptr, nullptr, &Err), Err));
Programs.data(), nullptr, nullptr, &Program));
PI_CHECK_THROW(Err, compile_program_error);
}
}
Expand Down Expand Up @@ -231,10 +231,10 @@ class program_impl {
info::device::is_linker_available>(Devices);
vector_class<RT::PiDevice> Devices(get_pi_devices());
RT::PiResult Err;
PI_CALL_RESULT((Program = RT::piProgramLink(
Err = PI_CALL_RESULT(RT::piProgramLink(
detail::getSyclObjImpl(Context)->getHandleRef(),
Devices.size(), Devices.data(), LinkOptions.c_str(),
1, &Program, nullptr, nullptr, &Err), Err));
1, &Program, nullptr, nullptr, &Program));
PI_CHECK_THROW(Err, compile_program_error);
this->LinkOptions = LinkOptions;
BuildOptions = LinkOptions;
Expand Down Expand Up @@ -348,12 +348,11 @@ class program_impl {

void create_cl_program_with_source(const string_class &Source) {
assert(!Program && "This program already has an encapsulated cl_program");
RT::PiResult Err;
const char *Src = Source.c_str();
size_t Size = Source.size();
PI_CALL((Program = RT::piclProgramCreateWithSource(
PI_CALL(RT::piclProgramCreateWithSource(
detail::getSyclObjImpl(Context)->getHandleRef(),
1, &Src, &Size, &Err), Err));
1, &Src, &Size, &Program));
}

void compile(const string_class &Options) {
Expand Down Expand Up @@ -416,8 +415,8 @@ class program_impl {
RT::PiKernel get_pi_kernel(const string_class &KernelName) const {
RT::PiKernel Kernel;
RT::PiResult Err;
Err = PI_CALL_RESULT((Kernel = RT::piKernelCreate(
Program, KernelName.c_str(), &Err), Err));
Err = PI_CALL_RESULT(
RT::piKernelCreate(Program, KernelName.c_str(), &Kernel));
if (Err == PI_RESULT_INVALID_KERNEL_NAME) {
throw invalid_object_error(
"This instance of program does not contain the kernel requested");
Expand Down
Loading