gitlab is upgraded to version 13, please report any issues and enjoy

Commit d014b9b7 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Extend the i/o conversion code to allow for conversions to long long

parent 82779ec7
......@@ -808,6 +808,28 @@ void io_convert_part_d_mapper(void* restrict temp, int N,
&temp_d[i * dim]);
}
/**
* @brief Mapper function to copy #part into a buffer of doubles using a
* conversion function.
*/
void io_convert_part_l_mapper(void* restrict temp, int N,
void* restrict extra_data) {
const struct io_props props = *((const struct io_props*)extra_data);
const struct part* restrict parts = props.parts;
const struct xpart* restrict xparts = props.xparts;
const struct engine* e = props.e;
const size_t dim = props.dimension;
/* How far are we with this chunk? */
long long* restrict temp_l = (long long*)temp;
const ptrdiff_t delta = (temp_l - props.start_temp_l) / dim;
for (int i = 0; i < N; i++)
props.convert_part_l(e, parts + delta + i, xparts + delta + i,
&temp_l[i * dim]);
}
/**
* @brief Mapper function to copy #gpart into a buffer of floats using a
* conversion function.
......@@ -848,6 +870,26 @@ void io_convert_gpart_d_mapper(void* restrict temp, int N,
props.convert_gpart_d(e, gparts + delta + i, &temp_d[i * dim]);
}
/**
* @brief Mapper function to copy #gpart into a buffer of doubles using a
* conversion function.
*/
void io_convert_gpart_l_mapper(void* restrict temp, int N,
void* restrict extra_data) {
const struct io_props props = *((const struct io_props*)extra_data);
const struct gpart* restrict gparts = props.gparts;
const struct engine* e = props.e;
const size_t dim = props.dimension;
/* How far are we with this chunk? */
long long* restrict temp_l = (long long*)temp;
const ptrdiff_t delta = (temp_l - props.start_temp_l) / dim;
for (int i = 0; i < N; i++)
props.convert_gpart_l(e, gparts + delta + i, &temp_l[i * dim]);
}
/**
* @brief Mapper function to copy #spart into a buffer of floats using a
* conversion function.
......@@ -888,6 +930,26 @@ void io_convert_spart_d_mapper(void* restrict temp, int N,
props.convert_spart_d(e, sparts + delta + i, &temp_d[i * dim]);
}
/**
* @brief Mapper function to copy #spart into a buffer of doubles using a
* conversion function.
*/
void io_convert_spart_l_mapper(void* restrict temp, int N,
void* restrict extra_data) {
const struct io_props props = *((const struct io_props*)extra_data);
const struct spart* restrict sparts = props.sparts;
const struct engine* e = props.e;
const size_t dim = props.dimension;
/* How far are we with this chunk? */
long long* restrict temp_l = (long long*)temp;
const ptrdiff_t delta = (temp_l - props.start_temp_l) / dim;
for (int i = 0; i < N; i++)
props.convert_spart_l(e, sparts + delta + i, &temp_l[i * dim]);
}
/**
* @brief Copy the particle data into a temporary buffer ready for i/o.
*
......@@ -945,6 +1007,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_part_d_mapper, temp_d, N, copySize, 0,
(void*)&props);
} else if (props.convert_part_l != NULL) {
/* Prepare some parameters */
long long* temp_l = (long long*)temp;
props.start_temp_l = (long long*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
threadpool_map((struct threadpool*)&e->threadpool,
io_convert_part_l_mapper, temp_l, N, copySize, 0,
(void*)&props);
} else if (props.convert_gpart_f != NULL) {
/* Prepare some parameters */
......@@ -969,6 +1043,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_gpart_d_mapper, temp_d, N, copySize, 0,
(void*)&props);
} else if (props.convert_gpart_l != NULL) {
/* Prepare some parameters */
long long* temp_l = (long long*)temp;
props.start_temp_l = (long long*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
threadpool_map((struct threadpool*)&e->threadpool,
io_convert_gpart_l_mapper, temp_l, N, copySize, 0,
(void*)&props);
} else if (props.convert_spart_f != NULL) {
/* Prepare some parameters */
......@@ -993,6 +1079,18 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
io_convert_spart_d_mapper, temp_d, N, copySize, 0,
(void*)&props);
} else if (props.convert_spart_l != NULL) {
/* Prepare some parameters */
long long* temp_l = (long long*)temp;
props.start_temp_l = (long long*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
threadpool_map((struct threadpool*)&e->threadpool,
io_convert_spart_l_mapper, temp_l, N, copySize, 0,
(void*)&props);
} else {
error("Missing conversion function");
}
......
......@@ -43,14 +43,23 @@ typedef void (*conversion_func_part_float)(const struct engine*,
typedef void (*conversion_func_part_double)(const struct engine*,
const struct part*,
const struct xpart*, double*);
typedef void (*conversion_func_part_long_long)(const struct engine*,
const struct part*,
const struct xpart*, long long*);
typedef void (*conversion_func_gpart_float)(const struct engine*,
const struct gpart*, float*);
typedef void (*conversion_func_gpart_double)(const struct engine*,
const struct gpart*, double*);
typedef void (*conversion_func_gpart_long_long)(const struct engine*,
const struct gpart*,
long long*);
typedef void (*conversion_func_spart_float)(const struct engine*,
const struct spart*, float*);
typedef void (*conversion_func_spart_double)(const struct engine*,
const struct spart*, double*);
typedef void (*conversion_func_spart_long_long)(const struct engine*,
const struct spart*,
long long*);
/**
* @brief The properties of a given dataset for i/o
......@@ -79,6 +88,7 @@ struct io_props {
char* start_temp_c;
float* start_temp_f;
double* start_temp_d;
long long* start_temp_l;
/* Pointer to the engine */
const struct engine* e;
......@@ -98,14 +108,17 @@ struct io_props {
/* Conversion function for part */
conversion_func_part_float convert_part_f;
conversion_func_part_double convert_part_d;
conversion_func_part_long_long convert_part_l;
/* Conversion function for gpart */
conversion_func_gpart_float convert_gpart_f;
conversion_func_gpart_double convert_gpart_d;
conversion_func_gpart_long_long convert_gpart_l;
/* Conversion function for spart */
conversion_func_spart_float convert_spart_f;
conversion_func_spart_double convert_spart_d;
conversion_func_spart_long_long convert_spart_l;
};
/**
......@@ -147,10 +160,13 @@ INLINE static struct io_props io_make_input_field_(
r.conversion = 0;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -191,10 +207,13 @@ INLINE static struct io_props io_make_output_field_(
r.conversion = 0;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -242,10 +261,13 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT(
r.conversion = 1;
r.convert_part_f = functionPtr;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -285,10 +307,13 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = functionPtr;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -334,10 +359,13 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT(
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = functionPtr;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -375,10 +403,57 @@ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE(
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = functionPtr;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
/**
* @brief Construct an #io_props from its parameters
*
* @param name Name of the field to read
* @param type The type of the data
* @param dimension Dataset dimension (1D, 3D, ...)
* @param units The units of the dataset
* @param gpartSize The size in byte of the particle
* @param gparts The particle array
* @param functionPtr The function used to convert a g-particle to a double
*
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG(
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_long_long functionPtr) {
struct io_props r;
strcpy(r.name, name);
r.type = type;
r.dimension = dimension;
r.importance = UNUSED;
r.units = units;
r.field = NULL;
r.partSize = gpartSize;
r.parts = NULL;
r.xparts = NULL;
r.gparts = gparts;
r.sparts = NULL;
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = functionPtr;
r.convert_spart_f = NULL;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -424,10 +499,13 @@ INLINE static struct io_props io_make_output_field_convert_spart_FLOAT(
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = functionPtr;
r.convert_spart_d = NULL;
r.convert_spart_l = NULL;
return r;
}
......@@ -465,10 +543,13 @@ INLINE static struct io_props io_make_output_field_convert_spart_DOUBLE(
r.conversion = 1;
r.convert_part_f = NULL;
r.convert_part_d = NULL;
r.convert_part_l = NULL;
r.convert_gpart_f = NULL;
r.convert_gpart_d = NULL;
r.convert_gpart_l = NULL;
r.convert_spart_f = NULL;
r.convert_spart_d = functionPtr;
r.convert_spart_l = NULL;
return r;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment