Skip to content

Commit

Permalink
add regression test for issue pocl#1435
Browse files Browse the repository at this point in the history
  • Loading branch information
franz committed Apr 4, 2024
1 parent 6c08b95 commit bee90c3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set(PROGRAMS_TO_BUILD test_barrier_between_for_loops test_early_return
test_autolocals_in_constexprs test_issue_553 test_issue_577 test_issue_757
test_flatten_barrier_subs test_alignment_with_dynamic_wg
test_alignment_with_dynamic_wg2 test_alignment_with_dynamic_wg3
test_issue_893 test_builtin_args
test_issue_893 test_issue_1435 test_builtin_args
test_workitem_func_outside_kernel
)

Expand Down Expand Up @@ -83,6 +83,8 @@ add_test_pocl(NAME "regression/test_issue_577" COMMAND "test_issue_577")

add_test_pocl(NAME "regression/test_issue_757" COMMAND "test_issue_757")

add_test_pocl(NAME "regression/test_issue_1435" COMMAND "test_issue_1435")

add_test_pocl(NAME "regression/test_workitem_func_outside_kernel" COMMAND "test_workitem_func_outside_kernel")

if(OPENCL_HEADER_VERSION GREATER 299)
Expand Down Expand Up @@ -231,7 +233,7 @@ foreach(VARIANT ${VARIANTS})
"regression/test_issue_445_${VARIANT}" "regression/test_issue_553_${VARIANT}"
"regression/test_issue_577_${VARIANT}" "regression/test_issue_757_${VARIANT}"
"regression/test_llvm_segfault_issue_889_${VARIANT}"
"regression/test_issue_893_${VARIANT}"
"regression/test_issue_893_${VARIANT}" "regression/test_issue_1435_${VARIANT}"
"regression/test_flatten_barrier_subs_${VARIANT}"
"regression/test_workitem_func_outside_kernel_${VARIANT}"
${OCL_30_TESTS}
Expand Down
52 changes: 52 additions & 0 deletions tests/regression/test_issue_1435.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Github Issue #1435
*/

#include "pocl_opencl.h"

#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#define CL_HPP_TARGET_OPENCL_VERSION 120
#include <CL/opencl.hpp>
#include <cassert>
#include <iostream>

using namespace std;

const char *SOURCE = R"RAW(
__kernel void testkernel(__local float2 *b) {
struct {
int c[1];
float2 d;
} e;
for (int f = 0; f < 2; f++) {
if (f)
for (int g; g < (int)b[0].x; g++)
e.c[g] = 0;
else if (b)
e.d.s0 = b[0].s0;
barrier(0);
}
}
)RAW";

#define ARRAY_SIZE 4

int main(int argc, char *argv[]) {
cl::Device device = cl::Device::getDefault();
cl::Program program(SOURCE);
program.build("-cl-std=CL1.2");

// This triggers compilation of dynamic WG binaries.
cl::Program::Binaries binaries{};
int err = program.getInfo<>(CL_PROGRAM_BINARIES, &binaries);
if (err == CL_SUCCESS) {
printf("OK\n");
return EXIT_SUCCESS;
} else {
printf("FAIL\n");
return EXIT_FAILURE;
}
}

0 comments on commit bee90c3

Please sign in to comment.