Unified-memory stream attachment (advisory in one address space)#
Defined in code/simulator.h.
This page documents 4 symbols: 3 macros, 1 functions.
Macros#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
Expands to |
sim only |
simulator.h:2465 |
|
|
Expands to |
sim only |
simulator.h:2468 |
|
|
Expands to |
sim only |
simulator.h:2471 |
Functions#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
sim only |
simulator.h:2473 |
Examples#
Code from the repository’s example corpus (code\*.cu); the highlighted line is the call site. These blocks are what the View links above open.
cudaStreamAttachMemAsync (test_web_cs_um_streams.cu:84)
74 result[i] *= beta;
75 for (int j = 0; j < n; j++) result[i] += alpha * A[i * n + j] * x[j];
76 }
77}
78
79// Run one task: small ones on the host, large ones through cuBLAS on a stream.
80template <typename T>
81static void execute(Task<T>& t, cublasHandle_t* handle, cudaStream_t* stream, int tid) {
82 if (t.size < 100) {
83 std::printf("Task [%u], thread [%d] executing on host (%u)\n", t.id, tid, t.size);
84 check(cudaStreamAttachMemAsync(stream[0], t.data, 0, cudaMemAttachHost), "attach data");
85 check(cudaStreamAttachMemAsync(stream[0], t.vector, 0, cudaMemAttachHost), "attach vector");
86 check(cudaStreamAttachMemAsync(stream[0], t.result, 0, cudaMemAttachHost), "attach result");
87 check(cudaStreamSynchronize(stream[0]), "cudaStreamSynchronize");
88 gemv(int(t.size), int(t.size), T(1), t.data, t.vector, T(0), t.result);
89 } else {
90 std::printf("Task [%u], thread [%d] executing on device (%u)\n", t.id, tid, t.size);
91 const double one = 1.0, zero = 0.0;
92 cublasSetStream(handle[tid + 1], stream[tid + 1]);
93 check(cudaStreamAttachMemAsync(stream[tid + 1], t.data, 0, cudaMemAttachSingle), "attach data");
94 check(cudaStreamAttachMemAsync(stream[tid + 1], t.vector, 0, cudaMemAttachSingle), "attach vector");
95 check(cudaStreamAttachMemAsync(stream[tid + 1], t.result, 0, cudaMemAttachSingle), "attach result");