From 9dcf1910f914d3389fa1c446b3716e48712bf6c5 Mon Sep 17 00:00:00 2001 From: Ali Murat Gok Date: Fri, 1 Nov 2019 19:04:04 -0700 Subject: [PATCH 1/2] ExafelSZ: Added critical error messages, fixed some memory leaks --- sz/src/exafelSZ.c | 61 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/sz/src/exafelSZ.c b/sz/src/exafelSZ.c index e966f311..0d2eb89e 100644 --- a/sz/src/exafelSZ.c +++ b/sz/src/exafelSZ.c @@ -13,32 +13,33 @@ void exafelSZ_params_process(exafelSZ_params*pr,size_t nEvents, size_t panels, s void exafelSZ_params_checkDecomp(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols){ if(pr->calibPanel==NULL){ - // cout<<"ERROR: calibPanel is NULL : calibPanel="<calibPanel); assert(0); } if(pr->binSize<1 || pr->tolerance<0 || pr->szDim<1 || pr->szDim>3){ - // cout<<"ERROR: Something wrong with the following:"<binSize); + printf("tolerance=%d\n",(int)pr->tolerance); + printf("szDim=%d\n",(int)pr->szDim); + assert(0); } if(!(pr->peakSize%2)){ - // cout<<"ERROR: peakSize = "<peakSize); assert(0); } if(nEvents<1 || panels<1 || rows<1 || cols<1){ - // cout<<"ERROR: Something wrong with the following:"<peaks==NULL){ - // cout<<"ERROR: peaks is NULL : peaks="<peaks); assert(0); } exafelSZ_params_checkDecomp(pr,nEvents, panels, rows, cols); @@ -125,15 +126,15 @@ unsigned char * exafelSZ_Compress(void* _pr, peaksBytePos+=2; if(p_>=panels){ - // cout<<"ERROR: Peak coordinate out of bounds: Panel="<=rows){ - // cout<<"ERROR: Peak coordinate out of bounds: Row="<=cols){ - // cout<<"ERROR: Peak coordinate out of bounds: Col="<tolerance, 0, 0, 0, 0, nEvents * panels, pr->binnedRows, pr->binnedCols); break; default: - // cout<<"Wrong pr->szDim (SZ dimensions)"<szDim:"<szDim<szDim); assert(0); } @@ -312,10 +312,11 @@ unsigned char * exafelSZ_Compress(void* _pr, //printf("bytePos=%d\n",bytePos); if(bytePos!=(*compressedSize)){ - // cout<<"ERROR: bytePos = "<=rows*cols){ - // cout<<"ERROR: calcIdx(r,c,cols) = calcIdx("<=nEvents*panels*rows*cols){ - // cout<<"ERROR: calcIdx(e,p,r,c,panels,rows,cols) = calcIdx("<calibPanel[calcIdx_2D(r,c,cols)]; @@ -438,15 +438,15 @@ void* exafelSZ_Decompress(void *_pr, peaksBytePos+=2; if(p_<0 || p_>=panels){ - // cout<<"ERROR: Peak coordinate out of bounds: Panel="<=rows){ - // cout<<"ERROR: Peak coordinate out of bounds: Row="<=cols){ - // cout<<"ERROR: Peak coordinate out of bounds: Col="<szDim){ case 1: - // szDecomp=sz_decompress_3D(szComp,0,0,nEvents * panels * pr->binnedRows * pr->binnedCols,pr->tolerance,szCompressedSize); //1D szDecomp=SZ_decompress(SZ_FLOAT,szComp,_szCompressedSize,0,0,0,0, nEvents * panels * pr->binnedRows * pr->binnedCols); break; case 2: - // szDecomp=sz_decompress_3D(szComp,0,nEvents * panels * pr->binnedRows, pr->binnedCols,pr->tolerance,szCompressedSize); //2D szDecomp=SZ_decompress(SZ_FLOAT,szComp,_szCompressedSize,0,0,0, nEvents * panels * pr->binnedRows, pr->binnedCols); break; case 3: - // szDecomp=sz_decompress_3D(szComp,nEvents * panels, pr->binnedRows, pr->binnedCols,pr->tolerance,szCompressedSize); //3D szDecomp=SZ_decompress(SZ_FLOAT,szComp,_szCompressedSize,0,0,nEvents * panels, pr->binnedRows, pr->binnedCols); break; default: - // cout<<"Wrong pr->szDim (SZ dimensions)"<szDim:"<szDim<szDim); assert(0); } + //szDecomp=(void*)malloc(nEvents*panels*rows*cols*sizeof(float)); + // double max_err = 0; // for(int i=0; ibinnedRows * pr->binnedCols; i++){ // double err = fabs(szDecomp[i]-binnedData[i]); @@ -488,7 +486,7 @@ void* exafelSZ_Decompress(void *_pr, // } // cout << "Max err = \t\t\t" << max_err << endl; - + //De-binning: for(e=0;e Date: Mon, 6 Jan 2020 14:29:26 -0800 Subject: [PATCH 2/2] Version ready for exafelSZ_example package --- sz/include/exafelSZ.h | 6 +++--- sz/src/exafelSZ.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sz/include/exafelSZ.h b/sz/include/exafelSZ.h index e053c490..8a13cd30 100644 --- a/sz/include/exafelSZ.h +++ b/sz/include/exafelSZ.h @@ -30,9 +30,9 @@ typedef struct exafelSZ_params{ } exafelSZ_params; -void exafelSZ_params_process(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols); -void exafelSZ_params_checkDecomp(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols); -void exafelSZ_params_checkComp(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols); +void exafelSZ_params_process(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols); +void exafelSZ_params_checkDecomp(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols); +void exafelSZ_params_checkComp(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols); unsigned char * exafelSZ_Compress(void* _pr, void* _origData, diff --git a/sz/src/exafelSZ.c b/sz/src/exafelSZ.c index 0d2eb89e..a1480dd4 100644 --- a/sz/src/exafelSZ.c +++ b/sz/src/exafelSZ.c @@ -4,14 +4,14 @@ extern "C" { #include "sz.h" -void exafelSZ_params_process(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols){ +void exafelSZ_params_process(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols){ pr->binnedRows=(rows+pr->binSize-1)/pr->binSize; pr->binnedCols=(cols+pr->binSize-1)/pr->binSize; pr->peakRadius=(pr->peakSize-1)/2; } -void exafelSZ_params_checkDecomp(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols){ +void exafelSZ_params_checkDecomp(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols){ if(pr->calibPanel==NULL){ printf("ERROR: calibPanel is NULL : calibPanel=%ld\n",(long)pr->calibPanel); assert(0); @@ -27,9 +27,9 @@ void exafelSZ_params_checkDecomp(exafelSZ_params*pr,size_t nEvents, size_t panel printf("ERROR: peakSize = %d cannot be even. It must be odd!\n",(int)pr->peakSize); assert(0); } - if(nEvents<1 || panels<1 || rows<1 || cols<1){ + //if(nEvents<1 || panels<1 || rows<1 || cols<1){ + if(panels<1 || rows<1 || cols<1){ printf("ERROR: Something wrong with the following:\n"); - printf("nEvents=%d\n",(int)nEvents); printf("panels=%d\n",(int)panels); printf("rows=%d\n",(int)rows); printf("cols=%d\n",(int)cols); @@ -37,12 +37,12 @@ void exafelSZ_params_checkDecomp(exafelSZ_params*pr,size_t nEvents, size_t panel } } -void exafelSZ_params_checkComp(exafelSZ_params*pr,size_t nEvents, size_t panels, size_t rows, size_t cols){ +void exafelSZ_params_checkComp(exafelSZ_params*pr, size_t panels, size_t rows, size_t cols){ if(pr->peaks==NULL){ printf("ERROR: peaks is NULL : peaks=%ld\n",(long)pr->peaks); assert(0); } - exafelSZ_params_checkDecomp(pr,nEvents, panels, rows, cols); + exafelSZ_params_checkDecomp(pr, panels, rows, cols); } void exafelSZ_params_print(){ @@ -87,8 +87,8 @@ unsigned char * exafelSZ_Compress(void* _pr, float *origData=(float*)_origData; exafelSZ_params *pr=(exafelSZ_params*)_pr; - exafelSZ_params_process(pr,nEvents, panels, rows, cols); - exafelSZ_params_checkDecomp(pr,nEvents, panels, rows, cols); + exafelSZ_params_process(pr, panels, rows, cols); + exafelSZ_params_checkDecomp(pr, panels, rows, cols); uint8_t *roiM=(uint8_t*)malloc(nEvents*panels*rows*cols) ; float *roiData=(float*)malloc(nEvents*panels*rows*cols*sizeof(float)) ; @@ -334,8 +334,8 @@ void* exafelSZ_Decompress(void *_pr, { uint8_t *compressedBuffer=(uint8_t *)_compressedBuffer; exafelSZ_params *pr=(exafelSZ_params *)_pr; - exafelSZ_params_process(pr,nEvents, panels, rows, cols); - exafelSZ_params_checkDecomp(pr,nEvents, panels, rows, cols); + exafelSZ_params_process(pr, panels, rows, cols); + exafelSZ_params_checkDecomp(pr, panels, rows, cols); float *decompressedBuffer=(float*)malloc(nEvents*panels*rows*cols*sizeof(float));