Skip to content

Commit 9770f7a

Browse files
committed
read binary data --> generate volume for CI
add CvxCompress_Test to CI changed number of iterations to 10 cleaned up for merge
1 parent 95646a9 commit 9770f7a

File tree

7 files changed

+116
-89
lines changed

7 files changed

+116
-89
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@ jobs:
4343
make
4444
ls
4545
46-
- name: Run test
46+
- name: Run CvxCompress_Test
47+
run: ./CvxCompress_Test
48+
49+
- name: Run Test_With_Generated_Input
4750
run: ./Test_With_Generated_Input

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*.o
22
*.so
33
*~
4+
Ds79_Base.cpp
5+
Us79_Base.cpp
46
Compress_Guojians_Stuff
57
Compress_SEAM_Basin
68
Compress_Sams_Stuff
@@ -10,4 +12,4 @@ CvxCompress_Test_Dyn
1012
Test_Compression
1113
Test_With_Generated_Input
1214
results.txt
13-
build/
15+
build/

CvxCompress.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -736,12 +736,12 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
736736
else
737737
{
738738
if (forward_passed)
739-
printf("[\x1B[32mPassed\x1B[0m]\n");
739+
printf("[\x1B[32mPassed!\x1B[0m]\n");
740740
else
741-
printf("[\x1B[31mFailed\x1B[0m]\n");
741+
printf("[\x1B[31mFailed!\x1B[0m]\n");
742742
}
743743

744-
printf("3. Verify correctness of inverse wavelet transform...");
744+
printf("\n3. Verify correctness of inverse wavelet transform...");
745745
if (verbose) printf("\n");
746746
bool inverse_passed = true;
747747
for (int k = min_k; k <= max_k; ++k)
@@ -776,9 +776,9 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
776776
else
777777
{
778778
if (inverse_passed)
779-
printf("[\x1B[32mPassed\x1B[0m]\n");
779+
printf("[\x1B[32mPassed!\x1B[0m]\n");
780780
else
781-
printf("[\x1B[31mFailed\x1B[0m]\n");
781+
printf("[\x1B[31mFailed!\x1B[0m]\n");
782782
}
783783

784784
#ifdef PAPI
@@ -797,7 +797,7 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
797797
}
798798
#endif
799799

800-
printf("4. Test throughput of wavelet transform (forward + inverse)...\n");
800+
printf("\n4. Test throughput of wavelet transform (forward + inverse)...\n");
801801
for (int k = min_k; k <= max_k; ++k)
802802
{
803803
int bz = 1 << k;
@@ -961,7 +961,7 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
961961
else
962962
printf("\x1B[0m[\x1B[31mFailed!\x1B[0m]\n");
963963

964-
printf("6. Verify correctness of Copy_From_Block method..."); fflush(stdout);
964+
printf("\n6. Verify correctness of Copy_From_Block method..."); fflush(stdout);
965965
bool copy_from_block_passed = true;
966966
if (vol == 0L || block == 0L)
967967
{
@@ -1027,7 +1027,7 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
10271027
else
10281028
printf("\x1B[0m[\x1B[31mFailed!\x1B[0m]\n");
10291029

1030-
printf("7. Test throughput of block copy..."); fflush(stdout);
1030+
printf("\n7. Test throughput of block copy..."); fflush(stdout);
10311031
bool copy_round_trip_passed = true;
10321032
if (vol == 0L)
10331033
{
@@ -1094,9 +1094,8 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
10941094
}
10951095
}
10961096
}
1097-
printf("\n");
10981097

1099-
printf("8. Verify correctness of Global_RMS method..."); fflush(stdout);
1098+
printf("\n8. Verify correctness of Global_RMS method..."); fflush(stdout);
11001099
bool global_rms_passed = true;
11011100
if (vol == 0L || block == 0L)
11021101
{
@@ -1130,9 +1129,10 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
11301129

11311130
float scale = 1e-1f;
11321131

1133-
printf("9. Test throughput of Compress() method...\n");
1132+
printf("\n9. Test throughput of Compress() method...\n");
11341133
int nx3,ny3,nz3;
11351134
float* vol3;
1135+
// 2024.10.27 instead of reading a binary file, we now create a volume in the function Read_Raw_Volume
11361136
Read_Raw_Volume("/cpfs/lfs02/ESDRD/tjhc/pressure_at_t=7512.bin",nx3,ny3,nz3,vol3);
11371137
//Read_Raw_Volume("/cpfs/lfs01/ESDRD/tjhc/fdmod2/trunk/CvxCompress/empty.bin",nx3,ny3,nz3,vol3);
11381138
unsigned long* compressed3;
@@ -1160,7 +1160,6 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
11601160
memtype = "DRAM";
11611161
printf("\x1B[0m -> %3d x %3d x %3d (%s) ",bx,by,bz,memtype); fflush(stdout);
11621162

1163-
11641163
auto start = Time::now();
11651164
double elapsed = 0.0;
11661165

@@ -1176,16 +1175,16 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
11761175
double mcells_per_sec = (double)niter * (double)nx3 * (double)ny3 * (double)nz3 / (elapsed.count() * 1e6);
11771176
printf("\r\x1B[0m -> %3d x %3d x %3d (%s) %2d iterations - %6.3f secs - %.0f MCells/s - ratio %.2f:1",bx,by,bz,memtype,niter,elapsed.count(),mcells_per_sec,ratio);
11781177
fflush(stdout);
1179-
} while (elapsed < 10.0);
1178+
// } while (elapsed < 10.0); // 2024.10.27 switch to iteration count, elapased doesnt make sense
1179+
} while (niter < 10);
11801180
printf("\n");
1181-
//printf("%d iterations - %6.3f secs - %.0f MCells/s - ratio %.2f:1\n",niter,elapsed,mcells_per_sec,ratio);
11821181
}
11831182
}
11841183
}
11851184
}
11861185

1187-
printf("10. Test throughput of Decompress() method...\n");
1188-
for (int k = min_k; k <= max_k-2; ++k)
1186+
printf("\n10. Test throughput of Decompress() method...\n");
1187+
for (int k = min_k; k <= max_k-1; ++k)
11891188
{
11901189
int bz = 1 << k;
11911190
for (int j = min_j; j <= max_j; ++j)
@@ -1226,7 +1225,8 @@ bool CvxCompress::Run_Module_Tests(bool verbose, bool exhaustive_throughput_test
12261225
printf("\r\x1B[0m -> %3d x %3d x %3d (%s) %2d iterations - %6.3f secs - %.0f MCells/s",bx,by,bz,memtype,niter,elapsed.count(),mcells_per_sec);
12271226
fflush(stdout);
12281227
free(vol4);
1229-
} while (elapsed < 10.0);
1228+
// } while (elapsed < 10.0); // 2024.10.27 switch to iteration count, elapased doesnt make sense
1229+
} while (niter < 10);
12301230
printf("\n");
12311231
}
12321232
}

CvxCompress.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public:
4040
unsigned int* compressed,
4141
int num_threads,
4242
long& compressed_length
43-
);
43+
);
4444
/*!
4545
* Compress a 3D wavefield using a given block size
4646
* nx is fast, nz is slow
@@ -60,7 +60,7 @@ public:
6060
bool use_local_RMS,
6161
unsigned int* compressed,
6262
long& compressed_length
63-
);
63+
);
6464
/*!
6565
* Compress a 3D wavefield using a given block size.
6666
* Works same as above, except parameter use_local_RMS is hardcoded to be false.
@@ -108,7 +108,7 @@ public:
108108
unsigned int* compressed,
109109
int num_threads,
110110
long compressed_length
111-
);
111+
);
112112

113113
void Decompress(
114114
float* vol,
@@ -117,7 +117,7 @@ public:
117117
int nz,
118118
unsigned int* compressed,
119119
long compressed_length
120-
);
120+
);
121121

122122
bool Is_Valid_Block_Size(int bx, int by, int bz);
123123

README.md

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,100 @@
11
# CvxCompres library
2-
This CvxCompress was originally authored by Thor Johnsen.
2+
This CvxCompress was originally authored by Thor Johnsen, based on an implementation by Ray Ergas.
3+
For more information here are references to that earlier work.
4+
5+
```
6+
Ergas, R.A., "Wavelet Transform Techniques for Seismic Data Compression and Denoising," Society of Exploration Geophysicists Annual Meeting, 1995.
7+
8+
Ergas, R.A., Donoho, P.L., and Villasenor, J.D., "Multiresolution Analysis for Seismic Data Compression Using Wavelets," IEEE Transactions on Signal Processing, 1995.
9+
10+
Ergas, R.A., "Seismic data compression--A key technology for the future", Society of Exploration Geophysicists Annual Meeting, 1996.
11+
https://library.seg.org/doi/pdf/10.1190/1.1826518
12+
```
313

414
# Building
15+
516
## GCC
617

7-
It is believed that this will work with a wide variety of gcc
8-
versions, but as I am writing this I have only tested it with gcc 7.30 and gcc 9.3.0.
18+
It is believed that this will work any reasonably modern gcc version.
919

1020
## Tests
1121

12-
There are several tests included, some of which depends on binary
13-
cubes of input need to exist at some absolute path which is no longer
14-
present. Thus, here I describe only the ones that require no input file.
22+
There are two test sets included, below is the command line to run and the output.
1523

1624
```
1725
Prompt> ( setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${cwd} ; ./CvxCompress_Test )
1826
*
19-
* CvxCompress module tests (ICC1900, AVX).
27+
* CvxCompress module tests (GCC13.2, AVX).
2028
*
2129
22-
2. Verify correctness of forward wavelet transform...[Passed]
23-
3. Verify correctness of inverse wavelet transform...[Passed]
30+
2. Verify correctness of forward wavelet transform...[Passed!]
31+
32+
3. Verify correctness of inverse wavelet transform...[Passed!]
33+
2434
4. Test throughput of wavelet transform (forward + inverse)...
25-
-> 8 x 8 x 8 ( L1 ) :: 4.770 secs - 3602 MCells/s - 435 GF/s
26-
-> 16 x 16 x 16 ( L1 ) :: 4.629 secs - 3711 MCells/s - 480 GF/s
27-
-> 32 x 32 x 32 ( L2 ) :: 6.371 secs - 2697 MCells/s - 361 GF/s
28-
-> 64 x 64 x 64 ( L3 ) :: 7.438 secs - 2310 MCells/s - 314 GF/s
29-
-> 128 x 128 x 128 (DRAM) :: 11.056 secs - 1557 MCells/s - 213 GF/s
30-
-> 256 x 256 x 256 (DRAM) :: 18.059 secs - 965 MCells/s - 133 GF/s
35+
-> 8 x 8 x 8 ( L1 ) :: 5.009 secs - 25725 MCells/s - 3106 GF/s
36+
-> 16 x 16 x 16 ( L1 ) :: 3.770 secs - 34178 MCells/s - 4422 GF/s
37+
-> 32 x 32 x 32 ( L2 ) :: 5.681 secs - 22680 MCells/s - 3032 GF/s
38+
-> 64 x 64 x 64 ( L3 ) :: 11.787 secs - 10934 MCells/s - 1485 GF/s
39+
-> 128 x 128 x 128 (DRAM) :: 43.591 secs - 2962 MCells/s - 406 GF/s
40+
-> 256 x 256 x 256 (DRAM) :: 19.645 secs - 6661 MCells/s - 916 GF/s
3141
3242
5. Verify correctness of Copy_To_Block method...[Passed!]
43+
3344
6. Verify correctness of Copy_From_Block method...[Passed!]
45+
3446
7. Test throughput of block copy...
35-
-> 8 x 8 x 8 [Passed!] :: 0.413 secs - 2603 MCells/s - 31.23 GB/s
36-
-> 16 x 16 x 16 [Passed!] :: 0.438 secs - 2454 MCells/s - 29.44 GB/s
37-
-> 32 x 32 x 32 [Passed!] :: 0.605 secs - 1775 MCells/s - 21.30 GB/s
38-
-> 64 x 64 x 64 [Passed!] :: 0.517 secs - 2077 MCells/s - 24.92 GB/s
39-
-> 128 x 128 x 128 [Passed!] :: 0.608 secs - 1767 MCells/s - 21.20 GB/s
40-
-> 256 x 256 x 256 [Passed!] :: 0.694 secs - 1547 MCells/s - 18.56 GB/s
47+
-> 8 x 8 x 8 [Passed!] :: -0.190 secs - -5640 MCells/s - -67.69 GB/s
48+
-> 16 x 16 x 16 [Passed!] :: -0.182 secs - -5900 MCells/s - -70.81 GB/s
49+
-> 32 x 32 x 32 [Passed!] :: -0.127 secs - -8440 MCells/s - -101.28 GB/s
50+
-> 64 x 64 x 64 [Passed!] :: -0.131 secs - -8167 MCells/s - -98.01 GB/s
51+
-> 128 x 128 x 128 [Passed!] :: -0.177 secs - -6061 MCells/s - -72.74 GB/s
52+
-> 256 x 256 x 256 [Passed!] :: -0.362 secs - -2967 MCells/s - -35.61 GB/s
4153
4254
8. Verify correctness of Global_RMS method...[Passed!]
55+
4356
9. Test throughput of Compress() method...
44-
nx=1604, ny=1606, nz=968
45-
-> 8 x 8 x 8 ( L1 ) 9 iterations - 11.024 secs - 2036 MCells/s - ratio 29.03:1
46-
-> 16 x 16 x 16 ( L1 ) 12 iterations - 10.419 secs - 2872 MCells/s - ratio 51.37:1
47-
-> 32 x 32 x 32 ( L2 ) 10 iterations - 10.356 secs - 2408 MCells/s - ratio 73.40:1
48-
-> 64 x 64 x 64 ( L3 ) 10 iterations - 10.654 secs - 2341 MCells/s - ratio 93.21:1
49-
-> 128 x 128 x 128 (DRAM) 7 iterations - 10.751 secs - 1624 MCells/s - ratio 105.98:1
57+
-> 8 x 8 x 8 ( L1 ) 10 iterations - 0.393 secs - 20 MCells/s - ratio 21.78:1
58+
-> 16 x 16 x 16 ( L1 ) 10 iterations - 0.392 secs - 20 MCells/s - ratio 36.07:1
59+
-> 32 x 32 x 32 ( L2 ) 10 iterations - 0.408 secs - 19 MCells/s - ratio 55.67:1
60+
-> 64 x 64 x 64 ( L3 ) 10 iterations - 0.441 secs - 18 MCells/s - ratio 72.17:1
61+
-> 128 x 128 x 128 (DRAM) 10 iterations - 0.705 secs - 11 MCells/s - ratio 62.60:1
62+
5063
10. Test throughput of Decompress() method...
51-
-> 8 x 8 x 8 ( L1 ) 7 iterations - 10.321 secs - 1691 MCells/s
52-
-> 16 x 16 x 16 ( L1 ) 10 iterations - 10.283 secs - 2425 MCells/s
53-
-> 32 x 32 x 32 ( L2 ) 8 iterations - 11.327 secs - 1761 MCells/s
54-
-> 64 x 64 x 64 ( L3 ) 8 iterations - 10.695 secs - 1865 MCells/s
64+
-> 8 x 8 x 8 ( L1 ) 10 iterations - 0.000 secs - 33679 MCells/ss/s
65+
-> 16 x 16 x 16 ( L1 ) 10 iterations - 0.000 secs - 32253 MCells/s/s
66+
-> 32 x 32 x 32 ( L2 ) 10 iterations - 0.000 secs - 33092 MCells/s/s
67+
-> 64 x 64 x 64 ( L3 ) 10 iterations - 0.000 secs - 38488 MCells/s/s
68+
-> 128 x 128 x 128 (DRAM) 10 iterations - 0.000 secs - 243809 MCells/ss
69+
5570
5671
Prompt> ( setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$cwd ; ./Test_With_Generated_Input )
5772
Using global RMS.
5873
Using size of input (nslow, middle, fast) = ( 320, 416, 352 )
5974
Starting compression test
6075
RMS:
6176
input : 0.707107
62-
output: 0.707080
77+
output: 1.414186
6378
Difference: 0.000118
64-
compression ratio (return value) = 1048.35:1, compression throughput = 1282 MC/s, decompression throughput = 1207 MC/s, error = 1.663531e-04, SNR = 75.6 dB
65-
Total compression and decompression times were 0.08 seconds
79+
compression ratio (return value) = 1048.35:1, compression throughput = 2150 MC/s, decompression throughput = 7303 MC/s, error = 1.663531e-04, SNR = 75.6 dB
80+
Total compression and decompression times were 0.03 seconds
6681
Total compression ratio (based on compress_length) was 1048.35:1, compressed length in bytes = 178789
6782
Using size of input (nslow, middle, fast) = ( 640, 832, 704 )
6883
Starting compression test
6984
RMS:
7085
input : 0.707107
71-
output: 0.707080
86+
output: 1.414186
7287
Difference: 0.000118
73-
compression ratio (return value) = 1048.55:1, compression throughput = 1838 MC/s, decompression throughput = 1619 MC/s, error = 1.663531e-04, SNR = 75.6 dB
74-
Total compression and decompression times were 0.44 seconds
88+
compression ratio (return value) = 1048.55:1, compression throughput = 4236 MC/s, decompression throughput = 8478 MC/s, error = 1.663531e-04, SNR = 75.6 dB
89+
Total compression and decompression times were 0.13 seconds
7590
Total compression ratio (based on compress_length) was 1048.55:1, compressed length in bytes = 1430039
7691
Using size of input (nslow, middle, fast) = ( 960, 1248, 1056 )
7792
Starting compression test
7893
RMS:
7994
input : 0.707107
80-
output: 0.707080
95+
output: 1.414186
8196
Difference: 0.000118
82-
compression ratio (return value) = 1048.57:1, compression throughput = 2217 MC/s, decompression throughput = 1708 MC/s, error = 1.663531e-04, SNR = 75.6 dB
97+
compression ratio (return value) = 1048.57:1, compression throughput = 4271 MC/s, decompression throughput = 5989 MC/s, error = 1.663531e-04, SNR = 75.6 dB
98+
Total compression and decompression times were 0.51 seconds
99+
Total compression ratio (based on compress_length) was 1048.57:1, compressed length in bytes = 4826289
83100
```
84-

Read_Raw_Volume.cpp

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,38 @@
66
#include <omp.h>
77

88
/*!
9-
* Read uncompressed volume from a binary file.
10-
*
11-
*/
12-
void Read_Raw_Volume(const char* filename, int& nx, int& ny, int& nz, float*& vol)
13-
{
14-
FILE* fp = fopen(filename, "rb");
15-
if (fp != 0L)
9+
* Read uncompressed volume from a binary file.
10+
* 2024.10.27: hijacked this method to replace reading a binary with generating a volume from sinusoids + random
11+
*/
12+
void Read_Raw_Volume(const char* filename, int& nx, int& ny, int& nz, float*& vol) {
13+
nx = 151;
14+
ny = 101;
15+
nz = 51;
16+
size_t nn = (size_t)nx * (size_t)ny * (size_t)nz;
17+
posix_memalign((void**)&vol, 64, nn * (size_t)sizeof(float));
18+
int x0 = (nx-1) / 2;
19+
int y0 = (ny-1) / 2;
20+
int z0 = (nz-1) / 2;
21+
22+
#pragma omp parallel for schedule(static,1)
23+
for (long iz = 0; iz < nz; ++iz)
1624
{
17-
fread(&nx,sizeof(int),1,fp);
18-
fread(&ny,sizeof(int),1,fp);
19-
fread(&nz,sizeof(int),1,fp);
20-
printf("nx=%d, ny=%d, nz=%d\n",nx,ny,nz);
21-
size_t nn = (size_t)nx * (size_t)ny * (size_t)nz;
22-
posix_memalign((void**)&vol, 64, nn * (size_t)sizeof(float));
25+
memset((void*)(vol+iz*(long)nx*(long)ny),0,(long)sizeof(float)*(long)nx*(long)ny);
26+
}
27+
2328
#pragma omp parallel for schedule(static,1)
24-
for (long iz = 0; iz < nz; ++iz)
25-
{
26-
memset((void*)(vol+iz*(long)nx*(long)ny),0,(long)sizeof(float)*(long)nx*(long)ny);
27-
}
28-
fread(vol,sizeof(float),nn,fp);
29-
fclose(fp);
29+
for (long iz = 0; iz < nz; ++iz)
30+
{
31+
for (long iy = 0; iy < ny; ++iy)
32+
{
33+
for (long ix = 0; ix < nx; ++ix)
34+
{
35+
double x = ix - x0;
36+
double y = iy - y0;
37+
double z = iz - z0;
38+
double r = sqrt(x*x + y*y + z*z);
39+
vol[iz*nx*ny + ix*ny + iy] = sin(r / 10) + drand48() / 100;
40+
}
41+
}
3042
}
31-
else
32-
{
33-
printf("Error! Unable to open file %s for reading.\nAborting\n",filename);
34-
exit(-1);
35-
}
3643
}
37-

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC ?= gcc
22
CXX ?= g++
33

4-
CFLAGS=-fopenmp -O3 -fPIC -g
4+
CFLAGS=-fopenmp -O3 -fPIC -g -Wno-unused-result
55
# Check if we're on an x86 architecture and if CC supports -mavx
66
ifeq ($(shell uname -m), x86_64)
77
CFLAGS += -mavx

0 commit comments

Comments
 (0)