Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tracing param in disjoint_pool_parser #1172

Merged
merged 2 commits into from
Jan 2, 2024
Merged
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
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