Help with cgemm

Open forum for general discussions relating to PLASMA.

Help with cgemm

Postby lizoni » Mon Mar 11, 2013 7:12 am

Hello,

I am using the cgemm function and I get wrong results. I think I am doing something wrong with the memory allocation of the matrixes. My code is:
int main(){

PLASMA_Complex32_t *A = (PLASMA_Complex32_t *)malloc(lda*M*(sizeof(PLASMA_Complex32_t*)));
PLASMA_Complex32_t *X = (PLASMA_Complex32_t *)malloc(ldb*N*(sizeof(PLASMA_Complex32_t*)));
PLASMA_Complex32_t *Y = (PLASMA_Complex32_t *)malloc(ldc*N*(sizeof(PLASMA_Complex32_t*)));


/* Check if unable to allocate memory */

if ((!A)||(!X)||(!Y)){
printf("Out of Memory \n ");
return 0;
}

int times,i,j,info;

int cores=1;

/* Plasma Initialization */

info=PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);

for (i=0;i<M;i++)
*Y=0.0;

for (j=0;j<Z;j++){
*A = (float) (5);
}

for (i=0;i<K;i++){
*X = (float) (5);
}

for (times=0;times!=TIMES;times++){


info=PLASMA_cgemm(PlasmaTrans,PlasmaTrans, M, N, K, alpha, A, lda, X, ldb, beta, Y, ldc);

}
if ((info != 0))
printf("-- Error in example ! \n");
else
printf("-- Example successful ! \n");

free(A); free(X); free(Y);
PLASMA_Finalize();

return 0;
}

Could you please help me?
lizoni
 
Posts: 3
Joined: Tue Feb 26, 2013 3:39 pm

Re: Help with cgemm

Postby bhaugen » Mon Mar 11, 2013 11:00 am

It looks like your error is in the allocation of matrix X. When transB = PlasmaTrans the matrix should be allocated with dimensions ldb * K. I hope this helps. -Blake
bhaugen
 
Posts: 1
Joined: Mon Mar 11, 2013 10:47 am

Re: Help with cgemm

Postby lizoni » Thu Mar 21, 2013 6:35 am

Thank you for your reply. I have tried it but I still get wrong results...
lizoni
 
Posts: 3
Joined: Tue Feb 26, 2013 3:39 pm

Re: Help with cgemm

Postby yarkhan » Thu Mar 21, 2013 10:47 am

For the mallocs, try removing the pointer reference (i.e., the star *)
Use
malloc(lda*M*(sizeof(PLASMA_Complex32_t)));
And not
malloc(lda*M*(sizeof(PLASMA_Complex32_t*)));

You were allocating an array of pointers, not an array of data.

Regards,
Asim
yarkhan
 
Posts: 15
Joined: Thu Oct 01, 2009 10:38 am


Return to User discussion

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron