-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Avoid using heavy API to query single attribution #3179
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
Conversation
src/runtime/cuda/cuda_device_api.cc
Outdated
cudaDeviceProp props; | ||
CUDA_CALL(cudaGetDeviceProperties(&props, ctx.device_id)); | ||
*rv = std::string(props.name); | ||
char name[256]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider directly create a std::string with the corresponding length and resize back to the size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get updated.
1126203
to
05e872c
Compare
src/runtime/cuda/cuda_device_api.cc
Outdated
cudaDeviceProp props; | ||
CUDA_CALL(cudaGetDeviceProperties(&props, ctx.device_id)); | ||
*rv = std::string(props.name); | ||
std::string name(sizeof(cudaDeviceProp::name), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider directly use 256, note that this might cause a problem if cuda driver changes its ABI and change name to a pointer.
src/runtime/cuda/cuda_device_api.cc
Outdated
*rv = std::string(props.name); | ||
std::string name(sizeof(cudaDeviceProp::name), 0); | ||
CUDA_DRIVER_CALL(cuDeviceGetName(&name[0], name.size(), ctx.device_id)); | ||
*rv = std::string(name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name.resize(std::strlen(name.c_str())
*rv = std::move(name);
CUDA_DRIVER_CALL(cuDeviceGetName(&name[0], name.size(), ctx.device_id)); | ||
name.resize(strlen(name.c_str())); | ||
*rv = std::move(name); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Thanks, @ghostplant ! this PR is now merged. |
To fix: Both of 2 queries spent a big stack memory and compute lots of properties unused.