Skip to content

Commit

Permalink
small
Browse files Browse the repository at this point in the history
  • Loading branch information
jinluchang committed Sep 20, 2024
1 parent c9498d9 commit 247ad27
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion examples-cpp/fields-io-simple-demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,40 @@ inline void demo()
get_shuffled_fields_writer(path, new_size_node, is_append);
const Coordinate total_site = Coordinate(4, 4, 4, 8);
const Geometry geo(total_site);
const RngState rs = RngState("seed");
//
Field<Complex> f1;
f1.init(geo, 2);
write_field(f1, path, "f1");
set_zero(f1);
set_u_rand_double(f1, rs.split("f1"));
const crc32_t crc_f1 = field_crc32(f1);
Field<ComplexF> f2;
f2.init(geo, 3);
set_zero(f2);
set_u_rand_float(f2, rs.split("f2"));
const crc32_t crc_f2 = field_crc32(f2);
//
write_field(f1, path, "f1");
write_field(f2, path, "f2");
clear_shuffled_fields_writer_cache();
//
Field<Complex> f1r;
Field<ComplexF> f2r;
//
read_field(f1r, path, "f1");
read_field(f2r, path, "f2");
clear_shuffled_fields_reader_cache();
//
const crc32_t crc_f1r = field_crc32(f1r);
qassert(crc_f1 == crc_f1r);
const crc32_t crc_f2r = field_crc32(f2r);
qassert(crc_f2 == crc_f2r);
}

int main(int argc, char* argv[])
{
begin(&argc, &argv);
demo();
displayln_info("CHECK: finished successfully.");
Timer::display();
end();
Expand Down

0 comments on commit 247ad27

Please sign in to comment.