/* --------------------------------------------- simplest initialization method if entries != NULL the object does not own the entries, it just points to the entries base address else if size > 0 the object will own the entries, it allocates a vector of size doubles's. else nothing happens endif created -- 96aug28, cca --------------------------------------------- */ void DV_init ( DV *dv, int size, double *entries ) { if ( dv == NULL || size < 0 ) { fprintf(stderr, "\n fatal error in DV_init(%p,%d,%p)" "\n bad input\n", dv, size, entries) ; spoolesFatal(); } /* -------------- clear any data -------------- */ DV_clearData(dv) ; /* ----------------------------- set the size and maximum size ----------------------------- */ dv->maxsize = dv->size = size ; /* ------------------------- set vector and owner flag ------------------------- */ if ( entries != NULL ) { dv->owned = 0 ; dv->vec = entries ; } else if ( size > 0 ) { dv->owned = 1 ; /* dv->vec = DVinit(size, 0.0) ; */ dv->vec = DVinit2(size) ; } return ; }
/* ------------------------- total initializion method created -- 95oct06, cca ------------------------- */ void DV_init2 ( DV *dv, int size, int maxsize, int owned, double *vec ) { /* --------------- check the input --------------- */ if ( dv == NULL ) { fprintf(stderr, "\n fatal error in DV_init2(%p,%d,%d,%d,%p)" "\n bad input\n", dv, size, maxsize, owned, vec) ; spoolesFatal(); } if ( size < 0 || maxsize < size ) { fprintf(stderr, "\n fatal error in DV_init2(%p,%d,%d,%d,%p)" "\n size = %d, maxsize = %d \n", dv, size, maxsize, owned, vec, size, maxsize) ; spoolesFatal(); } if ( owned < 0 || 1 < owned ) { fprintf(stderr, "\n fatal error in DV_init2(%p,%d,%d,%d,%p)" "\n owned = %d\n", dv, size, maxsize, owned, vec, owned) ; spoolesFatal(); } if ( owned == 1 && vec == NULL ) { fprintf(stderr, "\n fatal error in DV_init2(%p,%d,%d,%d,%p)" "\n owned = %d and vec = %p", dv, size, maxsize, owned, vec, owned, vec) ; spoolesFatal(); } /* -------------- clear any data -------------- */ DV_clearData(dv) ; if ( vec == NULL ) { /* ---------------------------------------------- no entries input, use the simplest initializer ---------------------------------------------- */ DV_init(dv, size, NULL) ; } else { /* --------------------------------- entries are input, set the fields --------------------------------- */ dv->size = size ; dv->maxsize = maxsize ; dv->owned = owned ; dv->vec = vec ; } return ; }
/* ---------------------------------------------------- purpose -- worker method to factor the matrix created -- 98may29, cca ---------------------------------------------------- */ static void * FrontMtx_QR_workerFactor ( void *arg ) { char *status ; ChvList *updlist ; ChvManager *chvmanager ; double facops, t0, t1 ; double *cpus ; DV workDV ; FILE *msgFile ; FrontMtx *frontmtx ; Ideq *dequeue ; InpMtx *mtxA ; int J, K, myid, neqns, nfront, msglvl ; int *colmap, *firstnz, *nactiveChild, *owners, *par ; IVL *rowsIVL ; QR_factorData *data ; MARKTIME(t0) ; data = (QR_factorData *) arg ; mtxA = data->mtxA ; rowsIVL = data->rowsIVL ; firstnz = data->firstnz ; IV_sizeAndEntries(data->ownersIV, &nfront, &owners) ; frontmtx = data->frontmtx ; chvmanager = data->chvmanager ; updlist = data->updlist ; myid = data->myid ; cpus = data->cpus ; msglvl = data->msglvl ; msgFile = data->msgFile ; par = frontmtx->tree->par ; neqns = FrontMtx_neqns(frontmtx) ; /* -------------------------------------------------------- status[J] = 'F' --> J finished = 'W' --> J waiting to be finished create the Ideq object to handle the bottom-up traversal nactiveChild[K] = # of unfinished children of K, when zero, K can be placed on the dequeue -------------------------------------------------------- */ status = CVinit(nfront, 'F') ; dequeue = FrontMtx_setUpDequeue(frontmtx, owners, myid, status, NULL, 'W', 'F', msglvl, msgFile) ; FrontMtx_loadActiveLeaves(frontmtx, status, 'W', dequeue) ; nactiveChild = FrontMtx_nactiveChild(frontmtx, status, myid) ; colmap = IVinit(neqns, -1) ; DV_setDefaultFields(&workDV) ; facops = 0.0 ; if ( msglvl > 3 ) { fprintf(msgFile, "\n owners") ; IVfprintf(msgFile, nfront, owners) ; fprintf(msgFile, "\n Ideq") ; Ideq_writeForHumanEye(dequeue, msgFile) ; fflush(msgFile) ; } MARKTIME(t1) ; cpus[0] += t1 - t0 ; /* --------------------------- loop while a path is active --------------------------- */ while ( (J = Ideq_removeFromHead(dequeue)) != -1 ) { if ( msglvl > 1 ) { fprintf(msgFile, "\n\n ### checking out front %d, owner %d", J, owners[J]) ; } if ( owners[J] == myid ) { /* -------------------------------- front J is ready to be processed -------------------------------- */ FrontMtx_QR_factorVisit(frontmtx, J, mtxA, rowsIVL, firstnz, updlist, chvmanager, status, colmap, &workDV, cpus, &facops, msglvl, msgFile) ; if ( status[J] == 'F' ) { /* ------------------------------------------ front J is finished, put parent on dequeue if it exists or all children are finished ------------------------------------------ */ if ( (K = par[J]) != -1 && --nactiveChild[K] == 0 ) { Ideq_insertAtHead(dequeue, K) ; } } else { /* ----------------------------------------------- front J is not complete, put on tail of dequeue ----------------------------------------------- */ Ideq_insertAtTail(dequeue, J) ; } } else { /* ------------------------------------------- front J is not owned, put parent on dequeue if it exists and all children are finished ------------------------------------------- */ if ( (K = par[J]) != -1 && --nactiveChild[K] == 0 ) { Ideq_insertAtHead(dequeue, K) ; } } } data->facops = facops ; /* ------------------------ free the working storage ------------------------ */ CVfree(status) ; Ideq_free(dequeue) ; IVfree(nactiveChild) ; IVfree(colmap) ; DV_clearData(&workDV) ; MARKTIME(t1) ; cpus[6] = t1 - t0 ; cpus[5] = t1 - t0 - cpus[0] - cpus[1] - cpus[2] - cpus[3] - cpus[4] ; return(NULL) ; }