Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions sycl/tools/sycl-ls/sycl-ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -467,14 +468,26 @@ int main(int argc, char **argv) {

// In verbose mode, if UR logging has not already been enabled by the user,
// enable the printing of any errors related to adapter loading.
const char *ur_log_loader_var = std::getenv("UR_LOG_LOADER");
if (verbose && ur_log_loader_var == nullptr)
setenv("UR_LOG_LOADER", "level:info;output:stderr", 1);
constexpr const char *Loggers[] = {"UR_LOG_LOADER", "UR_LOG_CUDA",
"UR_LOG_HIP", "UR_LOG_NATIVE_CPU",
"UR_LOG_OFFLOAD", "UR_LOG_OPENCL",
"UR_LOG_LEVEL_ZERO"};
std::vector<const char *> SetLoggers;

if (verbose) {
for (const auto &Logger : Loggers)
if (nullptr == std::getenv(Logger)) {
SetLoggers.push_back(Logger);
setenv(Logger, "level:info;output:stderr", 1);
}
}

const auto &Platforms = platform::get_platforms();

if (verbose && ur_log_loader_var == nullptr) {
unsetenv("UR_LOG_LOADER");
if (verbose) {
for (const auto &Logger : SetLoggers) {
unsetenv(Logger);
}
} else if (Platforms.size() == 0) {
std::cout
<< "No platforms found - run with '--verbose' to get more details."
Expand Down Expand Up @@ -512,6 +525,7 @@ int main(int argc, char **argv) {
if (verbose) {
std::cout << "\nPlatforms: " << Platforms.size() << std::endl;
uint32_t PlatformNum = 0;
std::set<backend> SeenBackends;
if (!SuppressNumberPrinting)
DeviceNums.clear();
for (const auto &Platform : Platforms) {
Expand All @@ -535,7 +549,39 @@ int main(int argc, char **argv) {
}
printDeviceInfo(Device, true, " ");
}
if (!Devices.empty())
SeenBackends.insert(Backend);
}

if (SeenBackends.count(backend::opencl) == 0) {
std::cout
<< "If you expect OpenCL devices to be present, the clinfo "
"tool can be used to diagnose configuration issues with OpenCL."
<< std::endl;
}
if (SeenBackends.count(backend::ext_oneapi_cuda) == 0) {
std::cout
<< "If you expect CUDA devices to be present, the nvidia-smi tool "
"can be used to diagnose configuration issues with CUDA."
<< std::endl;
}
if (SeenBackends.count(backend::ext_oneapi_hip) == 0) {
std::cout << "If you expect HIP devices to be present, the rocminfo or "
"amd-smi tools can be used to diagnose configuration "
"issues with HIP."
<< std::endl;
}
if (SeenBackends.count(backend::ext_oneapi_level_zero) == 0) {
std::cout << "If you expect Level Zero devices to be present, setting "
"ZE_ENABLE_LOADER_DEBUG_TRACE=1 can be used to diagnose "
"configuration issues by the loader."
<< std::endl;
}
#ifdef __linux__
std::cout
<< "strace can be used to diagnose any missing shared libraries."
<< std::endl;
#endif
Comment thread
inteltdelisle marked this conversation as resolved.
} else {
return EXIT_SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions unified-runtime/source/adapters/cuda/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ urPlatformGet(ur_adapter_handle_t, uint32_t, ur_platform_handle_t *phPlatforms,
Device, Context, UMF_MEMORY_TYPE_SHARED,
&dev->MemoryProviderShared, &dev->MemoryPoolShared));
}
UR_LOG(INFO, "CUDA: found {} platforms", NumPlatforms);
} catch (const std::bad_alloc &) {
// Signal out-of-memory situation
for (int i = 0; i < NumDevices; ++i) {
Expand Down
1 change: 1 addition & 0 deletions unified-runtime/source/adapters/hip/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ urPlatformGet(ur_adapter_handle_t, uint32_t, ur_platform_handle_t *phPlatforms,
ScopedDevice Active(
ur::hip::adapter->Platform->Devices.front().get());
}
UR_LOG(INFO, "HIP: found {} platforms", NumPlatforms);
} catch (const std::bad_alloc &) {
// Signal out-of-memory situation
ur::hip::adapter->Platform->Devices.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()

ur_result_t err = initPlatforms(this, platforms, ZesResult);
if (err == UR_RESULT_SUCCESS) {
UR_LOG(DEBUG, "Initialized {} platforms", platforms.size());
UR_LOG(INFO, "L0: found {} platforms", platforms.size());
Platforms = std::move(platforms);
} else {
UR_LOG(ERR, "Failed to initialize Platforms");
Expand Down
5 changes: 5 additions & 0 deletions unified-runtime/source/adapters/native_cpu/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ urPlatformGet(ur_adapter_handle_t, uint32_t NumEntries,

UR_ASSERT(pNumPlatforms || phPlatforms, UR_RESULT_ERROR_INVALID_VALUE);

[[maybe_unused]] static const bool Logged = [] {
UR_LOG(INFO, "NATIVE_CPU: found 1 platform");
return true;
}();

if (pNumPlatforms) {
*pNumPlatforms = 1;
}
Expand Down
4 changes: 4 additions & 0 deletions unified-runtime/source/adapters/offload/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ ur_result_t ur_adapter_handle_t_::init() {
},
&Adapter->Platforms);

if (Res == OL_SUCCESS) {
UR_LOG(INFO, "OFFLOAD: found {} platforms", Adapter->Platforms.size());
}

return offloadResultToUR(Res);
}

Expand Down
1 change: 1 addition & 0 deletions unified-runtime/source/adapters/opencl/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ur::opencl::ur_adapter_handle_t_::ur_adapter_handle_t_() : handle_base() {
cl_uint NumPlatforms = 0;
cl_int Result = ocl::clGetPlatformIDs_ptr(0, nullptr, &NumPlatforms);
if (Result != CL_SUCCESS || NumPlatforms == 0) {
UR_LOG(INFO, "OpenCL: No platforms found (Result = {})", Result);
// No platforms found — unload immediately. This adapter never escapes
// urAdapterGet, so no teardown paths can hold function pointers yet.
ocl::unloadOCLLibrary();
Expand Down
1 change: 1 addition & 0 deletions unified-runtime/source/adapters/opencl/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ ur_result_t urPlatformGet(ur_adapter_handle_t, uint32_t NumEntries,
}
Adapter->NumPlatforms =
static_cast<uint32_t>(Adapter->URPlatforms.size());
UR_LOG(INFO, "OpenCL: found {} platforms", Adapter->NumPlatforms);
} catch (std::bad_alloc &) {
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
} catch (...) {
Expand Down
6 changes: 6 additions & 0 deletions unified-runtime/source/loader/ur_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ ur_result_t context_t::init() {
if (!adapter_registry.adaptersForceLoaded()) {
#ifdef UR_STATIC_ADAPTER_LEVEL_ZERO
if (adapter_registry.includesAdapter("ur_adapter_level_zero")) {
UR_LOG(INFO, "Statically loaded adapter: ur_adapter_level_zero");
auto &level_zero = platforms.emplace_back(nullptr);
ur::level_zero::v1::urAdapterGetDdiTables(&level_zero.dditable);
adapter_registry.markAdapterAsStaticallyLoaded("ur_adapter_level_zero");
}
#endif
#ifdef UR_STATIC_ADAPTER_LEVEL_ZERO_V2
if (adapter_registry.includesAdapter("ur_adapter_level_zero_v2")) {
UR_LOG(INFO, "Statically loaded adapter: ur_adapter_level_zero_v2");
auto &level_zero_v2 = platforms.emplace_back(nullptr);
ur::level_zero::v2::urAdapterGetDdiTables(&level_zero_v2.dditable);
adapter_registry.markAdapterAsStaticallyLoaded(
Expand All @@ -60,6 +62,7 @@ ur_result_t context_t::init() {
#endif
#ifdef UR_STATIC_ADAPTER_OPENCL
if (adapter_registry.includesAdapter("ur_adapter_opencl")) {
UR_LOG(INFO, "Statically loaded adapter: ur_adapter_opencl");
auto &opencl = platforms.emplace_back(nullptr);
ur::opencl::urAdapterGetDdiTables(&opencl.dditable);
adapter_registry.markAdapterAsStaticallyLoaded("ur_adapter_opencl");
Expand All @@ -78,6 +81,7 @@ ur_result_t context_t::init() {
for (const auto &path : adapterPaths) {
auto handle = LibLoader::loadAdapterLibrary(path.string().c_str());
if (handle) {
UR_LOG(INFO, "Successfully loaded adapter: {}", path.string());
platforms.emplace_back(std::move(handle));
break;
}
Expand All @@ -88,6 +92,8 @@ ur_result_t context_t::init() {
(void)SetErrorMode(SavedMode);
#endif

UR_LOG(INFO, "{} adapters loaded", platforms.size());

forceIntercept = getenv_tobool("UR_ENABLE_LOADER_INTERCEPT");

if (forceIntercept || platforms.size() > 1) {
Expand Down
Loading