Commit 46674fa8 authored by Fabio Roberto Vitello's avatar Fabio Roberto Vitello
Browse files

moved nthread init

OmpSs compiler fail if nthreads is initialized in util.h
parent f027bd67
Loading
Loading
Loading
Loading
+10 −79
Original line number Original line Diff line number Diff line
@@ -39,9 +39,12 @@ void aprod(int mode, long int m, long int n, double *vVect, double *knownTerms,
    nproc = comlsqr.nproc;
    nproc = comlsqr.nproc;
    mapNcoeff = comlsqr.mapNcoeff;
    mapNcoeff = comlsqr.mapNcoeff;
    mapNoss = comlsqr.mapNoss;
    mapNoss = comlsqr.mapNoss;
    if (comlsqr.nthreads == NULL)
        comlsqr.nthreads=1;
        
    nthreads = comlsqr.nthreads;
    nthreads = comlsqr.nthreads;
    ntasks= comlsqr.ntasks;
    
    
    ntasks= comlsqr.ntasks;
    mapForThread = comlsqr.mapForThread;
    mapForThread = comlsqr.mapForThread;
    int multMI = comlsqr.multMI;
    int multMI = comlsqr.multMI;
    long nparam = comlsqr.parOss;
    long nparam = comlsqr.parOss;
@@ -72,10 +75,8 @@ void aprod(int mode, long int m, long int n, double *vVect, double *knownTerms,
    long offsetInstrParam = comlsqr.offsetInstrParam;
    long offsetInstrParam = comlsqr.offsetInstrParam;
    long offsetGlobParam = comlsqr.offsetGlobParam;
    long offsetGlobParam = comlsqr.offsetGlobParam;



    tid = 0;
    tid = 0;



    if (mode != 1 && mode != 2)
    if (mode != 1 && mode != 2)
    {
    {
        printf("ERROR: Invalid mode=%d in aprod function\n", mode);
        printf("ERROR: Invalid mode=%d in aprod function\n", mode);
@@ -86,15 +87,13 @@ void aprod(int mode, long int m, long int n, double *vVect, double *knownTerms,
    myid = comlsqr.myid;
    myid = comlsqr.myid;
    if (mode == 1)
    if (mode == 1)
    {
    {
        
        
        time_t startTime = time(NULL);
        time_t startTime = time(NULL);
        {
            myid = comlsqr.myid;
        
        
        myid = comlsqr.myid;


        if (comlsqr.itn == 1 && debugMode)
        if (comlsqr.itn == 1 && debugMode)
            printf("PE=%d Aprod1 OpenMP num of threads =%d from thread =%d icycle=%ld  comlsqr.itn=%d\n", myid, nthreads, tid, i, comlsqr.itn);
            printf("PE=%d Aprod1 OpenMP num of threads =%d from thread =%d icycle=%ld  comlsqr.itn=%d\n", myid, nthreads, tid, i, comlsqr.itn);
            
            long miValAstro = 0;
            long miValAstro = 0;
            long miValAtt = 0;
            long miValAtt = 0;
            long jstartAtt = 0;
            long jstartAtt = 0;
@@ -113,83 +112,15 @@ void aprod(int mode, long int m, long int n, double *vVect, double *knownTerms,
            int nGlobVal = nAstroPSolved + nAttP + nInstrPSolved;
            int nGlobVal = nAstroPSolved + nAttP + nInstrPSolved;
            jstartAstro = miValAstro - offLocalAstro;
            jstartAstro = miValAstro - offLocalAstro;
            
            
            
            for(int nt=0; nt < ntasks; nt++ )
            for(int nt=0; nt < ntasks; nt++ )
            {
            {
                #pragma omp task label(mode1)
                #pragma omp task label(mode1)
                {
                {
                    for (long ix = mapForThread[nt][0]; ix < mapForThread[nt][2]; ix++)  //FUNZIONE DA FARE
                    for (long ix = mapForThread[nt][0]; ix < mapForThread[nt][2]; ix++)  //FUNZIONE DA FARE
                    {
                    {

/*================= INIZIO
                        sum = 0.;   // FARE UNA FUNZIONE CHIAMATA NEL CICLO FOR
                        /////////////////////////////////////////////////////
                        /// Mode 1 Astrometric Sect
                        if (nAstroPSolved)
                        {

                            lset = ix * nparam;
                            if (matrixIndex[multMI * ix] != miValAstro)
                            {
                                miValAstro = matrixIndex[multMI * ix];
                                jstartAstro = miValAstro - offLocalAstro;
                            }
                            for (long jx = jstartAstro; jx < jstartAstro + nAstroPSolved; jx++)
                            {
                                sum = sum + systemMatrix[lset] * vVect[jx];
                                lset++;
                            }
                        }
                        //////////////////////////////////////////////////////
                        /// Mode 1 Attitude Sect
                        if (nAttP)
                        {
                            lset = ix * nparam + nAstroPSolved;
                            miValAtt = matrixIndex[multMI * ix + (multMI - 1)];
                            for (int nax = 0; nax < nAttAxes; nax++)
                            {
                                jstartAtt = miValAtt + offLocalAtt + nax * nDegFreedomAtt;
                                for (long inpax = jstartAtt; inpax < jstartAtt + nAttParAxis; inpax++)
                                {
                                    sum = sum + systemMatrix[lset] * vVect[inpax];
                                    lset++;
                                }
                            }
                        }
                        //////////////////////////////////////////////////////
                        /// Mode 1 Instrument Sect
                        if (nInstrPSolved)
                        {

                            lset = ix * nparam + nInstrVal;
                            long iiVal = ix * nInstrPSolved;
                            for (int inInstr = 0; inInstr < nInstrPSolved; inInstr++)
                            {
                                ixInstr = offLocalInstr + instrCol[iiVal + inInstr];
                                sum = sum + systemMatrix[lset] * vVect[ixInstr];
                                lset++;
                            }
                        }
                        //////////////////////////////////////////////////////
                        /// Mode 1 Global sect
                        if (nGlobP)
                        {
                            lset = ix * nparam + nGlobVal;
                            for (long inGlob = offLocalGlob; inGlob < offLocalGlob + nGlobP; inGlob++)
                            {
                                sum = sum + systemMatrix[lset] * vVect[inGlob];
                                lset++;
                            }
                        }
                        //////////////////////////////////////////////////////
                       // knownTerms[ix] += sum;
================ FINE */

                        knownTerms[ix] += aprodM1Obs(ix,comlsqr, vVect, systemMatrix, matrixIndex, instrCol);
                        knownTerms[ix] += aprodM1Obs(ix,comlsqr, vVect, systemMatrix, matrixIndex, instrCol);

                    } //for ix
                    } //for ix
                }
                }

            }
            }


            /// Mode 1 ExtConstr
            /// Mode 1 ExtConstr
@@ -266,7 +197,7 @@ void aprod(int mode, long int m, long int n, double *vVect, double *knownTerms,
                }
                }
            }
            }
            //////////////////////////////////////////////////////
            //////////////////////////////////////////////////////
        } //pragma

        *ompSec += time(NULL) - startTime;
        *ompSec += time(NULL) - startTime;
        if (comlsqr.itn <= 2 && (myid == 0 || myid == nproc - 1 || debugMode == 1))
        if (comlsqr.itn <= 2 && (myid == 0 || myid == nproc - 1 || debugMode == 1))
            printf("PE=%d AprodTiming: mode=1  OmpSec=%ld\n", myid, time(NULL) - startTime);
            printf("PE=%d AprodTiming: mode=1  OmpSec=%ld\n", myid, time(NULL) - startTime);
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ struct comData {
	int timeCPR, timeLimit, itnCPR,itnCPRstop,itnCPRend, itnLimit,itn,noCPR;
	int timeCPR, timeLimit, itnCPR,itnCPRstop,itnCPRend, itnLimit,itn,noCPR;
    long offsetCMag,offsetCnu,offsetCdelta_eta,offsetCDelta_eta_1,offsetCDelta_eta_2;
    long offsetCMag,offsetCnu,offsetCdelta_eta,offsetCDelta_eta_1,offsetCDelta_eta_2;
    long offsetCDelta_eta_3,offsetCdelta_zeta,offsetCDelta_zeta_1,offsetCDelta_zeta_2;
    long offsetCDelta_eta_3,offsetCdelta_zeta,offsetCDelta_zeta_1,offsetCDelta_zeta_2;
	int nthreads=1;
	int nthreads;
	int ntasks;
	int ntasks;
	long **mapForThread;
	long **mapForThread;
	int nSubsetAtt, nSubsetInstr;
	int nSubsetAtt, nSubsetInstr;