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
70
Issues
70
List
Boards
Labels
Milestones
Merge Requests
16
Merge Requests
16
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
a583f145
Commit
a583f145
authored
May 28, 2018
by
lhausamm
Committed by
Loic Hausammann
Oct 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove engine from logger_init and fix testLogger
parent
b26d0fb5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
37 deletions
+44
-37
src/engine.c
src/engine.c
+1
-1
src/logger.c
src/logger.c
+1
-1
src/logger.h
src/logger.h
+1
-1
src/logger_struct.h
src/logger_struct.h
+5
-1
tests/logger.yml
tests/logger.yml
+5
-0
tests/testLogger.c
tests/testLogger.c
+31
-33
No files found.
src/engine.c
View file @
a583f145
...
...
@@ -6705,7 +6705,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
#if defined(WITH_LOGGER)
e
->
log
=
(
struct
logger
*
)
malloc
(
sizeof
(
struct
logger
));
logger_init
(
e
->
log
,
params
,
e
);
logger_init
(
e
->
log
,
params
);
#endif
/* Make the space link back to the engine. */
...
...
src/logger.c
View file @
a583f145
...
...
@@ -403,7 +403,7 @@ void logger_ensure_size(
* @param params The #swift_params
* @param e The #engine
*/
void
logger_init
(
struct
logger
*
log
,
const
struct
swift_params
*
params
,
const
struct
engine
*
e
)
{
void
logger_init
(
struct
logger
*
log
,
const
struct
swift_params
*
params
)
{
/* read parameters */
log
->
delta_step
=
parser_get_param_int
(
params
,
"Logger:delta_step"
);
log
->
buffer_size
=
parser_get_param_float
(
params
,
"Logger:mmaped_buffer_size"
)
*
1e9
;
...
...
src/logger.h
View file @
a583f145
...
...
@@ -115,7 +115,7 @@ int logger_compute_chunk_size(unsigned int mask);
void
logger_log_all
(
struct
logger
*
log
,
const
struct
engine
*
e
);
void
logger_log_part
(
struct
logger
*
log
,
const
struct
part
*
p
,
unsigned
int
mask
,
size_t
*
offset
);
void
logger_log_gpart
(
struct
logger
*
log
,
const
struct
gpart
*
p
,
unsigned
int
mask
,
size_t
*
offset
);
void
logger_init
(
struct
logger
*
log
,
const
struct
swift_params
*
params
,
const
struct
engine
*
e
);
void
logger_init
(
struct
logger
*
log
,
const
struct
swift_params
*
params
);
void
logger_clean
(
struct
logger
*
log
);
void
logger_log_timestamp
(
struct
logger
*
log
,
integertime_t
t
,
size_t
*
offset
);
void
logger_ensure_size
(
struct
logger
*
log
,
size_t
total_nr_parts
,
...
...
src/logger_struct.h
View file @
a583f145
...
...
@@ -21,9 +21,13 @@
#ifdef WITH_LOGGER
#define LOGGER_STRING_LENGTH 200
#include <limits.h>
/* Local Includes */
#include "dump.h"
#define LOGGER_STRING_LENGTH 200
/* parameters of the logger */
struct
logger_parameters
{
/* size of a label in bytes */
...
...
tests/logger.yml
0 → 100644
View file @
a583f145
# Parameters governing the logger snapshot system
Logger
:
delta_step
:
10
# (Optional) Update the particle log every this many updates
mmaped_buffer_size
:
.01
# buffer size in GB
basename
:
indice
# Common part of the filenames
tests/testLogger.c
View file @
a583f145
...
...
@@ -31,7 +31,8 @@
/* Local headers. */
#include "swift.h"
void
test_log_parts
(
struct
dump
*
d
)
{
void
test_log_parts
(
struct
logger
*
log
)
{
struct
dump
*
d
=
log
->
dump
;
/* Write several copies of a part to the dump. */
struct
part
p
;
...
...
@@ -43,22 +44,20 @@ void test_log_parts(struct dump *d) {
size_t
offset
=
d
->
count
;
/* Write the full part. */
logger_log_part
(
&
p
,
logger_mask_x
|
logger_mask_v
|
logger_mask_a
|
logger_mask_u
|
logger_mask_h
|
logger_mask_rho
|
logger_mask_consts
,
&
offset
,
d
);
logger_log_part
(
log
,
&
p
,
logger_mask_x
|
logger_mask_v
|
logger_mask_a
|
logger_mask_u
|
logger_mask_h
|
logger_mask_rho
|
logger_mask_consts
,
&
offset
);
printf
(
"Wrote part at offset %#016zx.
\n
"
,
offset
);
/* Write only the position. */
p
.
x
[
0
]
=
2
.
0
;
logger_log_part
(
&
p
,
logger_mask_x
,
&
offset
,
d
);
logger_log_part
(
log
,
&
p
,
logger_mask_x
,
&
offset
);
printf
(
"Wrote part at offset %#016zx.
\n
"
,
offset
);
/* Write the position and velocity. */
p
.
x
[
0
]
=
3
.
0
;
p
.
v
[
0
]
=
0
.
3
;
logger_log_part
(
&
p
,
logger_mask_x
|
logger_mask_v
,
&
offset
,
d
);
logger_log_part
(
log
,
&
p
,
logger_mask_x
|
logger_mask_v
,
&
offset
);
printf
(
"Wrote part at offset %#016zx.
\n
"
,
offset
);
/* Recover the last part from the dump. */
...
...
@@ -101,7 +100,8 @@ void test_log_parts(struct dump *d) {
}
}
void
test_log_gparts
(
struct
dump
*
d
)
{
void
test_log_gparts
(
struct
logger
*
log
)
{
struct
dump
*
d
=
log
->
dump
;
/* Write several copies of a part to the dump. */
struct
gpart
p
;
...
...
@@ -113,21 +113,19 @@ void test_log_gparts(struct dump *d) {
size_t
offset
=
d
->
count
;
/* Write the full part. */
logger_log_gpart
(
&
p
,
logger_mask_x
|
logger_mask_v
|
logger_mask_a
|
logger_mask_h
|
logger_mask_consts
,
&
offset
,
d
);
logger_log_gpart
(
log
,
&
p
,
logger_mask_x
|
logger_mask_v
|
logger_mask_a
|
logger_mask_h
|
logger_mask_consts
,
&
offset
);
printf
(
"Wrote gpart at offset %#016zx.
\n
"
,
offset
);
/* Write only the position. */
p
.
x
[
0
]
=
2
.
0
;
logger_log_gpart
(
&
p
,
logger_mask_x
,
&
offset
,
d
);
logger_log_gpart
(
log
,
&
p
,
logger_mask_x
,
&
offset
);
printf
(
"Wrote gpart at offset %#016zx.
\n
"
,
offset
);
/* Write the position and velocity. */
p
.
x
[
0
]
=
3
.
0
;
p
.
v_full
[
0
]
=
0
.
3
;
logger_log_gpart
(
&
p
,
logger_mask_x
|
logger_mask_v
,
&
offset
,
d
);
logger_log_gpart
(
log
,
&
p
,
logger_mask_x
|
logger_mask_v
,
&
offset
);
printf
(
"Wrote gpart at offset %#016zx.
\n
"
,
offset
);
/* Recover the last part from the dump. */
...
...
@@ -170,7 +168,8 @@ void test_log_gparts(struct dump *d) {
}
}
void
test_log_timestamps
(
struct
dump
*
d
)
{
void
test_log_timestamps
(
struct
logger
*
log
)
{
struct
dump
*
d
=
log
->
dump
;
/* The timestamp to log. */
unsigned
long
long
int
t
=
10
;
...
...
@@ -179,13 +178,13 @@ void test_log_timestamps(struct dump *d) {
size_t
offset
=
d
->
count
;
/* Log three consecutive timestamps. */
logger_log_timestamp
(
t
,
&
offset
,
d
);
logger_log_timestamp
(
log
,
t
,
&
offset
);
printf
(
"Logged timestamp %020llu at offset %#016zx.
\n
"
,
t
,
offset
);
t
+=
10
;
logger_log_timestamp
(
t
,
&
offset
,
d
);
logger_log_timestamp
(
log
,
t
,
&
offset
);
printf
(
"Logged timestamp %020llu at offset %#016zx.
\n
"
,
t
,
offset
);
t
+=
10
;
logger_log_timestamp
(
t
,
&
offset
,
d
);
logger_log_timestamp
(
log
,
t
,
&
offset
);
printf
(
"Logged timestamp %020llu at offset %#016zx.
\n
"
,
t
,
offset
);
/* Recover the three timestamps. */
...
...
@@ -222,30 +221,29 @@ void test_log_timestamps(struct dump *d) {
int
main
(
int
argc
,
char
*
argv
[])
{
/* Some constants. */
char
filename
[
256
];
const
int
now
=
time
(
NULL
);
sprintf
(
filename
,
"/tmp/SWIFT_logger_test_%d.out"
,
now
);
/* Prepare a dump. */
struct
dump
d
;
dump_init
(
&
d
,
filename
,
1024
*
1024
);
/* Prepare a logger. */
struct
logger
log
;
struct
swift_params
params
;
parser_read_file
(
"logger.yml"
,
&
params
);
logger_init
(
&
log
,
&
params
);
/* Test writing/reading parts. */
test_log_parts
(
&
d
);
test_log_parts
(
&
log
);
/* Test writing/reading gparts. */
test_log_gparts
(
&
d
);
test_log_gparts
(
&
log
);
/* Test writing/reading timestamps. */
test_log_timestamps
(
&
d
);
/* Finalize the dump. */
dump_close
(
&
d
);
test_log_timestamps
(
&
log
);
/* Be clean */
char
filename
[
256
];
sprintf
(
filename
,
"%s.dump"
,
log
.
base_name
);
remove
(
filename
);
/* Clean the logger. */
logger_clean
(
&
log
);
/* Return a happy number. */
return
0
;
}
...
...
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