Taskflow  3.2.0-Master-Branch
Loading...
Searching...
No Matches
cuda_execution_policy.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "cuda_error.hpp"
4
10namespace tf {
11
28template<unsigned NT, unsigned VT>
30
31 static_assert(is_pow2(NT), "max # threads per block must be a power of two");
32
33 public:
34
36 const static unsigned nt = NT;
37
39 const static unsigned vt = VT;
40
42 const static unsigned nv = NT*VT;
43
48
52 explicit cudaExecutionPolicy(cudaStream_t s) : _stream{s} {}
53
57 cudaStream_t stream() noexcept { return _stream; };
58
62 void stream(cudaStream_t stream) noexcept { _stream = stream; }
63
64 private:
65
66 cudaStream_t _stream {0};
67};
68
73
74} // end of namespace tf -----------------------------------------------------
75
76
77
class to define execution policy for CUDA standard algorithms
Definition cuda_execution_policy.hpp:29
cudaStream_t stream() noexcept
queries the associated stream
Definition cuda_execution_policy.hpp:57
void stream(cudaStream_t stream) noexcept
assigns a stream
Definition cuda_execution_policy.hpp:62
static const unsigned nv
static constant for getting the number of elements to process per block
Definition cuda_execution_policy.hpp:42
static const unsigned vt
static constant for getting the number of work units per thread
Definition cuda_execution_policy.hpp:39
static const unsigned nt
static constant for getting the number of threads per block
Definition cuda_execution_policy.hpp:36
cudaExecutionPolicy(cudaStream_t s)
constructs an execution policy object with the given stream
Definition cuda_execution_policy.hpp:52
cudaExecutionPolicy()=default
constructs an execution policy object with default stream
taskflow namespace
Definition small_vector.hpp:27