Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature io load #158

Merged
merged 11 commits into from
Jan 18, 2024
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ uninstall-hook:
## (for instance, a .o file), then mostlyclean should delete it.
## Otherwise, if make built it, then clean should delete it.
clean-local:
rm -f ChangeLog
rm -f ChangeLog sc_test_io_file.*

## If configure built it, then distclean should delete it.
distclean-local:
Expand Down
10 changes: 8 additions & 2 deletions doc/release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ There have been breaking changes, very strictly speaking.
### Documentation

- Begin maintaining a release notes file.
- Add to documentation of sc_containers.h.
- Completion and some polishing of the doxygen documentation in sc_io.h.
- Add the scda (file-oriented data format suitable for parallel,
partition-independent disk I/O) API including its documentation in sc_scda.h.
Expand All @@ -24,16 +25,21 @@ There have been breaking changes, very strictly speaking.
### Build system

- No longer install getopt and puff original headers.
- Further align CMake with the autoconf build system.
- Make sc_getopt.h a purely internal header file.
- Add a generic external library installation option.
- Add script doc/p4est-build-wdeps.sh for autotools build.
- Further align CMake with the autoconf build system.
- Update CMake logic to configure zlib and jansson.
- Make sc_getopt.h a purely internal header file.
- Add CMake option to run tests with Valgrind

### Functionality

- Further align I/O wrappers with and without MPI I/O.
- Simplify the replacements for MPI_{read,write}_at*.
- Further updates to the MPI I/O wrapper code.
- Add sc_io_source, sink_destroy_null functions.
- Make sure not to sc_io_source_read an array beyond its length.
- Add sc_io_file_load, save functions and test program.
- Update zlib and base64 encode/compression routines.

## 2.8.5
Expand Down
40 changes: 28 additions & 12 deletions src/sc_containers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,16 @@ sc_hash_print_statistics (int package_id, int log_priority, sc_hash_t * hash)

/* hash array routines */

struct sc_hash_array_data
{
sc_hash_array_t the_hash_array;
sc_array_t *pa;
sc_hash_function_t hash_fn;
sc_equal_function_t equal_fn;
void *user_data;
void *current_item;
};

size_t
sc_hash_array_memory_used (sc_hash_array_t * ha)
{
Expand Down Expand Up @@ -1560,17 +1570,22 @@ sc_hash_array_new (size_t elem_size, sc_hash_function_t hash_fn,
sc_equal_function_t equal_fn, void *user_data)
{
sc_hash_array_t *hash_array;
sc_hash_array_data_t *had;

hash_array = SC_ALLOC (sc_hash_array_t, 1);
/* save one allocation by storing the hash array inside its context */
had = SC_ALLOC (sc_hash_array_data_t, 1);
hash_array = &had->the_hash_array;
hash_array->internal_data = had;

/* initialize all members */
sc_array_init (&hash_array->a, elem_size);
hash_array->internal_data.pa = &hash_array->a;
hash_array->internal_data.hash_fn = hash_fn;
hash_array->internal_data.equal_fn = equal_fn;
hash_array->internal_data.user_data = user_data;
hash_array->internal_data.current_item = NULL;
had->pa = &hash_array->a;
had->hash_fn = hash_fn;
had->equal_fn = equal_fn;
had->user_data = user_data;
had->current_item = NULL;
hash_array->h = sc_hash_new (sc_hash_array_hash_fn, sc_hash_array_equal_fn,
&hash_array->internal_data, NULL);
had, NULL);

return hash_array;
}
Expand All @@ -1581,7 +1596,8 @@ sc_hash_array_destroy (sc_hash_array_t * hash_array)
sc_hash_destroy (hash_array->h);
sc_array_reset (&hash_array->a);

SC_FREE (hash_array);
/* the hash_array memory lives as part of internal data */
SC_FREE (hash_array->internal_data);
}

int
Expand Down Expand Up @@ -1615,9 +1631,9 @@ sc_hash_array_lookup (sc_hash_array_t * hash_array, void *v, size_t *position)
int found;
void **found_void;

hash_array->internal_data.current_item = v;
hash_array->internal_data->current_item = v;
found = sc_hash_lookup (hash_array->h, (void *) (-1L), &found_void);
hash_array->internal_data.current_item = NULL;
hash_array->internal_data->current_item = NULL;

if (found) {
if (position != NULL) {
Expand All @@ -1639,9 +1655,9 @@ sc_hash_array_insert_unique (sc_hash_array_t * hash_array, void *v,

SC_ASSERT (hash_array->a.elem_count == hash_array->h->elem_count);

hash_array->internal_data.current_item = v;
hash_array->internal_data->current_item = v;
added = sc_hash_insert_unique (hash_array->h, (void *) (-1L), &found_void);
hash_array->internal_data.current_item = NULL;
hash_array->internal_data->current_item = NULL;

if (added) {
if (position != NULL) {
Expand Down
Loading