Skip to content

Commit

Permalink
Fix MacOS test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Beanavil committed Sep 13, 2023
1 parent ddef3a5 commit ca64897
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 25 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,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 &&
Expand All @@ -581,7 +588,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
Expand All @@ -591,15 +597,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
Expand All @@ -615,8 +621,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}}
Expand Down
2 changes: 1 addition & 1 deletion external/OpenCL-ICD-Loader
2 changes: 1 addition & 1 deletion samples/core/binaries/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion samples/core/binaries/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 5 additions & 0 deletions samples/core/blur/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ std::tuple<bool, bool, bool> 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(
Expand Down
3 changes: 3 additions & 0 deletions samples/core/blur/blur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class BlurCppExample {
// Query device and runtime capabilities
std::tuple<bool, bool, bool> 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);
Expand Down
20 changes: 16 additions & 4 deletions samples/core/blur/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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");

Expand All @@ -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");

Expand Down Expand Up @@ -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");

Expand All @@ -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");

Expand Down
10 changes: 6 additions & 4 deletions samples/core/blur/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion samples/core/reduce/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/core/saxpy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/extensions/khr/conway/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,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)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/extensions/khr/histogram/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/extensions/khr/nbody/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit ca64897

Please sign in to comment.