source: CIVL/examples/cuda/undefined_kernel.cu@ a389857

main test-branch
Last change on this file since a389857 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 685 bytes
Line 
1#include <civlc.cvh>
2#include <stdlib.h>
3#include <cuda.h>
4
5$input int N = 3;
6$assume (N >= 1);
7
8$input int DATA[N];
9
10$input int THREADS_PER_BLOCK = 2;
11$input int NUM_BLOCKS = 2;
12
13__global__ void test_kernel(int* data, int n);
14
15int main ()
16{
17 // allocate and init two data arrays
18 int* data = (int*) malloc(N * sizeof(int));
19 for (int i = 0; i < N; i++) {
20 data[i] = DATA[i];
21 }
22
23 int* d_data;
24 cudaMalloc((void**) &d_data, N * sizeof(int));
25 cudaMemcpy(d_data, data, N * sizeof(int), cudaMemcpyHostToDevice);
26
27 test_kernel<<<NUM_BLOCKS, THREADS_PER_BLOCK>>>(d_data, N);
28
29 cudaMemcpy(data, d_data, N * sizeof(int), cudaMemcpyDeviceToHost);
30 cudaFree(d_data);
31 return 0;
32}
Note: See TracBrowser for help on using the repository browser.