NVCC .cu compilation problem Getting a bus error after compiling a .cu file with NVCC

Hi everyone,

I wonder if anybody could help me with my current dilemma. I’m stuck so any hints or help will be appreciated.

I have the following part of the code w/c I’ve isolated as the cause of problem:

//START of loadMatrixFile function

void loadMatrixFile( char *filename, int *array, int cols, int rows ) {

        //assumes space separate integer values e.g. -1 23 4 -56 6 77 i.e. in row-major order

        int x, y, *dummy;

        FILE *matFile = fopen( filename, "r" );

        if ( matFile == 0 ){

                printf( "\n could not open file %s \n", filename );

        }

        else{

                y = 1;

                int offset = 4;

                fscanf( matFile, "%d", &x );

                while( !feof( matFile ) && y <  rows * cols + offset ) {

                        if ( y < offset ){

                                fscanf( matFile, "%d", &x );

                                printf( " A: y = %d x = %d \n ", y, x );

                        }

                        else {

                                fscanf( matFile, "%d", &dummy[ y - 4 ] );

                                //fscanf( matFile, "%d", &x );

                                //printf( " B: y = %d x = %d \n", y, x );

                                printf( " B: y = %d dummy[ z ] = %d \n", y, dummy[ y - 4 ] );

                        }

                        y++;

                } 

        }

        fclose( matFile ); 

}

if I compile it with nvcc I don’t get any errors. If I do run it:

./mulMatrix MatA MatB

(assuming you have a text file with integer values separated by spaces as input files e.g. MatA MatB in this case)

I get:

./mulMatrix MatA MatB 

 A: y = 1 x = 3 

  A: y = 2 x = 1 

  A: y = 3 x = 1 

Bus error

That is, the fscanf in my code seems to be causing (or is a part of the cause) of the Bus error. I only get to my If, but not to my Else statement.

The details of my iMac are:

uname -a

Darwin theorylabs-P-System-iMac.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

Running Mac OS X 10.5.8 (Intel Core2Duo)

And using CUDA version 3.2.17.

Is there a bug in this version of CUDA for Mac perhaps?

Attached is the entire .cu source code.
mulMatrix.cu (5.43 KB)

You are using [font=“Courier New”]dummy[/font] uninitialized.