Hello!
I am running Windows 7 64bit, Visual Studio 2010 Professional, and a GTS 250. I am using CUDA 4.0 and have it targeted.
I am starting to go through “CUDA By Example: An Introduction to General-Purpose GPU Programming” and I can’t get past the final example in Chapter 4.
I am getting this error: “C:\Users\brickwalls\Desktop\glut-3.7.6-bin-32and64\glut-3.7.6-bin\glut64.lib(5): fatal error C1004: unexpected end-of-file found” when I go to compile.
////PAGES 41 TO 44 IN CUDA BOOK
#include <book.h>
#include <cpu_bitmap.h>
#include "C:\Users\brickwalls\Desktop\glut-3.7.6-bin-32and64\glut-3.7.6-bin\glut64.lib"
#define DIM 1000
struct cuComplex {
float r;
float i;
cuComplex( float a, float b ) : r(a), i(b) {}
float magnitude2(void) {return r*r + i*i;}
cuComplex operator* (const cuComplex& a) {
return cuComplex(r*a.r - i*a.i,i*a.r + r*a.i);
}
cuComplex operator+ (const cuComplex& a){
return cuComplex(r+a.r,i+a.i);
}
};
int julia( int x, int y) {
const float scale = 1.5;
float jx = scale * (float) (DIM/2 - x)/(DIM/2);
float jy = scale * (float) (DIM/2 - y)/(DIM/2);
cuComplex c(-0.8, 0.156);
cuComplex a(jx,jy);
int i = 0;
for (i=0; i<200; i++) {
a = a * a + c;
if (a.magnitude2() > 1000)
return 0;
}
return 1;
}
void kernel( unsigned char *ptr ){
for (int y=0; y<DIM; y++) {
for (int x=0; x<DIM; x++) {
int offset = x + y * DIM;
int juliaValue = julia( x, y );
ptr[offset*4 + 0] = 255 * juliaValue;
ptr[offset*4 + 1] = 0;
ptr[offset*4 + 2] = 0;
ptr[offset*4 + 3] = 255;
}
}
}
int main (void) {
CPUBitmap bitmap (DIM, DIM) ;
unsigned char *ptr = bitmap.get_ptr();
kernel (ptr);
bitmap.display_and_exit();
}
Anyone having similiar issues?
Thank you!