Skip to content

Commit 7bdb906

Browse files
authored
fix clGetProgramInfo for some param_names (#774)
- CL_PROGRAM_NUM_KERNELS - CL_PROGRAM_KERNEL_NAMES, - CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT - CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT Those params requires the program to have been built for at least one device according to the specification. Returning the value when the program has not been built triggers a failure in the CTS (compiler get_program_info_kernel_names).
1 parent f1589ab commit 7bdb906

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/api.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,10 +2543,12 @@ cl_int CLVK_API_CALL clGetProgramInfo(cl_program prog,
25432543
return CL_INVALID_PROGRAM;
25442544
}
25452545

2546-
// TODO CL_INVALID_PROGRAM_EXECUTABLE if param_name is
2547-
// CL_PROGRAM_NUM_KERNELS or CL_PROGRAM_KERNEL_NAMES and a successful
2548-
// program executable has not been built for at least one device in the list
2549-
// of devices associated with program.
2546+
bool program_built_once = false;
2547+
for (auto dev : program->devices()) {
2548+
if (program->build_status(dev) == CL_BUILD_SUCCESS) {
2549+
program_built_once = true;
2550+
}
2551+
}
25502552

25512553
switch (param_name) {
25522554
case CL_PROGRAM_NUM_DEVICES:
@@ -2572,6 +2574,9 @@ cl_int CLVK_API_CALL clGetProgramInfo(cl_program prog,
25722574
ret_size = sizeof(cl_device_id) * val_devices.size();
25732575
break;
25742576
case CL_PROGRAM_NUM_KERNELS:
2577+
if (!program_built_once) {
2578+
return CL_INVALID_PROGRAM_EXECUTABLE;
2579+
}
25752580
val_sizet = program->num_kernels();
25762581
copy_ptr = &val_sizet;
25772582
ret_size = sizeof(val_sizet);
@@ -2581,6 +2586,9 @@ cl_int CLVK_API_CALL clGetProgramInfo(cl_program prog,
25812586
ret_size = program->source().size() + 1;
25822587
break;
25832588
case CL_PROGRAM_KERNEL_NAMES: {
2589+
if (!program_built_once) {
2590+
return CL_INVALID_PROGRAM_EXECUTABLE;
2591+
}
25842592
val_string = "";
25852593
std::string sep = "";
25862594
for (auto kname : program->kernel_names()) {
@@ -2619,6 +2627,9 @@ cl_int CLVK_API_CALL clGetProgramInfo(cl_program prog,
26192627
break;
26202628
case CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT:
26212629
case CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT:
2630+
if (!program_built_once) {
2631+
return CL_INVALID_PROGRAM_EXECUTABLE;
2632+
}
26222633
val_bool = CL_FALSE;
26232634
copy_ptr = &val_bool;
26242635
ret_size = sizeof(val_bool);

0 commit comments

Comments
 (0)