Dim3 dimgridgridwidth grid dimensions dim3

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: erThread); N = ValuesPerThread * GridWidth * BlockWidth; size_t size = N * sizeof(float); // number of bytes for a vector. dim3 dimGrid(GridWidth); // grid dimensions dim3 dimBlock(BlockWidth); // thread block dimensions host: allocate // Allocate input vectors h_A and h_B in host memory h_A = (float*)malloc(size); if (h_A == 0) Cleanup(false); h_B = (float*)malloc(size); if (h_B == 0) Cleanup(false); h_C = (float*)malloc(size); if (h_C == 0) Cleanup(false); // Allocate vectors in device memory. cudaError_t error; error = cudaMalloc((void**)&d_A, size); if (error != cudaSuccess) Cleanup(false); error = cudaMalloc((void**)&d_B, size); if (error != cudaSuccess) Cleanup(false); error = cudaMalloc((void**)&d_C, size); if (error != cudaSuccess) Cleanup(false); // intialize host vectors h_A and h_B host: copy host data to device invoke kernel on device copy devi...
View Full Document

This note was uploaded on 02/12/2014 for the course CS 475 taught by Professor Staff during the Fall '08 term at Colorado State.

Ask a homework question - tutors are online