cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
current_context.hpp File Reference
#include "error.hpp"
#include "constants.hpp"
#include "types.hpp"
Include dependency graph for current_context.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::context::current::scoped_override_t
 A RAII-based mechanism for pushing a context onto the context stack for what remains of the current (C++ language) scope - making it the current context - then popping it back when exiting the scope - restoring the stack and the current context to what they had been previously. More...
 

Namespaces

 cuda
 Definitions and functionality wrapping CUDA APIs.
 

Macros

#define CUDA_API_WRAPPERS_CURRENT_CONTEXT_HPP_
 
#define CUDA_CONTEXT_FOR_THIS_SCOPE(_cuda_context)   ::cuda::context::current::scoped_override_t set_context_for_this_scope{ _cuda_context }
 This macro will set the current device for the remainder of the scope in which it is invoked, and will change it back to the previous value when exiting the scope. More...
 

Functions

bool cuda::context::current::exists ()
 Determine whether any CUDA context is current, or whether the context stack is empty/uninitialized.
 
void cuda::context::current::synchronize ()
 Avoid executing any additional instructions on this thread until all work on all streams in the current context has been concluded. More...
 

Macro Definition Documentation

◆ CUDA_CONTEXT_FOR_THIS_SCOPE

#define CUDA_CONTEXT_FOR_THIS_SCOPE (   _cuda_context)    ::cuda::context::current::scoped_override_t set_context_for_this_scope{ _cuda_context }

This macro will set the current device for the remainder of the scope in which it is invoked, and will change it back to the previous value when exiting the scope.

Use it as an opaque command, which does not explicitly expose the variable defined under the hood to effect this behavior.

Function Documentation

◆ synchronize()

void cuda::context::current::synchronize ( )
inline

Avoid executing any additional instructions on this thread until all work on all streams in the current context has been concluded.

Note
The synchronization will occur using the current context's sync_scheduling_policy()