-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New API to allow storing only stats for primary variables (#4328)
* Move the decision to write data for derived variables in VariableBase Co-authored-by: Greg Eisenhauer <eisen@cc.gatech.edu> * C and C++ bindings for setting the write mode of a variable * Fortran API for changing the write mode for primary variables * Python API for changing the write mode for primary variables * Change the API to StoreStatsOnly instead of SetWriteMode Co-authored-by: Norbert Podhorszki <pnorbert@ornl.gov> * Testing in CXX and C for the StatsOnly write mode * Testing for the Fortran bindings for the StatsOnly write mode * Testing for the Python bindings for the StatsOnly write mode --------- Co-authored-by: Greg Eisenhauer <eisen@cc.gatech.edu> Co-authored-by: Norbert Podhorszki <pnorbert@ornl.gov>
- Loading branch information
1 parent
d975ac0
commit 532747a
Showing
22 changed files
with
410 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Distributed under the OSI-approved Apache License, Version 2.0. See | ||
* accompanying file Copyright.txt for details. | ||
* | ||
* TestBPWriteStatsOnly.cpp : test the C bindings when only stats are written | ||
*/ | ||
|
||
#include <adios2_c.h> | ||
#include <gtest/gtest.h> | ||
#include <vector> | ||
|
||
class ADIOS2_C_API : public ::testing::Test | ||
{ | ||
public: | ||
ADIOS2_C_API() { adiosH = adios2_init_serial(); } | ||
|
||
~ADIOS2_C_API() { adios2_finalize(adiosH); } | ||
|
||
adios2_adios *adiosH; | ||
}; | ||
|
||
TEST_F(ADIOS2_C_API, ADIOS2BPWriteStatsOnly) | ||
{ | ||
#if ADIOS2_USE_MPI | ||
const char fname[] = "ADIOS2_C_API.ADIOS2BPWriteStatsOnly_MPI.bp"; | ||
#else | ||
const char fname[] = "ADIOS2_C_API.ADIOS2BPWriteStatsOnly.bp"; | ||
#endif | ||
// write | ||
{ | ||
adios2_io *ioH = adios2_declare_io(adiosH, "CWriteStats"); | ||
adios2_set_engine(ioH, "BPFile"); | ||
|
||
size_t shape[2]; | ||
shape[0] = 5; | ||
shape[1] = 2; | ||
|
||
size_t start[2]; | ||
start[0] = 0; | ||
start[1] = 0; | ||
|
||
size_t count[2]; | ||
count[0] = 5; | ||
count[1] = 2; | ||
|
||
int32_t data_I32[10] = {131072, 131073, -131070, 131075, -131068, | ||
131077, -131066, 131079, -131064, 131081}; | ||
adios2_define_variable(ioH, "varI32", adios2_type_int32_t, 2, shape, start, count, | ||
adios2_constant_dims_true); | ||
adios2_variable *varI32 = adios2_inquire_variable(ioH, "varI32"); | ||
adios2_store_stats_only(varI32, adios2_true); | ||
|
||
adios2_engine *engineH = adios2_open(ioH, fname, adios2_mode_write); | ||
adios2_put(engineH, varI32, data_I32, adios2_mode_deferred); | ||
adios2_close(engineH); | ||
} | ||
// read shape | ||
{ | ||
adios2_io *ioH = adios2_declare_io(adiosH, "Reader"); | ||
adios2_engine *engineH = adios2_open(ioH, fname, adios2_mode_readRandomAccess); | ||
size_t steps; | ||
adios2_steps(&steps, engineH); | ||
EXPECT_EQ(steps, 1); | ||
|
||
std::vector<int32_t> inI32(10); | ||
adios2_variable *varI32 = adios2_inquire_variable(ioH, "varI32"); | ||
|
||
// test that the shape function returns the correct dimensions | ||
size_t cpu_shape[2]; | ||
adios2_error e = adios2_variable_shape(cpu_shape, varI32); | ||
EXPECT_EQ(e, adios2_error_none); | ||
EXPECT_EQ(cpu_shape[0], 5); | ||
EXPECT_EQ(cpu_shape[1], 2); | ||
|
||
e = adios2_get(engineH, varI32, inI32.data(), adios2_mode_sync); | ||
EXPECT_EQ(e, adios2_error_runtime_error); | ||
adios2_close(engineH); | ||
} | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int result; | ||
::testing::InitGoogleTest(&argc, argv); | ||
result = RUN_ALL_TESTS(); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
program TestBPWriteStatsOnly | ||
use adios2 | ||
|
||
implicit none | ||
|
||
type(adios2_adios) :: adios | ||
type(adios2_io) :: ioPut, ioGet | ||
type(adios2_engine) :: bpWriter, bpReader | ||
type(adios2_variable) :: var_temperatures, var_temperaturesIn | ||
|
||
integer(kind=4), dimension(:, :), allocatable :: temperatures_i4, & | ||
sel_temperatures_i4 | ||
|
||
integer(kind=8), dimension(2) :: ishape, istart, icount | ||
integer(kind=4) :: ierr | ||
integer :: step_status | ||
integer :: in1, in2 | ||
|
||
in1 = 5 | ||
in2 = 10 | ||
|
||
icount = (/in1, in2/) | ||
istart = (/0, 0/) | ||
ishape = (/in1, in2/) | ||
|
||
allocate (temperatures_i4(in1, in2)) | ||
temperatures_i4 = 1 | ||
|
||
! Start adios2 Writer | ||
call adios2_init(adios, ierr) | ||
call adios2_declare_io(ioPut, adios, 'TestWrite', ierr) | ||
|
||
call adios2_define_variable(var_temperatures, ioPut, & | ||
'temperatures_i4', adios2_type_integer4, & | ||
2, ishape, istart, icount, & | ||
adios2_constant_dims, ierr) | ||
call adios2_store_stats_only(var_temperatures, .true., ierr) | ||
|
||
call adios2_open(bpWriter, ioPut, 'TestBPWriteStatsOnly_f.bp', adios2_mode_write, & | ||
ierr) | ||
call adios2_put(bpWriter, var_temperatures, temperatures_i4, ierr) | ||
call adios2_close(bpWriter, ierr) | ||
if (allocated(temperatures_i4)) deallocate (temperatures_i4) | ||
|
||
call adios2_declare_io(ioGet, adios, 'TestRead', ierr) | ||
call adios2_open(bpReader, ioGet, 'TestBPWriteStatsOnly_f.bp', & | ||
adios2_mode_read, ierr) | ||
|
||
call adios2_begin_step(bpReader, adios2_step_mode_read, -1., & | ||
step_status, ierr) | ||
call adios2_inquire_variable(var_temperaturesIn, ioGet, & | ||
'temperatures_i4', ierr) | ||
|
||
allocate (sel_temperatures_i4(ishape(1), ishape(2))) | ||
sel_temperatures_i4 = 0 | ||
|
||
call adios2_get(bpReader, var_temperaturesIn, sel_temperatures_i4, adios2_mode_sync, ierr) | ||
if (ierr == 0) then | ||
write(*,*) 'adios2_get for a variable storing only stats returned without error' | ||
if (allocated(sel_temperatures_i4)) deallocate (sel_temperatures_i4) | ||
call adios2_close(bpReader, ierr) | ||
stop 1 | ||
end if | ||
if (allocated(sel_temperatures_i4)) deallocate (sel_temperatures_i4) | ||
call adios2_close(bpReader, ierr) | ||
|
||
end program TestBPWriteStatsOnly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.