From 5f89d3e166887f45bc6d6a9e2fba9a920fe84f37 Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Wed, 10 Jul 2024 22:43:24 +0800 Subject: [PATCH] Handle platforms with no devices correctly Some tests were not correctly handling the case where an OpenCL platform had no devices, and instead assumed there was always at least one. Signed-off-by: Rodrigo Tobar --- src/profit/tests/test_convolver.h | 3 ++- src/profit/tests/test_model.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/profit/tests/test_convolver.h b/src/profit/tests/test_convolver.h index 0c20847..9c5c094 100644 --- a/src/profit/tests/test_convolver.h +++ b/src/profit/tests/test_convolver.h @@ -233,7 +233,8 @@ class TestConvolver : public CxxTest::TestSuite { if (has_fftw()) { _test_psf_bigger_than_image(ConvolverType::FFT); } - if (has_opencl() && !get_opencl_info().empty()) { + auto opencl_info = get_opencl_info(); + if (!opencl_info.empty() && !opencl_info[0].dev_info.empty()) { ConvolverCreationPreferences prefs; prefs.opencl_env = get_opencl_environment(0, 0, false, false); _test_psf_bigger_than_image(ConvolverType::OPENCL, prefs); diff --git a/src/profit/tests/test_model.h b/src/profit/tests/test_model.h index 35b7720..4f86fd1 100644 --- a/src/profit/tests/test_model.h +++ b/src/profit/tests/test_model.h @@ -513,7 +513,8 @@ class TestFluxCapturing : public CxxTest::TestSuite { if (has_fftw()) { convolvers.emplace_back(create_convolver(ConvolverType::FFT)); } - if (has_opencl() && !get_opencl_info().empty()) { + auto opencl_info = get_opencl_info(); + if (!opencl_info.empty() && !opencl_info[0].dev_info.empty()) { ConvolverCreationPreferences prefs; prefs.opencl_env = get_opencl_environment(0, 0, false, false); convolvers.emplace_back(create_convolver(ConvolverType::OPENCL, prefs));