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

[FEA] The libcudf example should show how to use a memory resource #11870

Closed
jrhemstad opened this issue Oct 6, 2022 · 2 comments · Fixed by #11966
Closed

[FEA] The libcudf example should show how to use a memory resource #11870

jrhemstad opened this issue Oct 6, 2022 · 2 comments · Fixed by #11966
Assignees
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.

Comments

@jrhemstad
Copy link
Contributor

jrhemstad commented Oct 6, 2022

Is your feature request related to a problem? Please describe.

Using a memory pool is essential to good performance with libcudf. Today, the example libcudf application doesn't show how to construct an RMM memory resource nor set the current_device_resource.

Describe the solution you'd like

The example should be updated to show constructing a rmm::mr::pool_memory_resource or rmm::mr::cuda_async_memory_resource and setting it as the default via set_current_device_resource

Describe alternatives you've considered
One could argue that this could/should be a separate example, but using a pool resource is fundamental to performance in libcudf and makes sense to be part of the existing and future examples.

@jrhemstad jrhemstad added feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. labels Oct 6, 2022
@davidwendt
Copy link
Contributor

I could add some more comments to the example in #11849
https://github.com/rapidsai/cudf/pull/11849/files#diff-5c4769eb07f9859a4f196ad1fc2105ef1420f1cc645401eb9c4f27c601730cefR70-R74
Do you think that would be enough or do you have something else in mind?

@jrhemstad
Copy link
Contributor Author

Here's what I'm thinking:

int main(int argc, char** argv)
{

  // Construct a memory pool using RAPIDS Memory Manager (RMM) 
  // Using a memory pool for device memory allocations is important for good performance in libcudf
  // Defaults to allocating half of the available GPU memory 
  rmm::mr::pool_memory_resource mr{};

  // Set the pool resource to be used by default for all device memory allocations
  // Note: It is the user's responsibility to ensure the `mr` object stays alive for the duration of it being set as the default
  rmm::mr::set_current_device_resource(&mr);

  // Read data
  auto stock_table_with_metadata = read_csv("4stock_5day.csv");

  // Process
  auto result = average_closing_price(*stock_table_with_metadata.tbl);

  // Write out result
  write_csv(*result, "4stock_5day_avg_close.csv");

  return 0;
}

@davidwendt davidwendt self-assigned this Oct 21, 2022
rapids-bot bot pushed a commit that referenced this issue Oct 25, 2022
Adds the pool memory resource to the libcudf basic example.
Also adds README.md to the strings example and makes some minor fixes to the documentation.

Closes #11870

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Jake Hemstad (https://github.com/jrhemstad)
  - Elias Stehle (https://github.com/elstehle)

URL: #11966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants