seg fault when allocating 1D array or stream

Discussion created by FangQ on Mar 15, 2009
Latest reply on Mar 15, 2009 by gaurav.garg
is this related to the maximum stream size?

I am running a Monte-Carlo simulation using Brook+. The code seems to be working ok, except I can not use larger domains. My machine has a Radeon 4650 video card with 512M memory. I compiled the program using the newly released SDK 1.4 on a Ubuntu 8.10 desktop.

The following code contains the minimum lines to replicate the problem:

[code]#include <stdio.h>

// dimension of the target domain
#define DIMX 128
#define DIMY 128
#define DIMZ 128
#define MAX_PROP   256

int main (int argc, char *argv[]) {
     int    nthread=1024;   /*the default total thread number*/

     // comment the following two lines will save it from crash
     uchar  media[DIMXYZ];
     float  field[DIMXYZ];

     uchar  gmedia<DIMXYZ>;
     float  gfield<DIMXYZ>;
     float4 gPpos<nthread>;
     float4 gPdir<nthread>;
     float3 gPlen<nthread>;
     float3 gPseed<nthread>;
     float4 gPpos2<nthread>;
     float4 gPdir2<nthread>;
     float3 gPlen2<nthread>;
     float3 gPseed2<nthread>;
     float3 gproperty<MAX_PROP>;

     return 0;

Let DIMX=DIMY=DIMZ=d, and when d<=118, the program runs ok. But as long as d>118, the program will crash with "Segmentation fault".

If I comment out the two array definition, i.e. "uchar  media[DIMXYZ];" and "float  field[DIMXYZ];" then it does not crash any more.

It is strange that if you count the total stream memory, its only around 10M, far less than the memory on the video card. Is this a bug of the compiler? or I missed something in the definition?