Skip to content

Commit

Permalink
Merge branch 'release_1_4'
Browse files Browse the repository at this point in the history
  • Loading branch information
franz committed Sep 11, 2019
2 parents 8176364 + e691edb commit 8962942
Show file tree
Hide file tree
Showing 22 changed files with 316 additions and 50 deletions.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif()

include(CheckCCompilerFlag)

# don't allow implicit function declarations
if(UNIX)
if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang"))

set(FORBIT_IMPLICIT_FUNCTIONS "-Werror=implicit-function-declaration;-Werror=incompatible-pointer-types")
check_c_compiler_flag("-Wincompatible-pointer-types" HAVE_WARN_INCOMPATIBLE_POINTER_TYPES)
set(FORBIT_IMPLICIT_FUNCTIONS "-Werror=implicit-function-declaration")
if (HAVE_WARN_INCOMPATIBLE_POINTER_TYPES)
set(FORBIT_IMPLICIT_FUNCTIONS ${FORBIT_IMPLICIT_FUNCTIONS} "-Werror=incompatible-pointer-types")
endif()
add_compile_options(${FORBIT_IMPLICIT_FUNCTIONS})

else()
Expand Down Expand Up @@ -181,6 +187,15 @@ else()
set(ENABLE_TSAN OFF CACHE INTERNAL "Enable ThreadSanitizer")
endif()

# Unfortunately the way CMake tests work, if they're given
# a pass/fail expression, they don't check for exit status.
# This was causing some false negatives with ASan (test was
# returning with 1, but CMake reported it as pass because
# the pass expression was present in output).
if(ENABLE_ASAN OR ENABLE_TSAN OR ENABLE_UBSAN OR ENABLE_LSAN)
set(ENABLE_ANYSAN 1)
endif()

##########################################################

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down
8 changes: 5 additions & 3 deletions cmake/add_test_pocl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ function(add_test_pocl)
list(APPEND POCL_TEST_ARGLIST "-P" "${CMAKE_SOURCE_DIR}/cmake/run_test.cmake")

add_test(${POCL_TEST_ARGLIST} )
set_tests_properties("${POCL_TEST_NAME}" PROPERTIES
PASS_REGULAR_EXPRESSION "OK"
FAIL_REGULAR_EXPRESSION "FAIL")
if(NOT ENABLE_ANYSAN)
set_tests_properties("${POCL_TEST_NAME}" PROPERTIES
PASS_REGULAR_EXPRESSION "OK"
FAIL_REGULAR_EXPRESSION "FAIL")
endif()

endfunction()
8 changes: 7 additions & 1 deletion examples/boxadd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ target_link_libraries("boxadd" ${POCLU_LINK_OPTIONS})

add_test("examples/boxadd" "boxadd")

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK")
endif()

set_tests_properties( "examples/boxadd"
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK"
${PROPS}
PROCESSORS 1
LABELS "internal;"
DEPENDS "pocl_version_check")
14 changes: 12 additions & 2 deletions examples/example0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ if (ENABLE_SPIRV)
list(APPEND SPIREX "examples/example0_spirv")
endif()

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK")
endif()

set_tests_properties( "examples/example0" ${SPIREX}
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK"
${PROPS}
PROCESSORS 1
ENVIRONMENT "POCL_TTASIM0_PARAMETERS=${CMAKE_SOURCE_DIR}/tools/data/test_machine_LE.adf"
LABELS "internal;hsa;tce;cuda"
LABELS "internal;cuda"
DEPENDS "pocl_version_check")

# devices which don't support SPIR
set_property(TEST "examples/example0"
APPEND PROPERTY LABELS "tce;hsa;hsa-native")
23 changes: 14 additions & 9 deletions examples/example1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,25 @@ if (ENABLE_SPIRV)
list(APPEND SPIREX "examples/example1_spirv")
endif()

set_tests_properties( "examples/example1_dot_product" ${SPIREX}
PROPERTIES
COST 3.0
set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "[(]0[.]000000, 0[.]000000, 0[.]000000, 0[.]000000[)] [.] [(]0[.]000000, 0[.]000000, 0[.]000000, 0[.]000000[)] = 0[.]000000
[(]1[.]000000, 1[.]000000, 1[.]000000, 1[.]000000[)] [.] [(]1[.]000000, 1[.]000000, 1[.]000000, 1[.]000000[)] = 4[.]000000
[(]2[.]000000, 2[.]000000, 2[.]000000, 2[.]000000[)] [.] [(]2[.]000000, 2[.]000000, 2[.]000000, 2[.]000000[)] = 16[.]000000
[(]3[.]000000, 3[.]000000, 3[.]000000, 3[.]000000[)] [.] [(]3[.]000000, 3[.]000000, 3[.]000000, 3[.]000000[)] = 36[.]000000
OK"
OK")
endif()

set_tests_properties( "examples/example1_dot_product" ${SPIREX}
PROPERTIES
COST 3.0
${PROPS}
PROCESSORS 1
ENVIRONMENT "POCL_TTASIM0_PARAMETERS=${CMAKE_SOURCE_DIR}/tools/data/test_machine_LE.adf"
LABELS "internal;hsa;tce;cuda"
LABELS "internal;cuda"
DEPENDS "pocl_version_check")

set_tests_properties( "examples/example1_dot_product"
PROPERTIES
LABELS "hsa-native"
DEPENDS "pocl_version_check")
# devices which don't support SPIR
set_property(TEST "examples/example1_dot_product"
APPEND PROPERTY LABELS "tce;hsa;hsa-native")
18 changes: 12 additions & 6 deletions examples/example2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,23 @@ if (ENABLE_SPIR)
set(SPIREX "examples/example2_spir")
endif()


set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK\n")
endif()

set_tests_properties( "examples/example2" ${SPIREX}
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK\n"
${PROPS}
PROCESSORS 1
ENVIRONMENT "POCL_TTASIM0_PARAMETERS=${CMAKE_SOURCE_DIR}/tools/data/test_machine_LE.adf"
LABELS "internal;hsa;tce;cuda"
LABELS "internal;cuda"
DEPENDS "pocl_version_check")

set_tests_properties( "examples/example2"
PROPERTIES
LABELS "hsa-native"
DEPENDS "pocl_version_check")
# devices which don't support SPIR
set_property(TEST "examples/example2"
APPEND PROPERTY LABELS "tce;hsa;hsa-native")

17 changes: 11 additions & 6 deletions examples/example2a/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ if (ENABLE_SPIR)
set(SPIREX "examples/example2a_spir")
endif()

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK\n")
endif()

set_tests_properties( "examples/example2a" ${SPIREX}
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK\n"
${PROPS}
PROCESSORS 1
ENVIRONMENT "POCL_TTASIM0_PARAMETERS=${CMAKE_SOURCE_DIR}/tools/data/test_machine_LE.adf"
LABELS "internal;hsa;tce;cuda"
LABELS "internal;cuda"
DEPENDS "pocl_version_check")

set_tests_properties( "examples/example2a"
PROPERTIES
LABELS "hsa-native"
DEPENDS "pocl_version_check")
# devices which don't support SPIR
set_property(TEST "examples/example2a"
APPEND PROPERTY LABELS "tce;hsa;hsa-native")
8 changes: 7 additions & 1 deletion examples/matadd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ target_link_libraries("matadd" ${POCLU_LINK_OPTIONS})

add_test("examples/matadd" "matadd")

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK")
endif()

set_tests_properties( "examples/matadd"
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK"
${PROPS}
PROCESSORS 1
LABELS "internal;"
DEPENDS "pocl_version_check")
2 changes: 1 addition & 1 deletion examples/matrix1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
#=============================================================================

add_compile_options(${OPENCL_CFLAGS})
add_compile_options(${OPENCL_CFLAGS} -std=c99)

if (MSVC)
set_source_files_properties( matrix1.c PROPERTIES LANGUAGE CXX )
Expand Down
3 changes: 3 additions & 0 deletions examples/matrix1/matrix1.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
IN THE SOFTWARE.
*/

// For srandom
#define _BSD_SOURCE

#include <CL/opencl.h>
#include <assert.h>
#include <errno.h>
Expand Down
8 changes: 7 additions & 1 deletion examples/scalarwave/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ target_link_libraries("scalarwave" ${POCLU_LINK_OPTIONS})

add_test_pocl(NAME "examples/scalarwave" COMMAND "scalarwave" EXPECTED_OUTPUT "scalarwave_expout.txt")

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "Done.\n")
endif()

set_tests_properties( "examples/scalarwave"
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "Done.\n"
${PROPS}
PROCESSORS 1
LABELS "internal;cuda;hsa-native"
DEPENDS "pocl_version_check")
8 changes: 7 additions & 1 deletion examples/trig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ target_link_libraries("trig" ${POCLU_LINK_OPTIONS})

add_test("examples/trig" "trig")

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK")
endif()

set_tests_properties(
"examples/trig"
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK\n"
${PROPS}
PROCESSORS 1
LABELS "internal;cuda;hsa-native"
DEPENDS "pocl_version_check")
8 changes: 7 additions & 1 deletion examples/vecadd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ add_test("examples/vecadd" "vecadd")

add_test("examples/vecadd_large_grid" "vecadd" "128000" "128" "10000" "100" "1" "1")

set(PROPS)
if(NOT ENABLE_ANYSAN)
set(PROPS
PASS_REGULAR_EXPRESSION "OK")
endif()

set_tests_properties( "examples/vecadd"
PROPERTIES
COST 3.0
PASS_REGULAR_EXPRESSION "OK"
${PROPS}
PROCESSORS 1
LABELS "internal;"
DEPENDS "pocl_version_check")
3 changes: 2 additions & 1 deletion examples/vecadd/vecadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ main (int argc, char **argv)
if (argc > 2)
launches = (argc - 1) / 2;

for (int l = 0; l < launches; ++l)
int l;
for (l = 0; l < launches; ++l)
{
int vec_width = N;
int wg_size = N;
Expand Down
6 changes: 4 additions & 2 deletions lib/CL/clCreateProgramWithBuiltInKernels.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ CL_API_SUFFIX__VERSION_1_2
while (token != NULL)
{
unsigned num_supported = 0;
for (cl_uint i = 0; i < num_devices; ++i)
cl_uint i;
for (i = 0; i < num_devices; ++i)
{
cl_device_id dev = device_list[i];
if (dev->ops->supports_builtin_kernel == NULL)
Expand All @@ -72,7 +73,8 @@ CL_API_SUFFIX__VERSION_1_2

kernel_names_copy = strdup (kernel_names);
token = strtok_r (kernel_names_copy, ";", &save_ptr);
for (unsigned i = 0; token != NULL; ++i)
unsigned i;
for (i = 0; token != NULL; ++i)
{
builtin_names[i] = strdup (token);
token = strtok_r (NULL, ";", &save_ptr);
Expand Down
8 changes: 7 additions & 1 deletion lib/CL/pocl_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ free_meta (cl_program program)
continue;
POCL_MEM_FREE (meta->attributes);
POCL_MEM_FREE (meta->name);
for (j = 0; j < meta->num_args; ++j)
{
POCL_MEM_FREE (meta->arg_info[j].name);
POCL_MEM_FREE (meta->arg_info[j].type_name);
}
POCL_MEM_FREE (meta->arg_info);
for (j = 0; j < program->num_devices; ++j)
if (meta->data[j] != NULL)
Expand Down Expand Up @@ -821,7 +826,8 @@ compile_and_link_program(int compile_program,
program->kernel_meta = calloc (program->num_kernels,
sizeof (pocl_kernel_metadata_t));

for (size_t i = 0; i < program->num_kernels; ++i)
size_t i;
for (i = 0; i < program->num_kernels; ++i)
{
device->ops->get_builtin_kernel_metadata (
device->data, program->builtin_kernel_names[i],
Expand Down
7 changes: 3 additions & 4 deletions lib/llvmopencl/WorkitemReplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,16 @@ WorkitemReplication::ProcessFunction(Function &F)

//pocl::dumpCFG(F, F.getName().str() + ".after_repl.dot", original_parallel_regions);

if (original_parallel_regions) {
for (auto i = original_parallel_regions->begin(),
e = original_parallel_regions->end();
for (size_t j = 0; j < parallel_regions.size(); ++j) {
for (auto i = parallel_regions[j].begin(),
e = parallel_regions[j].end();
i != e; ++i) {
ParallelRegion *p = *i;
delete p;
}
}
delete original_parallel_regions;
original_parallel_regions = nullptr;
// F.viewCFG();

return true;
}
Expand Down
16 changes: 11 additions & 5 deletions tests/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,25 @@ add_test_pocl(NAME "kernel/test_hadd_loopvec"
add_test_pocl(NAME "kernel/test_hadd_loops"
COMMAND "kernel" "test_hadd")

set(PROPS "")
if(NOT ENABLE_ANYSAN)
set(PROPS
FAIL_REGULAR_EXPRESSION "FAIL"
PASS_REGULAR_EXPRESSION "OK\n")
endif()

set_tests_properties( "kernel/test_as_type" "kernel/test_bitselect"
"kernel/test_convert_type_1" "kernel/test_convert_type_2" "kernel/test_convert_type_4"
"kernel/test_convert_type_8" "kernel/test_convert_type_16"
"kernel/test_hadd_loops" "kernel/test_hadd_loopvec"
PROPERTIES
COST 40.0
FAIL_REGULAR_EXPRESSION "FAIL"
PASS_REGULAR_EXPRESSION "\nOK\n"
${PROPS}
PROCESSORS 1
DEPENDS "pocl_version_check"
LABELS "kernel")


# convert_type_{4,8,16} on some machines takes >1 hour,
# so only add convert_type_1/2 to internal tests to keep them reasonably fast.

Expand Down Expand Up @@ -132,8 +139,7 @@ set_tests_properties("kernel/test_min_max" "kernel/test_length_distance"
"kernel/test_frexp_modf"
PROPERTIES
COST 4.0
FAIL_REGULAR_EXPRESSION "FAIL"
PASS_REGULAR_EXPRESSION "\nOK\n"
${PROPS}
PROCESSORS 1
DEPENDS "pocl_version_check"
LABELS "internal;kernel")
Expand Down Expand Up @@ -235,7 +241,7 @@ set_tests_properties("kernel/test_shuffle_char"

PROPERTIES
COST 77
PASS_REGULAR_EXPRESSION "OK\n"
${PROPS}
PROCESSORS 1
DEPENDS "pocl_version_check"
LABELS "internal;kernel")
Expand Down
Loading

0 comments on commit 8962942

Please sign in to comment.