Intel® oneAPI HPC Toolkit
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
2017 Discussions

Need help on memory allocation problem

Dear Sir/Madam,

I am a student from University of Connecticut. I am now using "SGI Altix 3700 BX2 system". The system contains 64 Intel Itanium 2 processors and 64 GB memory. I do C program on it. Now I met some problem on my project(The program can run in personal computer correctly). The problem is memory allocation and it seems caused by memory alignment.

Now I copy part of my program to you (the error part). I do not know I can explain what happened, let me try.

I use this subroutine to allocate a 3D matrix space for my algorithm. While it runs to the line marked by /*error*/, it can run through until i=0, j=20. Then the error information shows up:
"Program received signal SIGSEGV, Segmentation fault.
0x20000000001d00c1 in _int_malloc () from /lib/tls/"

The program is:

double ***AllocMatrix1(short nxl,short nxh, short nyl,short nyh, short nzl,short nzh)
short i,j,k;
double *** m;

m=(double ***) malloc((unsigned) ((nxh-nxl)+1)*sizeof(double**));
if (!m) nrerror("allocation failure 1 in matrix()");
m -= nxl;

for(i=nxl;i<=nxh;i++) {
m=(double **) malloc((unsigned) ((nyh-nyl)+1)*sizeof(double*));
if (!m) nrerror("allocation failure 2 in matrix()");
m -= nyl;

for(j=nyl;j<=nyh;j++) {

/**The problem happened in this loop while j=20, (now i=0),

in this program the maxmum number is nzh=700***/

/*error*/ m=(double *) malloc((unsigned) (nzh-nzl+1)*sizeof(double));
if (!m) nrerror("allocation failure 3 in matrix()");
m -= nzl;

for(k=nzl;k<=nzh;k++) m = 0.0;
return m;

Thank you very much for your help!

Best regards,
0 Kudos
0 Replies