Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:26

0001 #pragma once
0002 
0003 /**
0004 NP_future.h
0005 ============
0006 
0007 General pattern of async functions::
0008 
0009     // Inside every async function:
0010     cudaStreamWaitEvent(my_stream, input.ready, 0);   // consume input
0011     // ... do work ...
0012     cudaEventRecord(output.ready, my_stream);         // produce output
0013     cudaEventDestroy(input.ready);                    // safe cleanup
0014     return output;                                    // ONE event
0015 
0016 
0017 **/
0018 
0019 
0020 
0021 struct NP_future
0022 {
0023     NP*          arr   = nullptr;
0024     cudaEvent_t  ready = nullptr;
0025 
0026     void wait(cudaStream_t stream) const;
0027 };
0028 
0029 inline void NP_future::wait(cudaStream_t stream) const
0030 {
0031     if (ready && stream) {
0032         cudaStreamWaitEvent(stream, ready, 0);
0033     }
0034 }
0035 
0036 
0037 
0038