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

Port computational part to GPU #17

Open
noooway opened this issue Dec 12, 2018 · 0 comments
Open

Port computational part to GPU #17

noooway opened this issue Dec 12, 2018 · 0 comments

Comments

@noooway
Copy link

noooway commented Dec 12, 2018

Single GPU should be sufficient for a start.
CUDA can be used.

A general idea is to define pointers in each class that would hold data about that class on GPU, e.g.

class Time_grid {
  public:
    double total_time, current_time;
    double time_step_size;
    double time_save_step;
    double *total_time_gpu, *current_time_gpu;
    double *time_step_size_gpu;
    double *time_step_step_gpu;
   .....

Then define methods that would allocate memory on GPU and transfer data to and from GPU

class Time_grid {
 .....
  public:
    .....
    void allocate_on_gpu();
    void transfer_to_gpu();
    void transfer_from_gpu();
    ......

Then duplicate all computational methods to perform on GPU. Those methods are supposed to call CUDA kernels.

class Time_grid {
 .....
  public:
  .....
  void update_to_next_step();
  void update_to_next_time_step_gpu();
  .....

Finally, it should be necessary to replace all calls to update methods to calls to update_on_gpu methods and perform data transfer from GPU to CPU when saving on disk is required

void Domain::run_pic()
{
    .....
    for ( int i = current_node; i < total_time_iterations; i++ ){
        std::cout << "Time step from " << i << " to " << i+1
                  << " of " << total_time_iterations << std::endl;
        advance_one_time_step_on_gpu();
        transfer_from_gpu_and_write_step_to_save();
    }
.....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant