Changes between Initial Version and Version 1 of Implementation_of_CUDA_in_CIVL


Ignore:
Timestamp:
03/16/22 12:40:33 (4 years ago)
Author:
Alex Wilton
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Implementation_of_CUDA_in_CIVL

    v1 v1  
     1= CUDA Overview =
     2== Introduction ==
     3This page describes how we translate CUDA programs into CIVL-C code. Primarily, we focus on how the cuda-civl library is organized and is used in our final translation of a CUDA program. We assume basic knowledge of CUDA concepts such as steams, kernels, blocks, and threads.
     4
     5== The CUDA Context ==
     6cuda-civl provides a structure called `$cuda_context_t` which is meant to house all CUDA information that pertains globally to a CUDA program. As such, our translation only creates one instance of this structure as a global variable simply called `$cuda_current_context`. Currently, the only information that `$cuda_context_t` manages is the set of CUDA streams being used in the program (including the null stream which is present in every program).
     7{{{
     8typedef struct $cuda_context $cuda_context_t;
     9struct $cuda_context {
     10  $cuda_stream_node_t* headNode;
     11  cudaStream_t nullStream;
     12  int numStreams;
     13};
     14}}}
     15`$cuda_stream_node_t` is simply a structure which holds a `cudaStream_t` and a pointer to another `$cuda_stream_node_t`. In other words it is a linked list of `cudaStream_t`'s. In general, we use the pattern in which types of the form `<T>_node_t` are structures representing nodes of a linked list containing type `T`. The streams in this list are the "non-default" or "non-null" CUDA streams meant for asynchronous execution of kernels. The integer `numStreams` represents the size of this list. `nullStream` obviously holds the null stream which is used by default when executing kernels and is executed sequentially. Thus, the number of total streams at any given time of the program is
     16`$cuda_current_context.numStreams + 1`.
     17
     18The way in which these values are initialized, managed, and ultimately destroyed, is discussed later in section '''ADD SECTION REF HERE'''
     19
     20== CUDA Streams ==