Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
SWIFTsim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
69
Issues
69
List
Boards
Labels
Milestones
Merge Requests
11
Merge Requests
11
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SWIFT
SWIFTsim
Commits
3629ccc3
Commit
3629ccc3
authored
Jul 23, 2020
by
Loic Hausammann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove string argument in some logger function
parent
d00218b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
96 deletions
+49
-96
src/gravity/MultiSoftening/gravity_logger.h
src/gravity/MultiSoftening/gravity_logger.h
+12
-19
src/hydro/Gadget2/hydro_logger.h
src/hydro/Gadget2/hydro_logger.h
+20
-33
src/logger_io.h
src/logger_io.h
+1
-19
src/stars/Default/stars_logger.h
src/stars/Default/stars_logger.h
+16
-25
No files found.
src/gravity/MultiSoftening/gravity_logger.h
View file @
3629ccc3
...
...
@@ -44,8 +44,7 @@ static const char *gravity_logger_field_names[gravity_logger_field_count] = {
/**
* @brief Initialize the logger.
*
* WARNING: this should be done in the same order than
* #gravity_logger_write_particle.
* WARNING: The order should be the same in all the functions!
*
* @param mask_data Data for each type of mask.
*
...
...
@@ -78,6 +77,8 @@ INLINE static int gravity_logger_populate_mask_data(
/**
* @brief Generates the mask and compute the size of the record.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #gravity_logger_init).
* @param part The #gpart that will be written.
* @param write_all Are we forcing to write all the fields?
...
...
@@ -94,35 +95,32 @@ INLINE static void gravity_logger_compute_size_and_mask(
/* Add the coordinates. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
gravity_logger_field_coordinates
],
gravity_logger_field_names
[
gravity_logger_field_coordinates
],
buffer_size
);
/* Add the velocities. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
gravity_logger_field_velocities
],
gravity_logger_field_names
[
gravity_logger_field_velocities
],
buffer_size
);
masks
[
gravity_logger_field_velocities
],
buffer_size
);
/* Add the accelerations. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
gravity_logger_field_accelerations
],
gravity_logger_field_names
[
gravity_logger_field_accelerations
],
buffer_size
);
/* Add the masses. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
gravity_logger_field_masses
],
gravity_logger_field_names
[
gravity_logger_field_masses
],
buffer_size
);
masks
[
gravity_logger_field_masses
],
buffer_size
);
/* Add the ID. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
gravity_logger_field_particle_ids
],
gravity_logger_field_names
[
gravity_logger_field_particle_ids
],
buffer_size
);
}
/**
* @brief Write a particle to the logger.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #gravity_logger_init).
* @param p The #gpart to write.
* @param mask The mask to use for this record.
...
...
@@ -136,40 +134,35 @@ INLINE static char *gravity_logger_write_particle(
/* Write the coordinate. */
if
(
logger_should_write_field
(
mask_data
[
gravity_logger_field_coordinates
],
mask
,
gravity_logger_field_names
[
gravity_logger_field_coordinates
]))
{
mask_data
[
gravity_logger_field_coordinates
],
mask
))
{
memcpy
(
buff
,
p
->
x
,
3
*
sizeof
(
double
));
buff
+=
3
*
sizeof
(
double
);
}
/* Write the velocity. */
if
(
logger_should_write_field
(
mask_data
[
gravity_logger_field_velocities
],
mask
,
gravity_logger_field_names
[
gravity_logger_field_velocities
]))
{
mask_data
[
gravity_logger_field_velocities
],
mask
))
{
memcpy
(
buff
,
p
->
v_full
,
3
*
sizeof
(
float
));
buff
+=
3
*
sizeof
(
float
);
}
/* Write the acceleration. */
if
(
logger_should_write_field
(
mask_data
[
gravity_logger_field_accelerations
],
mask
,
gravity_logger_field_names
[
gravity_logger_field_accelerations
]))
{
mask_data
[
gravity_logger_field_accelerations
],
mask
))
{
memcpy
(
buff
,
p
->
a_grav
,
3
*
sizeof
(
float
));
buff
+=
3
*
sizeof
(
float
);
}
/* Write the mass. */
if
(
logger_should_write_field
(
mask_data
[
gravity_logger_field_masses
],
mask
,
gravity_logger_field_names
[
gravity_logger_field_masses
]))
{
mask_data
[
gravity_logger_field_masses
],
mask
))
{
memcpy
(
buff
,
&
p
->
mass
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the Id. */
if
(
logger_should_write_field
(
mask_data
[
gravity_logger_field_particle_ids
],
mask
,
gravity_logger_field_names
[
gravity_logger_field_particle_ids
]))
{
mask_data
[
gravity_logger_field_particle_ids
],
mask
))
{
memcpy
(
buff
,
&
p
->
id_or_neg_offset
,
sizeof
(
long
long
));
buff
+=
sizeof
(
long
long
);
}
...
...
src/hydro/Gadget2/hydro_logger.h
View file @
3629ccc3
...
...
@@ -47,8 +47,7 @@ static const char *hydro_logger_field_names[hydro_logger_field_count] = {
/**
* @brief Initialize the logger.
*
* WARNING: this should be done in the same order than
* #hydro_logger_write_particle.
* WARNING: The order should be the same in all the functions!
*
* @param mask_data Data for each type of mask.
*
...
...
@@ -90,6 +89,8 @@ INLINE static int hydro_logger_populate_mask_data(struct mask_data *mask_data) {
/**
* @brief Generates the mask and compute the size of the record.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #hydro_logger_init).
* @param part The #part that will be written.
* @param xpart The #xpart that will be written.
...
...
@@ -107,49 +108,43 @@ INLINE static void hydro_logger_compute_size_and_mask(
/* Add the coordinates. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_coordinates
],
hydro_logger_field_names
[
hydro_logger_field_coordinates
],
buffer_size
);
masks
[
hydro_logger_field_coordinates
],
buffer_size
);
/* Add the velocities. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_velocities
],
hydro_logger_field_names
[
hydro_logger_field_velocities
],
buffer_size
);
masks
[
hydro_logger_field_velocities
],
buffer_size
);
/* Add the accelerations. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_accelerations
],
hydro_logger_field_names
[
hydro_logger_field_accelerations
],
buffer_size
);
masks
[
hydro_logger_field_accelerations
],
buffer_size
);
/* Add the masses. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_masses
],
hydro_logger_field_names
[
hydro_logger_field_masses
],
buffer_size
);
masks
[
hydro_logger_field_masses
],
buffer_size
);
/* Add the smoothing lengths. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_smoothing_lengths
],
hydro_logger_field_names
[
hydro_logger_field_smoothing_lengths
],
buffer_size
);
/* Add the entropies. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_entropies
],
hydro_logger_field_names
[
hydro_logger_field_entropies
],
buffer_size
);
masks
[
hydro_logger_field_entropies
],
buffer_size
);
/* Add the ID. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_particle_ids
],
hydro_logger_field_names
[
hydro_logger_field_particle_ids
],
buffer_size
);
masks
[
hydro_logger_field_particle_ids
],
buffer_size
);
/* Add the density. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
hydro_logger_field_densities
],
hydro_logger_field_names
[
hydro_logger_field_densities
],
buffer_size
);
masks
[
hydro_logger_field_densities
],
buffer_size
);
}
/**
* @brief Write a particle to the logger.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #hydro_logger_init).
* @param p The #part to write.
* @param xp The #xpart to write.
...
...
@@ -164,24 +159,21 @@ INLINE static char *hydro_logger_write_particle(
/* Write the coordinate. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_coordinates
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_coordinates
]))
{
mask_data
[
hydro_logger_field_coordinates
],
mask
))
{
memcpy
(
buff
,
p
->
x
,
3
*
sizeof
(
double
));
buff
+=
3
*
sizeof
(
double
);
}
/* Write the velocity. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_velocities
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_velocities
]))
{
mask_data
[
hydro_logger_field_velocities
],
mask
))
{
memcpy
(
buff
,
p
->
v
,
3
*
sizeof
(
float
));
buff
+=
3
*
sizeof
(
float
);
}
/* Write the acceleration. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_accelerations
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_accelerations
]))
{
mask_data
[
hydro_logger_field_accelerations
],
mask
))
{
/* Compute the acceleration due to hydro and gravity */
float
*
acc
=
(
float
*
)
buff
;
...
...
@@ -195,40 +187,35 @@ INLINE static char *hydro_logger_write_particle(
/* Write the mass. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_masses
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_masses
]))
{
mask_data
[
hydro_logger_field_masses
],
mask
))
{
memcpy
(
buff
,
&
p
->
mass
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the smoothing length. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_smoothing_lengths
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_smoothing_lengths
]))
{
mask_data
[
hydro_logger_field_smoothing_lengths
],
mask
))
{
memcpy
(
buff
,
&
p
->
h
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the entropy. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_entropies
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_entropies
]))
{
mask_data
[
hydro_logger_field_entropies
],
mask
))
{
memcpy
(
buff
,
&
p
->
entropy
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the Id. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_particle_ids
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_particle_ids
]))
{
mask_data
[
hydro_logger_field_particle_ids
],
mask
))
{
memcpy
(
buff
,
&
p
->
id
,
sizeof
(
long
long
));
buff
+=
sizeof
(
long
long
);
}
/* Write the density. */
if
(
logger_should_write_field
(
mask_data
[
hydro_logger_field_densities
],
mask
,
hydro_logger_field_names
[
hydro_logger_field_densities
]))
{
mask_data
[
hydro_logger_field_densities
],
mask
))
{
memcpy
(
buff
,
&
p
->
rho
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
...
...
src/logger_io.h
View file @
3629ccc3
...
...
@@ -80,22 +80,13 @@ INLINE static struct mask_data logger_create_mask_entry(const char* name,
*
* @param mask_data The mask_data corresponding to the field that we wish to
* write.
* @param name The name of the field.
* @param buffer_size (in) The current size of the future buffer. (out) The
* updated size.
*
* @return The mask of the current field.
*/
INLINE
static
size_t
logger_add_field_to_mask
(
struct
mask_data
mask_data
,
const
char
*
name
,
size_t
*
buffer_size
)
{
#ifdef SWIFT_DEBUG_CHECKS
/* Check that we are writing the requested field. */
if
(
strcmp
(
name
,
mask_data
.
name
)
!=
0
)
{
error
(
"Mismatch between the requested field (%s) and the mask (%s)"
,
name
,
mask_data
.
name
);
}
#endif
*
buffer_size
+=
mask_data
.
size
;
return
mask_data
.
mask
;
...
...
@@ -106,19 +97,10 @@ INLINE static size_t logger_add_field_to_mask(struct mask_data mask_data,
* #logger_add_field_to_mask.
*
* @param mask_data The mask_data corresponding to the current field.
* @param name The name of the field that we are checking.
* @param mask The mask used for the current record.
*/
INLINE
static
int
logger_should_write_field
(
struct
mask_data
mask_data
,
unsigned
int
*
mask
,
const
char
*
name
)
{
#ifdef SWIFT_DEBUG_CHECKS
/* Check that we are writing the requested field. */
if
(
strcmp
(
name
,
mask_data
.
name
)
!=
0
)
{
error
(
"Mismatch between the requested field (%s) and the mask (%s)"
,
name
,
mask_data
.
name
);
}
#endif
unsigned
int
*
mask
)
{
const
int
test
=
mask_data
.
mask
&
*
mask
;
if
(
test
)
{
...
...
src/stars/Default/stars_logger.h
View file @
3629ccc3
...
...
@@ -44,8 +44,7 @@ static const char *stars_logger_field_names[stars_logger_field_count] = {
/**
* @brief Initialize the logger.
*
* WARNING: this should be done in the same order than
* #stars_logger_write_particle.
* WARNING: The order should be the same in all the functions!
*
* @param mask_data Data for each type of mask.
*
...
...
@@ -81,6 +80,8 @@ INLINE static int stars_logger_populate_mask_data(struct mask_data *mask_data) {
/**
* @brief Generates the mask and compute the size of the record.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #stars_logger_init).
* @param part The #spart that will be written.
* @param write_all Are we forcing to write all the fields?
...
...
@@ -96,39 +97,35 @@ INLINE static void stars_logger_compute_size_and_mask(
/* Add the coordinates. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_coordinates
],
stars_logger_field_names
[
stars_logger_field_coordinates
],
buffer_size
);
masks
[
stars_logger_field_coordinates
],
buffer_size
);
/* Add the velocities. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_velocities
],
stars_logger_field_names
[
stars_logger_field_velocities
],
buffer_size
);
masks
[
stars_logger_field_velocities
],
buffer_size
);
/* Add the accelerations. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_accelerations
],
stars_logger_field_names
[
stars_logger_field_accelerations
],
buffer_size
);
masks
[
stars_logger_field_accelerations
],
buffer_size
);
/* Add the masses. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_masses
],
stars_logger_field_names
[
stars_logger_field_masses
],
buffer_size
);
masks
[
stars_logger_field_masses
],
buffer_size
);
/* Add the smoothing lengths. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_smoothing_lengths
],
stars_logger_field_names
[
stars_logger_field_smoothing_lengths
],
buffer_size
);
/* Add the ID. */
*
mask
|=
logger_add_field_to_mask
(
masks
[
stars_logger_field_particle_ids
],
stars_logger_field_names
[
stars_logger_field_particle_ids
],
buffer_size
);
masks
[
stars_logger_field_particle_ids
],
buffer_size
);
}
/**
* @brief Write a particle to the logger.
*
* WARNING: The order should be the same in all the functions!
*
* @param masks The list of masks (same order than in #stars_logger_init).
* @param p The #spart to write.
* @param mask The mask to use for this record.
...
...
@@ -142,48 +139,42 @@ INLINE static char *stars_logger_write_particle(
/* Write the coordinate. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_coordinates
],
mask
,
stars_logger_field_names
[
stars_logger_field_coordinates
]))
{
mask_data
[
stars_logger_field_coordinates
],
mask
))
{
memcpy
(
buff
,
p
->
x
,
3
*
sizeof
(
double
));
buff
+=
3
*
sizeof
(
double
);
}
/* Write the velocity. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_velocities
],
mask
,
stars_logger_field_names
[
stars_logger_field_velocities
]))
{
mask_data
[
stars_logger_field_velocities
],
mask
))
{
memcpy
(
buff
,
p
->
v
,
3
*
sizeof
(
float
));
buff
+=
3
*
sizeof
(
float
);
}
/* Write the acceleration. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_accelerations
],
mask
,
stars_logger_field_names
[
stars_logger_field_accelerations
]))
{
mask_data
[
stars_logger_field_accelerations
],
mask
))
{
memcpy
(
buff
,
p
->
gpart
->
a_grav
,
3
*
sizeof
(
float
));
buff
+=
3
*
sizeof
(
float
);
}
/* Write the mass. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_masses
],
mask
,
stars_logger_field_names
[
stars_logger_field_masses
]))
{
mask_data
[
stars_logger_field_masses
],
mask
))
{
memcpy
(
buff
,
&
p
->
mass
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the smoothing length. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_smoothing_lengths
],
mask
,
stars_logger_field_names
[
stars_logger_field_smoothing_lengths
]))
{
mask_data
[
stars_logger_field_smoothing_lengths
],
mask
))
{
memcpy
(
buff
,
&
p
->
h
,
sizeof
(
float
));
buff
+=
sizeof
(
float
);
}
/* Write the Id. */
if
(
logger_should_write_field
(
mask_data
[
stars_logger_field_particle_ids
],
mask
,
stars_logger_field_names
[
stars_logger_field_particle_ids
]))
{
mask_data
[
stars_logger_field_particle_ids
],
mask
))
{
memcpy
(
buff
,
&
p
->
id
,
sizeof
(
long
long
));
buff
+=
sizeof
(
long
long
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment