void *processImageThread(void* ptr){ imageThreadData *data; int i; _float *delgam; data = (imageThreadData*) ptr; delgam = (_float*)malloc(data->ndelgam * sizeof(_float) * 2); if(!delgam){ fprintf(stderr, "MALLOC ERROR\n"); #ifdef USE_THREADS pthread_exit(NULL); #endif } for(i=data->imstart;i<data->imend;i++){ // For each image process calcDeltaGamma(delgam, data->ccd, data->anglesp[0], data->anglesp[5]); calcQTheta(delgam, data->anglesp[1], data->anglesp[4], data->qOutp, data->ndelgam, data->lambda); if(data->mode > 1){ calcQPhiFromQTheta(data->qOutp, data->ndelgam, data->anglesp[2], data->anglesp[3]); } if(data->mode == 4){ calcHKLFromQPhi(data->qOutp, data->ndelgam, data->UBI); } data->anglesp+=6; data->qOutp+=(data->ndelgam * 4); } free(delgam); #ifdef USE_THREADS pthread_exit(NULL); #endif }
int processImages(double *delgam, double *anglesp, double *qOutp, double lambda, int mode, unsigned long nimages, double *ubinvp, CCD *ccd){ int retval = 0; unsigned long i; double UBI[3][3]; // Permute the UB matrix into the orientation // for the calculations for(i=0;i<3;i++){ UBI[i][0] = -1.0 * ubinvp[2]; UBI[i][1] = ubinvp[1]; UBI[i][2] = ubinvp[0]; ubinvp+=3; } #pragma omp parallel for shared(anglesp, qOutp, delgam, mode) for(i=0;i<nimages;i++){ // Calculate pointer offsets double *_anglesp = anglesp + (i * 6); double *_qOutp = qOutp + (i * ccd->size * 3); double *_delgam = delgam + (i * ccd->size * 2); // For each image process calcDeltaGamma(_delgam, ccd, _anglesp[0], _anglesp[5]); calcQTheta(_delgam, _anglesp[1], _anglesp[4], _qOutp, ccd->size, lambda); if(mode > 1){ calcQPhiFromQTheta(_qOutp, ccd->size, _anglesp[2], _anglesp[3]); } if(mode == 4){ calcHKLFromQPhi(_qOutp, ccd->size, UBI); } } return retval; }