// file: /data/courses/ece_1111/lectures/current/lecture_13/functs_00.cc // // local include files // #include "example.h" // function: mykernel // // arguments: none // // return: returns void // // This method does nothing. // __global__ void mykernel(void) { // print to stdout // printf("mykernel:: hello world from the GPU!\n"); // exit gracefully // return; } // function: myadd // // arguments: // int* c: (output) result // int* a: (input) first operand // int* b: (input) second operand // // return: returns void // // This method adds two numbers. // __global__ void myadd(int *c, int *a, int *b) { // add the arguments // *c = *a + *b; // exit gracefully // return; } // function: vadd_gpu // // arguments: // int* c: (output) result // int* a: (input) first operand // int* b: (input) second operand // int* N: (input) the vector dimension // // return: returns void // // This method adds two vectors. // __global__ void vadd_gpu(int *c, int *a, int *b, int* N) { // status // printf("... adding two vectors (%d: %d %d) on gpu hardware ...\n", *N, a[0], b[0]); // iterate // for (int i = 0; i < *N; i++) { c[i] = a[i] + b[i]; } // status // printf("... done adding two vectors (%d: %d) on gpu hardware ...\n", *N, c[0]); // exit gracefully // return; }