Skip to content

Improve test coverage for dpctl_sycl_queue_interface #492

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 3 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion dpctl-capi/source/dpctl_sycl_program_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ createLevelZeroInterOpProgram(const context &SyclCtx,

auto stZeModuleCreateF = getZeModuleCreateFn();

if (!stZeModuleCreateF)
if (!stZeModuleCreateF) {
std::cerr << "ZeModuleCreateFn is invalid.\n";
return nullptr;
}

auto ret =
stZeModuleCreateF(ZeCtx, ZeDevice, &ZeModuleDesc, &ZeModule, nullptr);
if (ret != ZE_RESULT_SUCCESS) {
// TODO: handle error
std::cerr << "ZeModule creation failed.\n";
return nullptr;
}

Expand Down Expand Up @@ -199,6 +202,8 @@ DPCTLProgram_CreateFromSpirv(__dpctl_keep const DPCTLSyclContextRef CtxRef,
context *SyclCtx = nullptr;
if (!CtxRef) {
// \todo handle error
std::cerr << "Cannot create program from SPIR-V as the supplied SYCL "
"context is NULL.\n";
return Pref;
}
SyclCtx = unwrap(CtxRef);
Expand Down
27 changes: 18 additions & 9 deletions dpctl-capi/source/dpctl_sycl_queue_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,18 @@ bool DPCTLQueue_AreEq(__dpctl_keep const DPCTLSyclQueueRef QRef1,
DPCTLSyclBackendType DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef)
{
auto Q = unwrap(QRef);
try {
auto C = Q->get_context();
return DPCTLContext_GetBackend(wrap(&C));
} catch (runtime_error &re) {
std::cerr << re.what() << '\n';
// store error message
return DPCTL_UNKNOWN_BACKEND;
if (Q) {
try {
auto C = Q->get_context();
return DPCTLContext_GetBackend(wrap(&C));
} catch (runtime_error &re) {
std::cerr << re.what() << '\n';
// store error message
return DPCTL_UNKNOWN_BACKEND;
}
}
else
return DPCTL_UNKNOWN_BACKEND;
}

__dpctl_give DPCTLSyclDeviceRef
Expand All @@ -327,8 +331,13 @@ __dpctl_give DPCTLSyclContextRef
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef)
{
auto Q = unwrap(QRef);
auto Context = new context(Q->get_context());
return wrap(Context);
DPCTLSyclContextRef CRef = nullptr;
if (Q)
CRef = wrap(new context(Q->get_context()));
else {
std::cerr << "Could not get the context for this queue.\n";
}
return CRef;
}

__dpctl_give DPCTLSyclEventRef
Expand Down
Loading