Skip to content

Commit 8b02d4f

Browse files
authored
Merge pull request #635 from E3SM-Project/dqwu/fix_adios_zfp_compression
This PR adds support for writing 0D data and short integer variables with the ZFP compression method in ADIOS.
2 parents e5381dd + a0af79f commit 8b02d4f

File tree

3 files changed

+209
-2
lines changed

3 files changed

+209
-2
lines changed

src/clib/pio_darray.cpp

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ static int PIOc_write_decomp_adios(file_desc_t *file, int ioid)
10671067
}
10681068

10691069
char name[PIO_MAX_NAME];
1070+
char name_varid[PIO_MAX_NAME];
10701071
adios2_variable *variableH = NULL;
10711072
adios2_variable *num_decomp_block_writers_varid = NULL;
10721073
if (file->adios_io_process == 1)
@@ -1089,7 +1090,6 @@ static int PIOc_write_decomp_adios(file_desc_t *file, int ioid)
10891090
/* Variable to store the number of writer blocks, in case buffer merging doesn't happen */
10901091
if (file->block_myrank == 0)
10911092
{
1092-
char name_varid[PIO_MAX_NAME];
10931093
snprintf(name_varid, PIO_MAX_NAME, "/__pio__/track/num_decomp_block_writers/%d", ioid);
10941094
av_count = 1;
10951095
num_decomp_block_writers_varid = adios2_inquire_variable(file->ioH, name_varid);
@@ -1157,6 +1157,23 @@ static int PIOc_write_decomp_adios(file_desc_t *file, int ioid)
11571157
"Setting (ADIOS) selection to variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
11581158
name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
11591159
}
1160+
1161+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1162+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1163+
{
1164+
if (count_val == 1)
1165+
{
1166+
adiosErr = adios2_remove_operations(variableH);
1167+
if (adiosErr != adios2_error_none)
1168+
{
1169+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1170+
"Removing all current operations associated with variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1171+
name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1172+
}
1173+
}
1174+
}
1175+
#endif
1176+
11601177
adiosErr = adios2_put(file->engineH, variableH, file->block_array, adios2_mode_sync);
11611178
if (adiosErr != adios2_error_none)
11621179
{
@@ -1172,12 +1189,25 @@ static int PIOc_write_decomp_adios(file_desc_t *file, int ioid)
11721189
/* Write the number of block writers */
11731190
if (file->adios_io_process == 1 && file->block_myrank == 0)
11741191
{
1192+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1193+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1194+
{
1195+
adiosErr = adios2_remove_operations(num_decomp_block_writers_varid);
1196+
if (adiosErr != adios2_error_none)
1197+
{
1198+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1199+
"Removing all current operations associated with variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1200+
name_varid, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1201+
}
1202+
}
1203+
#endif
1204+
11751205
adiosErr = adios2_put(file->engineH, num_decomp_block_writers_varid, &num_decomp_block_writers, adios2_mode_sync);
11761206
if (adiosErr != adios2_error_none)
11771207
{
11781208
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
11791209
"Putting (ADIOS) variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1180-
name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1210+
name_varid, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
11811211
}
11821212
(file->num_written_blocks)++;
11831213
}
@@ -1447,6 +1477,23 @@ static int check_adios2_need_to_flush(file_desc_t *file, adios_var_desc_t *av)
14471477
"Setting (ADIOS) selection to variable (name=num_data_block_writers/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
14481478
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
14491479
}
1480+
1481+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1482+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1483+
{
1484+
if (count_val == 1)
1485+
{
1486+
adiosErr = adios2_remove_operations(av->num_block_writers_varid);
1487+
if (adiosErr != adios2_error_none)
1488+
{
1489+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1490+
"Removing all current operations associated with variable (name=num_data_block_writers/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1491+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1492+
}
1493+
}
1494+
}
1495+
#endif
1496+
14501497
adiosErr = adios2_put(file->engineH, av->num_block_writers_varid, av->num_wb_buffer, adios2_mode_sync);
14511498
if (adiosErr != adios2_error_none)
14521499
{
@@ -1471,6 +1518,23 @@ static int check_adios2_need_to_flush(file_desc_t *file, adios_var_desc_t *av)
14711518
"Setting (ADIOS) selection to variable (name=fillval_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
14721519
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
14731520
}
1521+
1522+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1523+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1524+
{
1525+
if (count_val == 1)
1526+
{
1527+
adiosErr = adios2_remove_operations(av->fillval_varid);
1528+
if (adiosErr != adios2_error_none)
1529+
{
1530+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1531+
"Removing all current operations associated with variable (name=fillval_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1532+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1533+
}
1534+
}
1535+
}
1536+
#endif
1537+
14741538
adiosErr = adios2_put(file->engineH, av->fillval_varid, av->fillval_buffer, adios2_mode_sync);
14751539
if (adiosErr != adios2_error_none)
14761540
{
@@ -1495,6 +1559,23 @@ static int check_adios2_need_to_flush(file_desc_t *file, adios_var_desc_t *av)
14951559
"Setting (ADIOS) selection to variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
14961560
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
14971561
}
1562+
1563+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1564+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1565+
{
1566+
if (count_val == 1)
1567+
{
1568+
adiosErr = adios2_remove_operations(av->decomp_varid);
1569+
if (adiosErr != adios2_error_none)
1570+
{
1571+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1572+
"Removing all current operations associated with variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1573+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1574+
}
1575+
}
1576+
}
1577+
#endif
1578+
14981579
adiosErr = adios2_put(file->engineH, av->decomp_varid, av->decomp_buffer, adios2_mode_sync);
14991580
if (adiosErr != adios2_error_none)
15001581
{
@@ -1519,6 +1600,23 @@ static int check_adios2_need_to_flush(file_desc_t *file, adios_var_desc_t *av)
15191600
"Setting (ADIOS) selection to variable (name=frame_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
15201601
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
15211602
}
1603+
1604+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1605+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1606+
{
1607+
if (count_val == 1)
1608+
{
1609+
adiosErr = adios2_remove_operations(av->frame_varid);
1610+
if (adiosErr != adios2_error_none)
1611+
{
1612+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1613+
"Removing all current operations associated with variable (name=frame_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1614+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1615+
}
1616+
}
1617+
}
1618+
#endif
1619+
15221620
adiosErr = adios2_put(file->engineH, av->frame_varid, av->frame_buffer, adios2_mode_sync);
15231621
if (adiosErr != adios2_error_none)
15241622
{
@@ -1863,6 +1961,23 @@ static int PIOc_write_darray_adios(file_desc_t *file, int varid, int ioid,
18631961
"Setting (ADIOS) selection to variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
18641962
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
18651963
}
1964+
1965+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
1966+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
1967+
{
1968+
if (count_val == 1)
1969+
{
1970+
adiosErr = adios2_remove_operations(av->adios_varid);
1971+
if (adiosErr != adios2_error_none)
1972+
{
1973+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
1974+
"Removing all current operations associated with variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
1975+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
1976+
}
1977+
}
1978+
}
1979+
#endif
1980+
18661981
adiosErr = adios2_put(file->engineH, av->adios_varid, file->block_array, adios2_mode_sync);
18671982
if (adiosErr != adios2_error_none)
18681983
{

src/clib/pio_getput_int.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,22 @@ int spio_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
29162916
"Setting (ADIOS) selection to variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
29172917
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
29182918
}
2919+
2920+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
2921+
if (ios->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
2922+
{
2923+
if (av_size == 1)
2924+
{
2925+
adiosErr = adios2_remove_operations(av->adios_varid);
2926+
if (adiosErr != adios2_error_none)
2927+
{
2928+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
2929+
"Removing all current operations associated with variable (name=%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
2930+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
2931+
}
2932+
}
2933+
}
2934+
#endif
29192935
}
29202936

29212937
char *mem_buffer = (char*)calloc(av_size, sizeof(char));

src/clib/pioc_support.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ static int flush_adios2_tracking_data(file_desc_t *file)
152152
"Setting (ADIOS) selection to variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
153153
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
154154
}
155+
156+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
157+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
158+
{
159+
if (count_val == 1)
160+
{
161+
adiosErr = adios2_remove_operations(av->decomp_varid);
162+
if (adiosErr != adios2_error_none)
163+
{
164+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
165+
"Removing all current operations associated with variable (name=decomp_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
166+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
167+
}
168+
}
169+
}
170+
#endif
171+
155172
adiosErr = adios2_put(file->engineH, av->decomp_varid, av->decomp_buffer, adios2_mode_sync);
156173
if (adiosErr != adios2_error_none)
157174
{
@@ -178,6 +195,23 @@ static int flush_adios2_tracking_data(file_desc_t *file)
178195
"Setting (ADIOS) selection to variable (name=frame_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
179196
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
180197
}
198+
199+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
200+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
201+
{
202+
if (count_val == 1)
203+
{
204+
adiosErr = adios2_remove_operations(av->frame_varid);
205+
if (adiosErr != adios2_error_none)
206+
{
207+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
208+
"Removing all current operations associated with variable (name=frame_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
209+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
210+
}
211+
}
212+
}
213+
#endif
214+
181215
adiosErr = adios2_put(file->engineH, av->frame_varid, av->frame_buffer, adios2_mode_sync);
182216
if (adiosErr != adios2_error_none)
183217
{
@@ -204,6 +238,23 @@ static int flush_adios2_tracking_data(file_desc_t *file)
204238
"Setting (ADIOS) selection to variable (name=fillval_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
205239
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
206240
}
241+
242+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
243+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
244+
{
245+
if (count_val == 1)
246+
{
247+
adiosErr = adios2_remove_operations(av->fillval_varid);
248+
if (adiosErr != adios2_error_none)
249+
{
250+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
251+
"Removing all current operations associated with variable (name=fillval_id/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
252+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
253+
}
254+
}
255+
}
256+
#endif
257+
207258
adiosErr = adios2_put(file->engineH, av->fillval_varid, av->fillval_buffer, adios2_mode_sync);
208259
if (adiosErr != adios2_error_none)
209260
{
@@ -230,6 +281,23 @@ static int flush_adios2_tracking_data(file_desc_t *file)
230281
"Setting (ADIOS) selection to variable (name=num_data_block_writers/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
231282
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
232283
}
284+
285+
#if defined(_SPIO_ADIOS_USE_LOSSY_COMPRESSION) && defined(ADIOS2_HAVE_ZFP)
286+
if (file->iosystem->adios_lossy_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
287+
{
288+
if (count_val == 1)
289+
{
290+
adiosErr = adios2_remove_operations(av->num_block_writers_varid);
291+
if (adiosErr != adios2_error_none)
292+
{
293+
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
294+
"Removing all current operations associated with variable (num_data_block_writers/%s) failed (adios2_error=%s) for file (%s, ncid=%d)",
295+
av->name, convert_adios2_error_to_string(adiosErr), pio_get_fname_from_file(file), file->pio_ncid);
296+
}
297+
}
298+
}
299+
#endif
300+
233301
adiosErr = adios2_put(file->engineH, av->num_block_writers_varid, av->num_wb_buffer, adios2_mode_sync);
234302
if (adiosErr != adios2_error_none)
235303
{
@@ -572,6 +640,14 @@ adios2_variable* spio_define_adios2_variable(iosystem_desc_t *ios, file_desc_t *
572640
if (type != adios2_type_float && type != adios2_type_double)
573641
variable_compression_method = ios->adios_lossless_compression_method;
574642
}
643+
/* ZFP compressor does not support 8-bit or 16-bit integer types */
644+
else if (variable_compression_method == ADIOS_COMPRESSION_METHOD_ZFP)
645+
{
646+
/* Switch back to lossless compression method for unsupported integer types */
647+
if (type == adios2_type_int8_t || type == adios2_type_uint8_t ||
648+
type == adios2_type_int16_t || type == adios2_type_uint16_t)
649+
variable_compression_method = ios->adios_lossless_compression_method;
650+
}
575651
#endif
576652

577653
if (variable_compression_method == ADIOS_COMPRESSION_METHOD_BLOSC2)

0 commit comments

Comments
 (0)