Specification-File

This section will provide an example specification-file and implementation, implementing a simple 3-step algorithm, assuming the existence of two vectors, vec1 and vec2:
  1. Multiply vec1 and vec2 by the parameter m1.
  2. Add the two vectors together, and store the result in vec3.
  3. Multiply vec3 by another parameter m2.
  4. Calculate the sum of vec3.
These three steps can easily be factored into one, but for the sake of illustration, they will be kept seperately. The input vectors vec1 and vec2 will be stored in some file, and will serve as the input of our algorithm. The specification-file can now be defined as follows:
\begin{lstlisting}
/* spec.hycuda */
\par
// Directives
float m1;
float m2;
\pa...
...2: vec1 (r), vec2 (r), vec3 (w)
sumVec3: vec3 (r), sum (w)
\par
\end{lstlisting}
We have chosen for the default memory-allocation scheme (dynamic), because we cannot know in advance how large the vectors in the file are. Another option would have been to set a maximum vector size, and check if vectorSize is within this maximum. However, because we only process one run of data, the dynamic scheme will not cause any unnecessary overhead.

To generate the framework, call HyCuda from the commandline:

 $ hycuda spec.hycuda -m



Joren Heit 2013-12-17