From a314dd8cc8f573d7937adef74f7da71cb8379166 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Fri, 8 Dec 2023 20:51:12 +0100 Subject: [PATCH 1/2] [UR][L0] Fix tracing param in disjoint_pool_parser The disjoint_pool implementation distinguishes between a few different levels of logging (0-3). The argument should be an int, not bool. --- source/adapters/level_zero/usm.cpp | 2 +- source/common/umf_pools/disjoint_pool_config_parser.cpp | 2 +- source/common/umf_pools/disjoint_pool_config_parser.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index c6d98855e7..0d696a5524 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -64,7 +64,7 @@ usm::DisjointPoolAllConfigs InitializeDisjointPoolConfig() { ? PoolUrTraceVal : (PoolPiTraceVal ? PoolPiTraceVal : nullptr); - bool PoolTrace = false; + int PoolTrace = 0; if (PoolTraceVal != nullptr) { PoolTrace = std::atoi(PoolTraceVal); } diff --git a/source/common/umf_pools/disjoint_pool_config_parser.cpp b/source/common/umf_pools/disjoint_pool_config_parser.cpp index e7fabf07df..92ffd1197d 100644 --- a/source/common/umf_pools/disjoint_pool_config_parser.cpp +++ b/source/common/umf_pools/disjoint_pool_config_parser.cpp @@ -61,7 +61,7 @@ DisjointPoolAllConfigs::DisjointPoolAllConfigs() { } DisjointPoolAllConfigs parseDisjointPoolConfig(const std::string &config, - bool trace) { + int trace) { DisjointPoolAllConfigs AllConfigs; // TODO: replace with UR ENV var parser and avoid creating a copy of 'config' diff --git a/source/common/umf_pools/disjoint_pool_config_parser.hpp b/source/common/umf_pools/disjoint_pool_config_parser.hpp index 55f1242db1..2e9b07deba 100644 --- a/source/common/umf_pools/disjoint_pool_config_parser.hpp +++ b/source/common/umf_pools/disjoint_pool_config_parser.hpp @@ -51,7 +51,7 @@ class DisjointPoolAllConfigs { // Example of usage: // "1;32M;host:1M,4,64K;device:1M,4,64K;shared:0,0,2M" DisjointPoolAllConfigs parseDisjointPoolConfig(const std::string &config, - bool trace = 1); + int trace = 1); } // namespace usm #endif From 8ee650de3f92ca55b8411ce73612654779b8cdbd Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Wed, 13 Dec 2023 19:38:30 +0100 Subject: [PATCH 2/2] [UR][L0] Make allocator tracing independent of setting the limits Without this change, setting UR_L0_USM_ALLOCATOR_TRACE or SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR_TRACE only had an effect if UR_L0_USM_ALLOCATOR or SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR was also set. --- source/adapters/level_zero/usm.cpp | 16 ++++++++-------- .../umf_pools/disjoint_pool_config_parser.cpp | 6 +++++- .../umf_pools/disjoint_pool_config_parser.hpp | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index 0d696a5524..febea17d32 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -49,14 +49,6 @@ ur_result_t umf2urResult(umf_result_t umfResult) { } usm::DisjointPoolAllConfigs InitializeDisjointPoolConfig() { - const char *PoolUrConfigVal = std::getenv("SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR"); - const char *PoolPiConfigVal = std::getenv("UR_L0_USM_ALLOCATOR"); - const char *PoolConfigVal = - PoolUrConfigVal ? PoolUrConfigVal : PoolPiConfigVal; - if (PoolConfigVal == nullptr) { - return usm::DisjointPoolAllConfigs(); - } - const char *PoolUrTraceVal = std::getenv("UR_L0_USM_ALLOCATOR_TRACE"); const char *PoolPiTraceVal = std::getenv("SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR_TRACE"); @@ -69,6 +61,14 @@ usm::DisjointPoolAllConfigs InitializeDisjointPoolConfig() { PoolTrace = std::atoi(PoolTraceVal); } + const char *PoolUrConfigVal = std::getenv("SYCL_PI_LEVEL_ZERO_USM_ALLOCATOR"); + const char *PoolPiConfigVal = std::getenv("UR_L0_USM_ALLOCATOR"); + const char *PoolConfigVal = + PoolUrConfigVal ? PoolUrConfigVal : PoolPiConfigVal; + if (PoolConfigVal == nullptr) { + return usm::DisjointPoolAllConfigs(PoolTrace); + } + return usm::parseDisjointPoolConfig(PoolConfigVal, PoolTrace); } diff --git a/source/common/umf_pools/disjoint_pool_config_parser.cpp b/source/common/umf_pools/disjoint_pool_config_parser.cpp index 92ffd1197d..539529fb90 100644 --- a/source/common/umf_pools/disjoint_pool_config_parser.cpp +++ b/source/common/umf_pools/disjoint_pool_config_parser.cpp @@ -24,7 +24,7 @@ constexpr auto operator""_GB(unsigned long long x) -> size_t { return x * 1024 * 1024 * 1024; } -DisjointPoolAllConfigs::DisjointPoolAllConfigs() { +DisjointPoolAllConfigs::DisjointPoolAllConfigs(int trace) { Configs[DisjointPoolMemType::Host].name = "Host"; Configs[DisjointPoolMemType::Device].name = "Device"; Configs[DisjointPoolMemType::Shared].name = "Shared"; @@ -58,6 +58,10 @@ DisjointPoolAllConfigs::DisjointPoolAllConfigs() { Configs[DisjointPoolMemType::SharedReadOnly].MaxPoolableSize = 4_MB; Configs[DisjointPoolMemType::SharedReadOnly].Capacity = 4; Configs[DisjointPoolMemType::SharedReadOnly].SlabMinSize = 2_MB; + + for (auto &Config : Configs) { + Config.PoolTrace = trace; + } } DisjointPoolAllConfigs parseDisjointPoolConfig(const std::string &config, diff --git a/source/common/umf_pools/disjoint_pool_config_parser.hpp b/source/common/umf_pools/disjoint_pool_config_parser.hpp index 2e9b07deba..98455fba0e 100644 --- a/source/common/umf_pools/disjoint_pool_config_parser.hpp +++ b/source/common/umf_pools/disjoint_pool_config_parser.hpp @@ -23,7 +23,7 @@ class DisjointPoolAllConfigs { size_t EnableBuffers = 1; DisjointPoolConfig Configs[DisjointPoolMemType::All]; - DisjointPoolAllConfigs(); + DisjointPoolAllConfigs(int trace = 0); }; // Parse optional config parameters of this form: