walberla::gpu::ParallelStreams Class Reference

Detailed Description

Helper class to run CUDA/HIP operations on parallel streams.

This class introduces "side streams" that overlap with one "main stream". In a parallel section, multiple kernels (or other CUDA/HIP operations) are scheduled to the streams. The first "run" is scheduled on the main stream all subsequent operations on the side streams. The passed priority affects only the side streams. When the parallel section goes out of scope the side streams are synchronized to the main stream via CUDA/HIP events.

Example:

{
// new scope for the parallel section
ParallelSection sec = streams.parallelSection( mainGPUStream );
sec.run([&] ( gpuStream_t sideStream ) {
// run something on the side stream
});
// after the parallel section goes out of scope the side streams are synchronized to the main stream
}

#include <ParallelStreams.h>

Public Member Functions

 ParallelStreams (int priority=0)
 
ParallelSection parallelSection (gpuStream_t stream)
 
void setStreamPriority (int priority)
 

Private Member Functions

void ensureSize (uint_t size)
 

Private Attributes

std::vector< StreamRAIIsideStreams_
 
std::vector< EventRAIIevents_
 
EventRAII mainEvent_
 
int streamPriority_
 

Friends

class ParallelSection
 

Constructor & Destructor Documentation

◆ ParallelStreams()

walberla::gpu::ParallelStreams::ParallelStreams ( int  priority = 0)

Member Function Documentation

◆ ensureSize()

void walberla::gpu::ParallelStreams::ensureSize ( uint_t  size)
private

◆ parallelSection()

ParallelSection walberla::gpu::ParallelStreams::parallelSection ( gpuStream_t  stream)

◆ setStreamPriority()

void walberla::gpu::ParallelStreams::setStreamPriority ( int  priority)

Friends And Related Function Documentation

◆ ParallelSection

friend class ParallelSection
friend

Member Data Documentation

◆ events_

std::vector<EventRAII> walberla::gpu::ParallelStreams::events_
private

◆ mainEvent_

EventRAII walberla::gpu::ParallelStreams::mainEvent_
private

◆ sideStreams_

std::vector<StreamRAII> walberla::gpu::ParallelStreams::sideStreams_
private

◆ streamPriority_

int walberla::gpu::ParallelStreams::streamPriority_
private

The documentation for this class was generated from the following files:
friend class ParallelSection
Definition: ParallelStreams.h:89
ParallelStreams(int priority=0)
Definition: ParallelStreams.cpp:98