Skip to content
Snippets Groups Projects
Commit be5d3966 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also use the new mechanism when doing i/o with parallel-hdf5

parent 2e33483d
No related branches found
No related tags found
1 merge request!460Improvements to i/o and parallel-i/o
...@@ -254,6 +254,7 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id, ...@@ -254,6 +254,7 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id,
const size_t typeSize = io_sizeof_type(props.type); const size_t typeSize = io_sizeof_type(props.type);
const size_t copySize = typeSize * props.dimension; const size_t copySize = typeSize * props.dimension;
const size_t num_elements = N * props.dimension; const size_t num_elements = N * props.dimension;
const size_t dim = props.dimension;
/* Can't handle writes of more than 2GB */ /* Can't handle writes of more than 2GB */
if (N * props.dimension * typeSize > HDF5_PARALLEL_IO_MAX_BYTES) if (N * props.dimension * typeSize > HDF5_PARALLEL_IO_MAX_BYTES)
...@@ -265,25 +266,59 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id, ...@@ -265,25 +266,59 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id,
void* temp = malloc(num_elements * typeSize); void* temp = malloc(num_elements * typeSize);
if (temp == NULL) error("Unable to allocate memory for temporary buffer"); if (temp == NULL) error("Unable to allocate memory for temporary buffer");
/* Copy particle data to temporary buffer */ /* Copy particle data to temporary buffer */
if (props.convert_part == NULL && if (props.conversion == 0) { /* No conversion */
props.convert_gpart == NULL) { /* No conversion */
char* temp_c = temp; char* temp_c = temp;
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize); memcpy(&temp_c[i * copySize], props.field + i * props.partSize, copySize);
} else if (props.convert_part != NULL) { /* conversion (for parts)*/ } else { /* Converting particle to data */
float* temp_f = temp; if (props.convert_part_f != NULL) {
for (size_t i = 0; i < N; ++i)
temp_f[i] = props.convert_part(e, &props.parts[i]);
} else if (props.convert_gpart != NULL) { /* conversion (for gparts)*/ swift_declare_aligned_ptr(float, temp_f, temp, SWIFT_CACHE_ALIGNMENT);
swift_declare_aligned_ptr(const struct part, parts, props.parts,
SWIFT_STRUCT_ALIGNMENT);
float* temp_f = temp; /* float conversion for parts */
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; i++)
temp_f[i] = props.convert_gpart(e, &props.gparts[i]); props.convert_part_f(e, &parts[i], &temp_f[i * dim]);
} else if (props.convert_part_d != NULL) {
swift_declare_aligned_ptr(double, temp_d, temp, SWIFT_CACHE_ALIGNMENT);
swift_declare_aligned_ptr(const struct part, parts, props.parts,
SWIFT_STRUCT_ALIGNMENT);
/* double conversion for parts */
for (size_t i = 0; i < N; i++)
props.convert_part_d(e, &parts[i], &temp_d[i * dim]);
} else if (props.convert_gpart_f != NULL) {
swift_declare_aligned_ptr(float, temp_f, temp, SWIFT_CACHE_ALIGNMENT);
swift_declare_aligned_ptr(const struct gpart, gparts, props.gparts,
SWIFT_STRUCT_ALIGNMENT);
/* float conversion for gparts */
for (size_t i = 0; i < N; i++)
props.convert_gpart_f(e, &gparts[i], &temp_f[i * dim]);
} else if (props.convert_gpart_d != NULL) {
swift_declare_aligned_ptr(double, temp_d, temp, SWIFT_CACHE_ALIGNMENT);
swift_declare_aligned_ptr(const struct gpart, gparts, props.gparts,
SWIFT_STRUCT_ALIGNMENT);
/* double conversion for gparts */
for (size_t i = 0; i < N; i++)
props.convert_gpart_d(e, &gparts[i], &temp_d[i * dim]);
} else {
error("Missing conversion function");
}
} }
/* Unit conversion if necessary */ /* Unit conversion if necessary */
...@@ -294,10 +329,10 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id, ...@@ -294,10 +329,10 @@ void writeArray_chunk(struct engine* e, hid_t h_data, hid_t h_plist_id,
/* message("Converting ! factor=%e", factor); */ /* message("Converting ! factor=%e", factor); */
if (io_is_double_precision(props.type)) { if (io_is_double_precision(props.type)) {
double* temp_d = temp; swift_declare_aligned_ptr(double, temp_d, temp, SWIFT_CACHE_ALIGNMENT);
for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor; for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor;
} else { } else {
float* temp_f = temp; swift_declare_aligned_ptr(float, temp_f, temp, SWIFT_CACHE_ALIGNMENT);
for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor; for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment