diff --git a/SYCL/Basic/library_loading.cpp b/SYCL/Basic/library_loading.cpp index 7776f84f5e..c8835076b0 100644 --- a/SYCL/Basic/library_loading.cpp +++ b/SYCL/Basic/library_loading.cpp @@ -1,17 +1,20 @@ // REQUIRES: linux // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -// RUN: env SYCL_PI_TRACE=-1 %t.out &> %t_trace.txt || true -// RUN: FileCheck --input-file=%t_trace.txt %s - +// RUN: env SYCL_PI_TRACE=-1 %t.out &> %t_trace_no_filter.txt || true +// RUN: FileCheck --input-file=%t_trace_no_filter.txt --check-prefix=CHECK-NO-FILTER %s +// RUN: env SYCL_PI_TRACE=-1 SYCL_DEVICE_FILTER=esimd_emulator %t.out &> %t_trace_esimd_filter.txt || true +// RUN: FileCheck --input-file=%t_trace_esimd_filter.txt --check-prefix=CHECK-ESIMD-FILTER %s // Checks pi traces on library loading + #include using namespace sycl; int main() { - // CHECK: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_cuda.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_cuda.so)}} - // CHECK: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_hip.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_hip.so)}} - // CHECK: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_esimd_emulator.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_esimd_emulator.so)}} + // CHECK-NO-FILTER: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_cuda.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_cuda.so)}} + // CHECK-NO-FILTER-NOT: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_esimd_emulator.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_esimd_emulator.so)}} + // CHECK-NO-FILTER: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_hip.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_hip.so)}} + // CHECK-ESIMD-FILTER: {{(SYCL_PI_TRACE\[-1\]: dlopen\(.*/libpi_esimd_emulator.so\) failed with)|(SYCL_PI_TRACE\[basic\]: Plugin found and successfully loaded: libpi_esimd_emulator.so)}} queue q; q.submit([&](handler &cgh) {}); } diff --git a/SYCL/ESIMD/esimd_test_utils.hpp b/SYCL/ESIMD/esimd_test_utils.hpp index 335b0c3f42..07c03a32e4 100644 --- a/SYCL/ESIMD/esimd_test_utils.hpp +++ b/SYCL/ESIMD/esimd_test_utils.hpp @@ -26,26 +26,28 @@ using namespace sycl; namespace esimd_test { -// This is function provided to SYCL runtime by the application to decide +// This is the function provided to SYCL runtime by the application to decide // on which device to run, or whether to run at all. // When selecting a device, SYCL runtime first takes (1) a selector provided by // the program or a default one and (2) the set of all available devices. Then -// it passes each device to the selector. A device for which the highest number -// is returned is selected. If a negative number was returned for all devices, -// then the selection process will cause an exception. +// it passes each device to the '()' operator of the selector. Device, for +// which '()' returned the highest number, is selected. If a negative number +// was returned for all devices, then the selection process will cause an +// exception. +// Require GPU device inline int ESIMDSelector(const device &device) { - if (const char *dev_filter = getenv("SYCL_DEVICE_FILTER")) { - std::string filter_string(dev_filter); - if (filter_string.find("gpu") != std::string::npos) - return device.is_gpu() ? 1000 : -1; - - std::cerr - << "Supported 'SYCL_DEVICE_FILTER' env var device type is 'gpu' and " - << filter_string << "' does not contain that.\n"; + const std::string intel{"Intel(R) Corporation"}; + if (device.get_backend() == backend::ext_intel_esimd_emulator) { + return 1000; + } else if (device.is_gpu() && + (device.get_info() == intel)) { + // pick gpu device if esimd not available but give it a lower score in + // order not to compete with the esimd in environments where both are + // present + return 900; + } else { return -1; } - // If "SYCL_DEVICE_FILTER" not defined, only allow gpu device - return device.is_gpu() ? 1000 : -1; } inline auto createExceptionHandler() {