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

Use _depenv_s in dpnp/backend on Windows #1452

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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ repos:
rev: v1.3.5
hooks:
- id: clang-format
args: ["-i", "--version=12"]
args: ["-i"]
16 changes: 14 additions & 2 deletions dpnp/backend/src/memory_sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@
static bool use_sycl_device_memory()
{
// TODO need to move all getenv() into common dpnpc place
const char *dpnpc_memtype_device =
getenv("DPNPC_OUTPUT_DPARRAY_USE_MEMORY_DEVICE");
char *dpnpc_memtype_device = nullptr;

#ifdef _WIN32
size_t dpnpc_memtype_device_size = 0;
_dupenv_s(&dpnpc_memtype_device, &dpnpc_memtype_device_size,
"DPNPC_OUTPUT_DPARRAY_USE_MEMORY_DEVICE");
#else
dpnpc_memtype_device =
std::getenv("DPNPC_OUTPUT_DPARRAY_USE_MEMORY_DEVICE");
#endif

if (dpnpc_memtype_device != nullptr) {
#ifdef _WIN32
free(dpnpc_memtype_device);
#endif
return true;
}

Expand Down
17 changes: 15 additions & 2 deletions dpnp/backend/src/verbose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,24 @@ bool is_verbose_mode()
{
if (!_is_verbose_mode_init) {
_is_verbose_mode = false;
const char *env_var = std::getenv("DPNP_VERBOSE");
if (env_var and env_var == std::string("1")) {
char *env_var = nullptr;

#ifdef _WIN32
size_t env_var_size = 0;
_dupenv_s(&env_var, &env_var_size, "DPNP_VERBOSE");
#else
env_var = std::getenv("DPNP_VERBOSE");
#endif

if (env_var && std::string(env_var) == "1") {
_is_verbose_mode = true;
}
_is_verbose_mode_init = true;

#ifdef _WIN32
if (env_var != nullptr)
free(env_var);
#endif
}
return _is_verbose_mode;
}
Expand Down