Thursday, May 15, 2014

Example codes for our book

Erratum

We realized that there is an error in the textbook example in Chapter 2.5 (Simple Vector Addition Using CUDA in page 28).

Errorneous code example (AddVectors.cu)

#include "AddVectors.h"
#include "mex.h"

__global__ void addVectorsMask(float* A, float* B, float* C, int size)
{
int i = blockIdx.x;
if(i >= size)
return;

C[i] = A[i] +B[i];
}

Since this is the .cu file, we don't need the "mex.h" file.
Actually we already corrected in our example codes (downloaded from the publisher's website), but we didn't delete it in our manuscript by mistake.

After fix (AddVectors.cu):

#include "AddVectors.h"
// #include "mex.h"

__global__ void addVectorsMask(float* A, float* B, float* C, int size)
{
int i = blockIdx.x;
if(i >= size)
return;

C[i] = A[i] +B[i];
}

Block out or delete the line: #include "mex.h"

Thank you and appologize for your convenience.

Jung W. Suh