Skip to content

Commit

Permalink
Merge pull request oneapi-src#1172 from igchor/fix_tracing_pool
Browse files Browse the repository at this point in the history
Fix tracing param in disjoint_pool_parser
  • Loading branch information
igchor authored Jan 2, 2024
2 parents fb83446 + 8ee650d commit 810a577
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
18 changes: 9 additions & 9 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ 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");
const char *PoolTraceVal = PoolUrTraceVal
? PoolUrTraceVal
: (PoolPiTraceVal ? PoolPiTraceVal : nullptr);

bool PoolTrace = false;
int PoolTrace = 0;
if (PoolTraceVal != nullptr) {
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);
}

Expand Down
8 changes: 6 additions & 2 deletions source/common/umf_pools/disjoint_pool_config_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -58,10 +58,14 @@ 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,
bool trace) {
int trace) {
DisjointPoolAllConfigs AllConfigs;

// TODO: replace with UR ENV var parser and avoid creating a copy of 'config'
Expand Down
4 changes: 2 additions & 2 deletions source/common/umf_pools/disjoint_pool_config_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit 810a577

Please sign in to comment.