| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /* This program is valid, whether or not StarPU's GCC plug-in
- is being used. */
- #include <stdlib.h>
- /* The attribute below is ignored when GCC is not used. */
- static void matmul (const float *A, const float *B, float * C,
- unsigned nx, unsigned ny, unsigned nz)
- __attribute__ ((task));
- static void
- matmul (const float *A, const float *B, float * C,
- unsigned nx, unsigned ny, unsigned nz)
- {
- /* Code of the CPU kernel here... */
- }
- #ifdef STARPU_GCC_PLUGIN
- /* Optional OpenCL task implementation. */
- static void matmul_opencl (const float *A, const float *B, float * C,
- unsigned nx, unsigned ny, unsigned nz)
- __attribute__ ((task_implementation ("opencl", matmul)));
- static void
- matmul_opencl (const float *A, const float *B, float * C,
- unsigned nx, unsigned ny, unsigned nz)
- {
- /* Code that invokes the OpenCL kernel here... */
- }
- #endif
- int
- main (int argc, char *argv[])
- {
- /* The pragmas below are simply ignored when StarPU-GCC
- is not used. */
- #pragma starpu initialize
- float A[123][42][7], B[123][42][7], C[123][42][7];
- #pragma starpu register A
- #pragma starpu register B
- #pragma starpu register C
- /* When StarPU-GCC is used, the call below is asynchronous;
- otherwise, it is synchronous. */
- matmul ((float *) A, (float *) B, (float *) C, 123, 42, 7);
- #pragma starpu wait
- #pragma starpu shutdown
- return EXIT_SUCCESS;
- }
|