ARPACK OMP

General OpenMP discussion

ARPACK OMP

Postby gobboshow » Tue Sep 23, 2008 1:52 pm

i'm new and have a big problem whith OpenMP. i tried to use it to parallelized the calling of ARPACK function, but the error tell me that the input are wrong!
this is a problem of ARPACK? :(
gobboshow
 
Posts: 2
Joined: Tue Sep 23, 2008 1:21 pm

Re: ARPACK OMP

Postby ejd » Tue Sep 23, 2008 4:18 pm

Since you haven't given me much information, it is hard to say what the problem is. However, looking at the ARPACK homepage only shows a distributed memory parallel version of the package. Therefore, I would guess that they aren't supporting OpenMP and that is the problem.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: ARPACK OMP

Postby gobboshow » Wed Sep 24, 2008 1:34 am

i must parallelize the calling of the follow function. i have 8 cpu and want to call main_center with 8 different MOD and 8 different shift, but m,n and Opt are the same for every thread.
M_sI_inv_sparse calculate the function y=Ax.
what do i do?
the error is: Could not build an Arnoldi factorization. User input error highly likely. Please check
actual array dimensions and layout. IPARAM(5) returns the size of the current Arnoldi factorization

with a thread all is good... from 2 thread this is the situation.

i think:
#pragma omp parallel
{
ID=omp_get_thread_num();
CFH=main_center(MOD[ID],m,n,shift[ID],Opt);
}

is malloc a problem?
what fix private and shared?

Here start the function.

#include<stdio.h>
#include<stdlib.h>
#include "depcode.h"
#include"M_sI_inv_sparse.h"
#include "M_TimeX.h"
#include"structure.h"
#include<arpack.h>
#include<omp.h>

struct CFHs main_center(struct MODs MOD, int n, int m, Complex16 shift, struct OpS Opt)
{

struct CFHs CFH;
int uno=1,idmax,idmin;
double munod[2],unod=1;
Complex16 rad[2];

munod[0]=-1; munod[1]=0;

//definizione variabili dnaupd
int N,ido,nev,ldv,iparam[11],ipntr[14],info,lworkl,ncv;
char bmat,which[2];
double tol;
double* rwork;
Complex16* resid, *v, *workd, *workl;

//inizializzazione dei parametri
ido=0; bmat='I'; N = 2*n; nev=Opt.nummaxeigs, tol=Opt.tol; ncv=15*nev;
ldv=N; lworkl=3*ncv*ncv+5*ncv; info=0;
which[0]='L';which[1]='M';
iparam[0]=1;
iparam[2]=Opt.MaxIterations;
iparam[6]=3;

//creazione vettori dnaupd
rwork=(double*)malloc(sizeof(double)*ncv);
resid=(Complex16*)malloc(sizeof(Complex16)*N);
v=(Complex16*)malloc(sizeof(Complex16)*ldv*ncv);
workd=(Complex16*)malloc(sizeof(Complex16)*3*N);
workl=(Complex16*)malloc(sizeof(Complex16)*lworkl);

//definizione variabili zneupd
int rvec,ldz=N;
int* select;
char howmny='A';
double sigma[2];
Complex16* d, *workev, *z;

sigma[0]=0;
sigma[1]=shift.imag;

//creazione vettori dneupd
d=(Complex16*)malloc(sizeof(Complex16)*(nev+1));
workev=(Complex16*)malloc(sizeof(Complex16)*2*ncv);
select=(int*)malloc(sizeof(int)*ncv);
z=(Complex16*)malloc(sizeof(Complex16)*nev*N);

Complex16* y;
y=(Complex16*)malloc(sizeof(Complex16)*N);

//inizio calcolo autovalori
do{
znaupd_(&ido,&bmat,&N,which,&nev,&tol,resid,&ncv,v,&ldv,iparam,ipntr,workd,workl,&lworkl,rwork,&info);
if (ido==1 || ido==-1)
{
M_sI_inv_sparse(MOD,workd+ipntr[0]-1, n, m, &y);
zcopy( &N, y, &uno, workd+ipntr[1]-1, &uno);
}
}while(ido==1 || ido==-1);
free(y);
//estrazione autovalori e autovettori
if(info==0)
{
rvec = 0;
zneupd_(&rvec,&howmny,select,d,z,&ldz,(Complex16*)sigma,workev,&bmat,&N,which,&nev,&tol,resid,&ncv,v,&ldv,iparam,ipntr,workd,workl,&lworkl,rwork,&info);
}
else printf("Fatal Error occours in the eigenvalues routine. Error number: %d\n",info);

zcopy(&uno,(Complex16*)sigma,&uno,&CFH.shift,&uno);
zcopy(&iparam[4],d,&uno,CFH.eig,&uno);
idmax=izamax(&iparam[4],d, &uno);
idmin=izamin(&iparam[4],d, &uno);
rad[0]=d[idmax-1];
rad[1]=d[idmin-1];
zaxpy(&uno, (Complex16*)munod, &shift, &uno, &rad[0], &uno);
zaxpy(&uno, (Complex16*)munod, &shift, &uno, &rad[1], &uno);
rad[0].imag=dznrm2(&uno, &rad[0], &uno);
rad[1].imag=dznrm2(&uno, &rad[1], &uno);
if(rad[0].imag>rad[1].imag) CFH.radius=rad[0].imag;
else CFH.radius=rad[1].imag;
CFH.lbin=CFH.shift.imag+CFH.radius;
CFH.ubin=CFH.shift.imag-CFH.radius;

free(rwork);free(resid);free(v);
free(workd);free(workl);free(d);
free(workev); free(select); free(z);

return CFH;
}
gobboshow
 
Posts: 2
Joined: Tue Sep 23, 2008 1:21 pm


Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot], ftinetti and 10 guests

cron