mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-11-03 20:54:07 +01:00
replace offset_data arg with pointer arithmetics
This commit is contained in:
parent
99a234853b
commit
83c926fd6b
@ -2396,8 +2396,8 @@ def has_$group_dset$(trexio_file) -> bool:
|
|||||||
|
|
||||||
#+begin_src c :tangle hrw_dset_sparse_front.h :exports none
|
#+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_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_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 offset_data, const int64_t size, const int32_t* index_sparse, const double* 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_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);
|
//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
|
#+end_src
|
||||||
@ -2408,7 +2408,6 @@ trexio_exit_code trexio_write_$group_sparse_dset$(trexio_t* const file, const in
|
|||||||
trexio_exit_code
|
trexio_exit_code
|
||||||
trexio_read_$group_sparse_dset$(trexio_t* const file,
|
trexio_read_$group_sparse_dset$(trexio_t* const file,
|
||||||
const int64_t offset_file,
|
const int64_t offset_file,
|
||||||
const int64_t offset_data,
|
|
||||||
const int64_t size,
|
const int64_t size,
|
||||||
int32_t* const index_sparse,
|
int32_t* const index_sparse,
|
||||||
double* const value_sparse
|
double* const value_sparse
|
||||||
@ -2435,12 +2434,12 @@ trexio_read_$group_sparse_dset$(trexio_t* const file,
|
|||||||
switch (file->back_end) {
|
switch (file->back_end) {
|
||||||
|
|
||||||
case TREXIO_TEXT:
|
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;
|
break;
|
||||||
|
|
||||||
case TREXIO_HDF5:
|
case TREXIO_HDF5:
|
||||||
#ifdef HAVE_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;
|
break;
|
||||||
#else
|
#else
|
||||||
return TREXIO_BACK_END_MISSING;
|
return TREXIO_BACK_END_MISSING;
|
||||||
@ -2460,7 +2459,6 @@ trexio_read_$group_sparse_dset$(trexio_t* const file,
|
|||||||
trexio_exit_code
|
trexio_exit_code
|
||||||
trexio_write_$group_sparse_dset$(trexio_t* const file,
|
trexio_write_$group_sparse_dset$(trexio_t* const file,
|
||||||
const int64_t offset_file,
|
const int64_t offset_file,
|
||||||
const int64_t offset_data,
|
|
||||||
const int64_t size,
|
const int64_t size,
|
||||||
const int32_t* index_sparse,
|
const int32_t* index_sparse,
|
||||||
const double* value_sparse
|
const double* value_sparse
|
||||||
@ -2487,12 +2485,12 @@ trexio_write_$group_sparse_dset$(trexio_t* const file,
|
|||||||
switch (file->back_end) {
|
switch (file->back_end) {
|
||||||
|
|
||||||
case TREXIO_TEXT:
|
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;
|
break;
|
||||||
|
|
||||||
case TREXIO_HDF5:
|
case TREXIO_HDF5:
|
||||||
#ifdef HAVE_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;
|
break;
|
||||||
#else
|
#else
|
||||||
return TREXIO_BACK_END_MISSING;
|
return TREXIO_BACK_END_MISSING;
|
||||||
|
@ -1005,14 +1005,13 @@ trexio_text_has_$group_str$ (trexio_t* const file)
|
|||||||
|
|
||||||
#+begin_src c :tangle hrw_dset_sparse_text.h :exports none
|
#+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_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_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 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_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
|
#+end_src
|
||||||
|
|
||||||
#+begin_src c :tangle write_dset_sparse_text.c
|
#+begin_src c :tangle write_dset_sparse_text.c
|
||||||
trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file,
|
trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file,
|
||||||
const int64_t offset_file,
|
const int64_t offset_file,
|
||||||
const int64_t offset_dset,
|
|
||||||
const int64_t size,
|
const int64_t size,
|
||||||
const int64_t size_max,
|
const int64_t size_max,
|
||||||
const int32_t* index_sparse,
|
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);
|
//fseek(f, (long) offset_file * line_length, SEEK_SET);
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
for (uint64_t i=0L+offset_dset ; i<size+offset_dset ; ++i) {
|
for (uint64_t i=0L; i<size; ++i) {
|
||||||
rc = fprintf(f, "$group_sparse_dset_format_printf$\n",
|
rc = fprintf(f, "$group_sparse_dset_format_printf$\n",
|
||||||
$group_sparse_dset_indices_printf$,
|
$group_sparse_dset_indices_printf$,
|
||||||
value_sparse[i]);
|
value_sparse[i]);
|
||||||
@ -1068,7 +1067,6 @@ trexio_exit_code trexio_text_write_$group_sparse_dset$(trexio_t* const file,
|
|||||||
#+begin_src c :tangle read_dset_sparse_text.c
|
#+begin_src c :tangle read_dset_sparse_text.c
|
||||||
trexio_exit_code trexio_text_read_$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_file,
|
||||||
const int64_t offset_dset,
|
|
||||||
const int64_t size,
|
const int64_t size,
|
||||||
const int64_t size_max,
|
const int64_t size_max,
|
||||||
int32_t* const index_sparse,
|
int32_t* const index_sparse,
|
||||||
@ -1098,7 +1096,7 @@ trexio_exit_code trexio_text_read_$group_sparse_dset$(trexio_t* const file,
|
|||||||
fseek(f, (long) offset_file * line_length, SEEK_SET);
|
fseek(f, (long) offset_file * line_length, SEEK_SET);
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
for (uint64_t i=0L+offset_dset ; i<size+offset_dset ; ++i) {
|
for (uint64_t i=0L; i<size; ++i) {
|
||||||
rc = fscanf(f, "$group_sparse_dset_format_scanf$",
|
rc = fscanf(f, "$group_sparse_dset_format_scanf$",
|
||||||
$group_sparse_dset_indices_scanf$,
|
$group_sparse_dset_indices_scanf$,
|
||||||
&value_sparse[i]);
|
&value_sparse[i]);
|
||||||
|
@ -55,7 +55,7 @@ int main(){
|
|||||||
|
|
||||||
// write 5 chunks using write_sparse
|
// write 5 chunks using write_sparse
|
||||||
for(int i=0; i<n_chunks; ++i){
|
for(int i=0; i<n_chunks; ++i){
|
||||||
rc = trexio_write_mo_2e_int_eri(trexio_file, offset_f, offset_f, chunk_size, index, value);
|
rc = trexio_write_mo_2e_int_eri(trexio_file, offset_f, chunk_size, &index[4*offset_f], &value[offset_f]);
|
||||||
assert(rc==TREXIO_SUCCESS);
|
assert(rc==TREXIO_SUCCESS);
|
||||||
offset_f += chunk_size;
|
offset_f += chunk_size;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,8 @@ int main(){
|
|||||||
|
|
||||||
// read 1 chunk of 20 elements using offset of 40( i.e. lines No. 40--59)
|
// read 1 chunk of 20 elements using offset of 40( i.e. lines No. 40--59)
|
||||||
uint64_t offset_f_read = 40L;
|
uint64_t offset_f_read = 40L;
|
||||||
rc = trexio_read_mo_2e_int_eri(trexio_file_2, offset_f_read, 0L, chunk_size, index_read, value_read);
|
int offset_data_read = 5;
|
||||||
|
rc = trexio_read_mo_2e_int_eri(trexio_file_2, offset_f_read, 10L, &index_read[4*offset_data_read], &value_read[offset_data_read]);
|
||||||
assert(rc==TREXIO_SUCCESS);
|
assert(rc==TREXIO_SUCCESS);
|
||||||
|
|
||||||
// print the data being read
|
// print the data being read
|
||||||
|
@ -681,8 +681,8 @@ def split_dset_dict_detailed (datasets: dict) -> tuple:
|
|||||||
tmp_dict['group_sparse_dset_format_scanf'] = "%d %d %d %d %lf"
|
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_format_printf'] = "%10d %10d %10d %10d %24.16e"
|
||||||
tmp_dict['group_sparse_dset_line_length'] = "69"
|
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_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_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
|
# add group name as a key-value pair to the dset dict
|
||||||
tmp_dict['group'] = v[2]
|
tmp_dict['group'] = v[2]
|
||||||
|
Loading…
Reference in New Issue
Block a user