From 83c926fd6bd80c790456b10acf6e98abcc2bf7d5 Mon Sep 17 00:00:00 2001 From: q-posev Date: Wed, 1 Dec 2021 09:56:31 +0100 Subject: [PATCH] replace offset_data arg with pointer arithmetics --- src/templates_front/templator_front.org | 14 ++++++-------- src/templates_text/templator_text.org | 10 ++++------ tests/io_dset_sparse_text.c | 5 +++-- tools/generator_tools.py | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 41faa44..c12227e 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -2396,8 +2396,8 @@ def has_$group_dset$(trexio_file) -> bool: #+begin_src c :tangle hrw_dset_sparse_front.h :exports none trexio_exit_code trexio_has_$group_sparse_dset$(trexio_t* const file); -trexio_exit_code trexio_read_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t offset_data, const int64_t size, int32_t* const index_sparse, double* const value_sparse); -trexio_exit_code trexio_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t offset_data, const int64_t size, const int32_t* index_sparse, const double* value_sparse); +trexio_exit_code trexio_read_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t size, int32_t* const index_sparse, double* const value_sparse); +trexio_exit_code trexio_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t size, const int32_t* index_sparse, const double* value_sparse); //trexio_exit_code trexio_read_$group_sparse_dset$_value(trexio_t* const file, const uint64_t offset, const uint_64_t size, int32_t* const value_sparse); //trexio_exit_code trexio_write_$group_sparse_dset$_value(trexio_t* const file, const uint64_t offset, const uint_64_t size, double* const value_sparse); #+end_src @@ -2408,7 +2408,6 @@ trexio_exit_code trexio_write_$group_sparse_dset$(trexio_t* const file, const in trexio_exit_code trexio_read_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, - const int64_t offset_data, const int64_t size, int32_t* const index_sparse, double* const value_sparse @@ -2435,12 +2434,12 @@ trexio_read_$group_sparse_dset$(trexio_t* const file, switch (file->back_end) { case TREXIO_TEXT: - return trexio_text_read_$group_sparse_dset$(file, offset_file, offset_data, size, size_max, index_sparse, value_sparse); + return trexio_text_read_$group_sparse_dset$(file, offset_file, size, size_max, index_sparse, value_sparse); break; case TREXIO_HDF5: #ifdef HAVE_HDF5 - return trexio_hdf5_read_$group_sparse_dset$(file, offset_file, offset_data, size, size_max, index_sparse, value_sparse); + return trexio_hdf5_read_$group_sparse_dset$(file, offset_file, size, size_max, index_sparse, value_sparse); break; #else return TREXIO_BACK_END_MISSING; @@ -2460,7 +2459,6 @@ trexio_read_$group_sparse_dset$(trexio_t* const file, trexio_exit_code trexio_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, - const int64_t offset_data, const int64_t size, const int32_t* index_sparse, const double* value_sparse @@ -2487,12 +2485,12 @@ trexio_write_$group_sparse_dset$(trexio_t* const file, switch (file->back_end) { case TREXIO_TEXT: - return trexio_text_write_$group_sparse_dset$(file, offset_file, offset_data, size, size_max, index_sparse, value_sparse); + return trexio_text_write_$group_sparse_dset$(file, offset_file, size, size_max, index_sparse, value_sparse); break; case TREXIO_HDF5: #ifdef HAVE_HDF5 - return trexio_hdf5_write_$group_sparse_dset$(file, offset_file, offset_data, size, size_max, index_sparse, value_sparse); + return trexio_hdf5_write_$group_sparse_dset$(file, offset_file, size, size_max, index_sparse, value_sparse); break; #else return TREXIO_BACK_END_MISSING; diff --git a/src/templates_text/templator_text.org b/src/templates_text/templator_text.org index a1ec0d1..f9ed7fd 100644 --- a/src/templates_text/templator_text.org +++ b/src/templates_text/templator_text.org @@ -1005,14 +1005,13 @@ trexio_text_has_$group_str$ (trexio_t* const file) #+begin_src c :tangle hrw_dset_sparse_text.h :exports none trexio_exit_code trexio_text_has_$group_sparse_dset$(trexio_t* const file); -trexio_exit_code trexio_text_read_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t offset_dset, const int64_t size, const int64_t size_max, int32_t* const index_sparse, double* const value_sparse); -trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t offset_dset, const int64_t size, const int64_t size_max, const int32_t* index_sparse, const double* value_sparse); +trexio_exit_code trexio_text_read_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t size, const int64_t size_max, int32_t* const index_sparse, double* const value_sparse); +trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, const int64_t size, const int64_t size_max, const int32_t* index_sparse, const double* value_sparse); #+end_src #+begin_src c :tangle write_dset_sparse_text.c trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file, const int64_t offset_file, - const int64_t offset_dset, const int64_t size, const int64_t size_max, const int32_t* index_sparse, @@ -1042,7 +1041,7 @@ trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file, //fseek(f, (long) offset_file * line_length, SEEK_SET); int rc; - for (uint64_t i=0L+offset_dset ; i tuple: tmp_dict['group_sparse_dset_format_scanf'] = "%d %d %d %d %lf" tmp_dict['group_sparse_dset_format_printf'] = "%10d %10d %10d %10d %24.16e" tmp_dict['group_sparse_dset_line_length'] = "69" - tmp_dict['group_sparse_dset_indices_printf'] = "index_sparse[4*i], index_sparse[4*i+1], index_sparse[4*i+2], index_sparse[4*i+3]" - tmp_dict['group_sparse_dset_indices_scanf'] = "&index_sparse[4*i], &index_sparse[4*i+1], &index_sparse[4*i+2], &index_sparse[4*i+3]" + tmp_dict['group_sparse_dset_indices_printf'] = "*(index_sparse + 4*i), *(index_sparse + 4*i+1), *(index_sparse + 4*i+2), *(index_sparse + 4*i+3)" + tmp_dict['group_sparse_dset_indices_scanf'] = "index_sparse + 4*i, index_sparse + 4*i+1, index_sparse + 4*i+2, index_sparse + 4*i+3" # add group name as a key-value pair to the dset dict tmp_dict['group'] = v[2]