Skip to content

Conversation

ghostplant
Copy link
Contributor

To fix: Both of 2 queries spent a big stack memory and compute lots of properties unused.

cudaDeviceProp props;
CUDA_CALL(cudaGetDeviceProperties(&props, ctx.device_id));
*rv = std::string(props.name);
char name[256];
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get updated.

@ghostplant ghostplant force-pushed the avoid_prop branch 2 times, most recently from 1126203 to 05e872c Compare May 13, 2019 04:07
cudaDeviceProp props;
CUDA_CALL(cudaGetDeviceProperties(&props, ctx.device_id));
*rv = std::string(props.name);
std::string name(sizeof(cudaDeviceProp::name), 0);
Copy link
Member

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.

*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());
Copy link
Member

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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@tqchen tqchen merged commit 20ddd2b into apache:master May 14, 2019
@tqchen
Copy link
Member

tqchen commented May 14, 2019

Thanks, @ghostplant ! this PR is now merged.

wweic pushed a commit to wweic/tvm that referenced this pull request Jun 26, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants