diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index c4a4a97d..0d9888d4 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -276,6 +276,7 @@ jobs: include: - VER: v142 GEN: Visual Studio 17 2022 + DEPS: vcpkg BIN: x86 STD: C: 11 @@ -565,6 +566,13 @@ jobs: cmake --version && brew install tclap glm glew sfml mesa-glu + # We need to provide an OpenCL driver for Intel CPU on mac + - name: Install PoCL + shell: bash + run: | + brew install pocl && + sudo ls /usr/local/etc/OpenCL/vendors + - name: Configure shell: bash run: git clone https://github.com/Microsoft/vcpkg.git vcpkg && @@ -578,7 +586,6 @@ jobs: -D BUILD_TESTING=ON -D BUILD_EXAMPLES=ON -D OPENCL_SDK_BUILD_SAMPLES=ON - -D OPENCL_ICD_LOADER_BUILD_TESTING=ON -D CMAKE_C_STANDARD=${{matrix.STD.C}} -D CMAKE_CXX_STANDARD=${{matrix.STD.CXX}} -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install @@ -588,15 +595,15 @@ jobs: - name: Build shell: bash run: | - cmake --build $GITHUB_WORKSPACE/build --config Release --parallel `sysctl -n hw.logicalcpu` cmake --build $GITHUB_WORKSPACE/build --config Debug --parallel `sysctl -n hw.logicalcpu` + cmake --build $GITHUB_WORKSPACE/build --config Release --parallel `sysctl -n hw.logicalcpu` - # - name: Test - # working-directory: ${{runner.workspace}}/OpenCL-SDK/build - # shell: bash - # run: | - # ctest -C Release --output-on-failure --parallel `sysctl -n hw.logicalcpu` - # ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu` + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-SDK/build + shell: bash + run: | + OCL_ICD_VENDORS=/usr/local/etc/OpenCL/vendors ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu` + OCL_ICD_VENDORS=/usr/local/etc/OpenCL/vendors ctest -C Release --output-on-failure --parallel `sysctl -n hw.logicalcpu` - name: Test install shell: bash @@ -612,8 +619,10 @@ jobs: -D CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/install" -S $GITHUB_WORKSPACE/test/cmake/pkgconfig/useutil -B $GITHUB_WORKSPACE/build_install && + cmake --build $GITHUB_WORKSPACE/build_install --config Debug --parallel `sysctl -n hw.logicalcpu` `if [[ "${{matrix.GEN}}" == "Xcode" ]]; then echo "-- -quiet"; fi;` && cmake --build $GITHUB_WORKSPACE/build_install --config Release --parallel `sysctl -n hw.logicalcpu` `if [[ "${{matrix.GEN}}" == "Xcode" ]]; then echo "-- -quiet"; fi;` && - cmake --build $GITHUB_WORKSPACE/build_install --config Debug --parallel `sysctl -n hw.logicalcpu` `if [[ "${{matrix.GEN}}" == "Xcode" ]]; then echo "-- -quiet"; fi;` + OCL_ICD_VENDORS=/usr/local/etc/OpenCL/vendors ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu` && + OCL_ICD_VENDORS=/usr/local/etc/OpenCL/vendors ctest -C Release --output-on-failure --parallel `sysctl -n hw.logicalcpu` python: name: Exercise Python examples on ${{matrix.os}} diff --git a/external/OpenCL-ICD-Loader b/external/OpenCL-ICD-Loader index d4df1c6c..f41872f9 160000 --- a/external/OpenCL-ICD-Loader +++ b/external/OpenCL-ICD-Loader @@ -1 +1 @@ -Subproject commit d4df1c6c6837666c3ca1ee1890e2335877ffd228 +Subproject commit f41872f90857dff8c91c2a5245a620fa99bdc276 diff --git a/samples/core/binaries/main.c b/samples/core/binaries/main.c index 71d8cdf5..e0465291 100644 --- a/samples/core/binaries/main.c +++ b/samples/core/binaries/main.c @@ -199,7 +199,7 @@ int main(int argc, char *argv[]) OCLERROR_PAR(kernel = cl_util_read_text_file(kernel_location, &program_size, &error), error, cont); - printf("OpenCL file red... "); + printf("OpenCL file read... "); OCLERROR_PAR(program = clCreateProgramWithSource(context, 1, (const char **)&kernel, diff --git a/samples/core/binaries/main.cpp b/samples/core/binaries/main.cpp index e8d8b1ac..fa1ac1b7 100644 --- a/samples/core/binaries/main.cpp +++ b/samples/core/binaries/main.cpp @@ -208,7 +208,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) { diff --git a/samples/core/blur/blur.cpp b/samples/core/blur/blur.cpp index 06f6dd52..b8682963 100644 --- a/samples/core/blur/blur.cpp +++ b/samples/core/blur/blur.cpp @@ -503,6 +503,11 @@ std::tuple BlurCppExample::query_capabilities() use_subgroup_exchange_relative); } +bool BlurCppExample::query_opencl_2_0_support() +{ + return cl::util::opencl_c_version_contains(device, "2.0"); +} + void BlurCppExample::create_image_buffers() { input_image_buf = cl::Image2D( diff --git a/samples/core/blur/blur.hpp b/samples/core/blur/blur.hpp index ccfd0c0c..88c7904d 100644 --- a/samples/core/blur/blur.hpp +++ b/samples/core/blur/blur.hpp @@ -41,6 +41,9 @@ class BlurCppExample { // Query device and runtime capabilities std::tuple query_capabilities(); + // Query device support for OpenCL 2.0 + bool query_opencl_2_0_support(); + void create_image_buffers(); void build_program(std::string kernel_op); diff --git a/samples/core/blur/main.c b/samples/core/blur/main.c index 47b047f7..4ac52cbd 100644 --- a/samples/core/blur/main.c +++ b/samples/core/blur/main.c @@ -1048,6 +1048,18 @@ int main(int argc, char *argv[]) free(name); } + // 5) query if OpenCL driver version is 2.0 + bool opencl_version_2_0 = false; + { + char *driver_version = NULL; + OCLERROR_PAR( + driver_version = cl_util_get_device_info(s.device, CL_DRIVER_VERSION, &error), + error, clean); + opencl_version_2_0 = strcmp("2.0", driver_version) ? 0 : 1; + clean: + free(driver_version); + } + /// Create image buffers const cl_image_desc desc = { .image_type = CL_MEM_OBJECT_IMAGE2D, .image_width = s.input_image.width, @@ -1114,7 +1126,7 @@ int main(int argc, char *argv[]) error, prg); /// Subgroup exchange in dual-pass blur - if (use_subgroup_exchange_relative) + if (use_subgroup_exchange_relative && opencl_version_2_0) { printf("Dual-pass subgroup relative exchange blur\n"); @@ -1126,7 +1138,7 @@ int main(int argc, char *argv[]) &s, (cl_int)blur_opts.size), error, prg); } - if (use_subgroup_exchange) + if (use_subgroup_exchange && opencl_version_2_0) { printf("Dual-pass subgroup exchange blur\n"); @@ -1171,7 +1183,7 @@ int main(int argc, char *argv[]) } /// Subgroup exchange in dual-pass Gaussian blur - if (use_subgroup_exchange_relative) + if (use_subgroup_exchange_relative && opencl_version_2_0) { printf("Dual-pass subgroup relative exchange Gaussian blur\n"); @@ -1184,7 +1196,7 @@ int main(int argc, char *argv[]) gauss_kern), error, gkrn); } - if (use_subgroup_exchange) + if (use_subgroup_exchange && opencl_version_2_0) { printf("Dual-pass subgroup exchange Gaussian blur\n"); diff --git a/samples/core/blur/main.cpp b/samples/core/blur/main.cpp index 1b724f17..7472f7e2 100644 --- a/samples/core/blur/main.cpp +++ b/samples/core/blur/main.cpp @@ -49,6 +49,8 @@ int main(int argc, char* argv[]) std::tie(use_local_mem, use_subgroup_exchange, use_subgroup_exchange_relative) = blur.query_capabilities(); + bool opencl_version_2_0 = blur.query_opencl_2_0_support(); + // Create image buffers used for operation. In this example input, // output and temporary image buffers are used. Temporary buffer is used // when 2 blur operations in the row are performed. Result of the first @@ -85,7 +87,7 @@ int main(int argc, char* argv[]) // file you can find 'USE_SUBGROUP_EXCHANGE_RELATIVE' C-like // definition switch for blur_box_horizontal_subgroup_exchange // function. In this case, 2 blur kernel functors are used. - if (use_subgroup_exchange_relative) + if (use_subgroup_exchange_relative && opencl_version_2_0) { std::cout << "Dual-pass subgroup relative exchange blur" << std::endl; @@ -97,7 +99,7 @@ int main(int argc, char* argv[]) // Same as the previous one, but with a different build switch. See // the blur.cl file for more info about the switch. - if (use_subgroup_exchange) + if (use_subgroup_exchange && opencl_version_2_0) { std::cout << "Dual-pass subgroup exchange blur" << std::endl; // cl_khr_subgroup_shuffle requires OpenCL 2.0 @@ -133,7 +135,7 @@ int main(int argc, char* argv[]) // Similar to dual_pass_subgroup_exchange_box_blur but with a gauss // kernel. - if (use_subgroup_exchange_relative) + if (use_subgroup_exchange_relative && opencl_version_2_0) { std::cout << "Dual-pass subgroup relative exchange Gaussian blur" @@ -146,7 +148,7 @@ int main(int argc, char* argv[]) // Same as the previous one, but with a different build switch. See // the blur.cl file for more info about the switch. - if (use_subgroup_exchange) + if (use_subgroup_exchange && opencl_version_2_0) { std::cout << "Dual-pass subgroup exchange Gaussian blur" << std::endl; diff --git a/samples/core/reduce/main.cpp b/samples/core/reduce/main.cpp index cfa5361a..c49262f7 100644 --- a/samples/core/reduce/main.cpp +++ b/samples/core/reduce/main.cpp @@ -313,7 +313,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) { diff --git a/samples/core/saxpy/main.cpp b/samples/core/saxpy/main.cpp index 3b87e293..39a6244b 100644 --- a/samples/core/saxpy/main.cpp +++ b/samples/core/saxpy/main.cpp @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) { diff --git a/samples/extensions/khr/conway/main.cpp b/samples/extensions/khr/conway/main.cpp index afa2c914..faea2611 100644 --- a/samples/extensions/khr/conway/main.cpp +++ b/samples/extensions/khr/conway/main.cpp @@ -396,7 +396,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) { diff --git a/samples/extensions/khr/histogram/main.cpp b/samples/extensions/khr/histogram/main.cpp index 338f066a..6ae8bede 100644 --- a/samples/extensions/khr/histogram/main.cpp +++ b/samples/extensions/khr/histogram/main.cpp @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) { diff --git a/samples/extensions/khr/nbody/main.cpp b/samples/extensions/khr/nbody/main.cpp index 7df8aa8b..927757f0 100644 --- a/samples/extensions/khr/nbody/main.cpp +++ b/samples/extensions/khr/nbody/main.cpp @@ -502,7 +502,7 @@ int main(int argc, char* argv[]) std::exit(e.err()); } catch (cl::Error& e) { - std::cerr << "OpenCL rutnime error: " << e.what() << std::endl; + std::cerr << "OpenCL runtime error: " << e.what() << std::endl; std::exit(e.err()); } catch (std::exception& e) {