Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
L
load_leveller
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Weber
load_leveller
Commits
0bd961b6
Commit
0bd961b6
authored
Jun 16, 2020
by
Lukas Weber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting
parent
5651eb93
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
49 additions
and
45 deletions
+49
-45
src/iodump.cpp
src/iodump.cpp
+1
-1
src/iodump.h
src/iodump.h
+1
-1
src/jobinfo.cpp
src/jobinfo.cpp
+5
-5
src/jobinfo.h
src/jobinfo.h
+4
-3
src/loadleveller.h
src/loadleveller.h
+8
-7
src/mc.cpp
src/mc.cpp
+2
-1
src/mc.h
src/mc.h
+1
-1
src/random.h
src/random.h
+1
-5
src/random/intel_mkl.h
src/random/intel_mkl.h
+13
-8
src/random/internal_mt.h
src/random/internal_mt.h
+2
-4
src/random/stl_random.h
src/random/stl_random.h
+2
-2
src/runner.cpp
src/runner.cpp
+2
-1
src/runner_pt.cpp
src/runner_pt.cpp
+3
-2
test/bench_rng.cpp
test/bench_rng.cpp
+3
-3
test/catch.hpp
test/catch.hpp
+1
-1
No files found.
src/iodump.cpp
View file @
0bd961b6
#include "iodump.h"
#include <filesystem>
#include <iostream>
#include <sstream>
#include <typeinfo>
#include <filesystem>
namespace
loadl
{
...
...
src/iodump.h
View file @
0bd961b6
#pragma once
#include <cassert>
#include <fmt/format.h>
#include <hdf5.h>
#include <string>
#include <cassert>
#include <vector>
namespace
loadl
{
...
...
src/jobinfo.cpp
View file @
0bd961b6
...
...
@@ -2,11 +2,11 @@
#include "mc.h"
#include "merger.h"
#include <ctime>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <regex>
#include <filesystem>
namespace
loadl
{
...
...
@@ -50,11 +50,11 @@ std::filesystem::path jobinfo::taskdir(int task_id) const {
}
std
::
filesystem
::
path
jobinfo
::
rundir
(
int
task_id
,
int
run_id
)
const
{
return
taskdir
(
task_id
)
/
fmt
::
format
(
"run{:04d}"
,
run_id
);
return
taskdir
(
task_id
)
/
fmt
::
format
(
"run{:04d}"
,
run_id
);
}
jobinfo
::
jobinfo
(
const
std
::
filesystem
::
path
&
jobfile_name
,
register_evalables_func
evalable_func
)
:
evalable_func_
{
evalable_func
},
jobfile
{
jobfile_name
},
jobdir
{
jobfile_name
.
parent_path
()}
{
:
evalable_func_
{
evalable_func
},
jobfile
{
jobfile_name
},
jobdir
{
jobfile_name
.
parent_path
()}
{
for
(
auto
node
:
jobfile
[
"tasks"
])
{
std
::
string
task_name
=
node
.
first
;
task_names
.
push_back
(
task_name
);
...
...
@@ -82,7 +82,7 @@ jobinfo::jobinfo(const std::filesystem::path &jobfile_name, register_evalables_f
// and having the right file_ending.
// The regex has to be matched with the output of the rundir function.
std
::
vector
<
std
::
filesystem
::
path
>
jobinfo
::
list_run_files
(
const
std
::
string
&
taskdir
,
const
std
::
string
&
file_ending
)
{
const
std
::
string
&
file_ending
)
{
std
::
regex
run_filename
{
"^run
\\
d{4,}
\\
."
+
file_ending
+
"$"
};
std
::
vector
<
std
::
filesystem
::
path
>
results
;
...
...
@@ -112,7 +112,7 @@ int jobinfo::read_dump_progress(int task_id) const {
}
void
jobinfo
::
concatenate_results
()
{
std
::
ofstream
cat_results
{
jobdir
.
parent_path
()
/
fmt
::
format
(
"{}.results.json"
,
jobname
)};
std
::
ofstream
cat_results
{
jobdir
.
parent_path
()
/
fmt
::
format
(
"{}.results.json"
,
jobname
)};
cat_results
<<
"["
;
for
(
size_t
i
=
0
;
i
<
task_names
.
size
();
i
++
)
{
std
::
ifstream
res_file
{
taskdir
(
i
)
/
"results.json"
};
...
...
src/jobinfo.h
View file @
0bd961b6
...
...
@@ -3,17 +3,18 @@
#include "evalable.h"
#include "iodump.h"
#include "parser.h"
#include <filesystem>
#include <string>
#include <vector>
#include <filesystem>
namespace
loadl
{
using
register_evalables_func
=
std
::
function
<
void
(
evaluator
&
,
const
parser
&
)
>
;
using
register_evalables_func
=
std
::
function
<
void
(
evaluator
&
,
const
parser
&
)
>
;
class
jobinfo
{
private:
register_evalables_func
evalable_func_
;
public:
parser
jobfile
;
const
std
::
filesystem
::
path
jobdir
;
...
...
@@ -30,7 +31,7 @@ public:
std
::
filesystem
::
path
taskdir
(
int
task_id
)
const
;
static
std
::
vector
<
std
::
filesystem
::
path
>
list_run_files
(
const
std
::
string
&
taskdir
,
const
std
::
string
&
file_ending
);
const
std
::
string
&
file_ending
);
int
read_dump_progress
(
int
task_id
)
const
;
void
merge_task
(
int
task_id
);
void
concatenate_results
();
...
...
src/loadleveller.h
View file @
0bd961b6
...
...
@@ -8,26 +8,28 @@ namespace loadl {
inline
int
merge_only
(
jobinfo
job
,
const
mc_factory
&
,
int
,
char
**
)
{
int
ntasks
=
job
.
task_names
.
size
();
int
len
=
log
(
ntasks
)
/
log
(
10
)
+
1
;
int
len
=
log
(
ntasks
)
/
log
(
10
)
+
1
;
size_t
max_tasklen
=
0
;
for
(
size_t
task_id
=
0
;
task_id
<
job
.
task_names
.
size
();
task_id
++
)
{
std
::
string
taskdir
=
job
.
taskdir
(
task_id
);
max_tasklen
=
std
::
max
(
max_tasklen
,
taskdir
.
size
());
std
::
cout
<<
fmt
::
format
(
"
\r
Merging task {0: >{3}}/{1: >{3}}... {2: <{4}}"
,
task_id
+
1
,
job
.
task_names
.
size
(),
taskdir
,
len
,
max_tasklen
);
std
::
cout
<<
fmt
::
format
(
"
\r
Merging task {0: >{3}}/{1: >{3}}... {2: <{4}}"
,
task_id
+
1
,
job
.
task_names
.
size
(),
taskdir
,
len
,
max_tasklen
);
std
::
cout
.
flush
();
job
.
merge_task
(
task_id
);
}
std
::
cout
<<
fmt
::
format
(
"
\r
Merged {0} tasks.{1: >{2}}
\n
"
,
job
.
task_names
.
size
(),
""
,
2
*
len
+
5
+
max_tasklen
);
std
::
cout
<<
fmt
::
format
(
"
\r
Merged {0} tasks.{1: >{2}}
\n
"
,
job
.
task_names
.
size
(),
""
,
2
*
len
+
5
+
max_tasklen
);
return
0
;
}
template
<
typename
mc_implementation
>
int
run_mc
(
int
(
*
starter
)(
jobinfo
job
,
const
mc_factory
&
,
int
argc
,
char
**
argv
),
int
argc
,
char
**
argv
)
{
template
<
typename
mc_implementation
>
int
run_mc
(
int
(
*
starter
)(
jobinfo
job
,
const
mc_factory
&
,
int
argc
,
char
**
argv
),
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
)
{
std
::
cerr
<<
fmt
::
format
(
"{0} JOBFILE
\n
{0} single JOBFILE
\n
{0} merge JOBFILE
\n\n
Without further flags, the MPI "
...
...
@@ -56,7 +58,6 @@ int run_mc(int (*starter)(jobinfo job, const mc_factory &, int argc, char **argv
// run this function from main() in your code.
template
<
class
mc_implementation
>
int
run
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
&&
std
::
string
(
argv
[
1
])
==
"merge"
)
{
return
run_mc
<
mc_implementation
>
(
merge_only
,
argc
-
1
,
argv
+
1
);
}
else
if
(
argc
>
1
&&
std
::
string
(
argv
[
1
])
==
"single"
)
{
...
...
src/mc.cpp
View file @
0bd961b6
...
...
@@ -72,7 +72,8 @@ void mc::_write(const std::string &dir) {
// blocks limit scopes of the dump file handles to ensure they are closed at the right time.
{
std
::
error_code
ec
;
std
::
filesystem
::
copy_file
(
dir
+
".meas.h5"
,
dir
+
".meas.h5.tmp"
,
std
::
filesystem
::
copy_options
::
overwrite_existing
,
ec
);
std
::
filesystem
::
copy_file
(
dir
+
".meas.h5"
,
dir
+
".meas.h5.tmp"
,
std
::
filesystem
::
copy_options
::
overwrite_existing
,
ec
);
if
(
ec
&&
ec
!=
std
::
errc
::
no_such_file_or_directory
)
{
throw
std
::
system_error
(
ec
);
}
...
...
src/mc.h
View file @
0bd961b6
...
...
@@ -43,7 +43,7 @@ public:
size_t
sweep
()
const
;
// implement this static function in your class!
//static void register_evalables(evaluator &evalables);
//
static void register_evalables(evaluator &evalables);
virtual
void
write_output
(
const
std
::
string
&
filename
);
...
...
src/random.h
View file @
0bd961b6
#pragma once
#include "config.h"
#include "iodump.h"
#include <mpi.h>
#include <random>
#include "iodump.h"
#include <typeinfo>
// A whole bunch of template magic to make the random backend modular.
// We don’t want a vtable on such a performance critical object, otherwise I
// would make it settable at runtime.
#include "random/stl_random.h"
#include "random/internal_mt.h"
...
...
@@ -19,7 +18,6 @@
#include "random/intel_mkl.h"
#endif
namespace
loadl
{
template
<
class
base
>
...
...
@@ -39,7 +37,6 @@ private:
void
set_seed
(
uint64_t
seed
)
{
seed_
=
seed
;
static_cast
<
base
*>
(
this
)
->
set_seed
(
seed
);
}
uint64_t
seed_
{};
...
...
@@ -86,7 +83,6 @@ public:
double
rand_double
();
// in [0,1]
};
// RNG_BACKEND is a macro set by the build system. If you add backends and you can help it,
// avoid using huge blocks of #ifdefs as it will lead to dead code nobody uses for 10 years.
// using random_number_generator = rng_base<RNG_BACKEND, #RNG_BACKEND>;
...
...
src/random/intel_mkl.h
View file @
0bd961b6
#pragma once
#include "iodump.h"
#include <mkl_vsl.h>
#include <vector>
#include "iodump.h"
namespace
loadl
{
...
...
@@ -16,20 +16,23 @@ private:
VSLStreamStatePtr
random_stream_
{};
void
refill_buffer
()
{
vdRngUniform
(
VSL_RNG_METHOD_UNIFORM_STD
,
random_stream_
,
buffer_size_
,
buffer_
.
data
(),
0
,
1
);
vdRngUniform
(
VSL_RNG_METHOD_UNIFORM_STD
,
random_stream_
,
buffer_size_
,
buffer_
.
data
(),
0
,
1
);
}
public:
void
backend_checkpoint_write
(
const
iodump
::
group
&
dump_file
)
{
std
::
vector
<
char
>
save_buf
(
vslGetStreamSize
(
random_stream_
));
int
rc
=
vslSaveStreamM
(
random_stream_
,
save_buf
.
data
());
if
(
rc
!=
VSL_ERROR_OK
)
{
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not write Intel MKL RNG: error code {}"
,
rc
)};
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not write Intel MKL RNG: error code {}"
,
rc
)};
}
dump_file
.
write
(
"state"
,
save_buf
);
dump_file
.
write
(
"buffer"
,
std
::
vector
<
double
>
(
buffer_
.
begin
(),
buffer_
.
end
()));
dump_file
.
write
(
"buffer_idx"
,
buffer_idx_
);
}
void
backend_checkpoint_read
(
const
iodump
::
group
&
dump_file
)
{
if
(
random_stream_
!=
nullptr
)
{
vslDeleteStream
(
&
random_stream_
);
...
...
@@ -38,7 +41,8 @@ public:
dump_file
.
read
(
"state"
,
load_buf
);
int
rc
=
vslLoadStreamM
(
&
random_stream_
,
load_buf
.
data
());
if
(
rc
!=
VSL_ERROR_OK
)
{
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not load Intel MKL RNG: error code {}"
,
rc
)};
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not load Intel MKL RNG: error code {}"
,
rc
)};
}
std
::
vector
<
double
>
tmpbuffer
;
...
...
@@ -54,7 +58,8 @@ public:
}
int
rc
=
vslNewStream
(
&
random_stream_
,
VSL_BRNG_SFMT19937
,
seed
);
if
(
rc
!=
VSL_ERROR_OK
)
{
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not initialize Intel MKL RNG: error code {}"
,
rc
)};
throw
std
::
runtime_error
{
fmt
::
format
(
"Could not initialize Intel MKL RNG: error code {}"
,
rc
)};
}
}
...
...
@@ -65,10 +70,10 @@ public:
}
return
buffer_
[
buffer_idx_
++
];
}
uint32_t
random_integer
(
uint32_t
bound
)
{
return
bound
*
random_double
();
// TODO: use the optimized integer distribution at the cost of a second buffer?
return
bound
*
random_double
();
// TODO: use the optimized integer distribution at the cost
// of a second buffer?
}
~
rng_intel_mkl
()
{
...
...
src/random/internal_mt.h
View file @
0bd961b6
#pragma once
#include "iodump.h"
#include "MersenneTwister.h"
#include "iodump.h"
namespace
loadl
{
...
...
@@ -17,7 +16,7 @@ public:
mtrand_
.
save
(
rand_state
);
dump_file
.
write
(
"state"
,
rand_state
);
}
void
backend_checkpoint_read
(
const
iodump
::
group
&
dump_file
)
{
std
::
vector
<
uint64_t
>
rand_state
;
dump_file
.
read
(
"state"
,
rand_state
);
...
...
@@ -27,7 +26,6 @@ public:
mtrand_
.
seed
(
seed
);
}
double
random_double
()
{
return
mtrand_
.
randDblExc
(
1
);
}
...
...
src/random/stl_random.h
View file @
0bd961b6
#pragma once
#include <sstream>
#include <random>
#include "iodump.h"
#include <random>
#include <sstream>
namespace
loadl
{
...
...
src/runner.cpp
View file @
0bd961b6
...
...
@@ -255,7 +255,8 @@ void runner_slave::checkpoint_write() {
time_last_checkpoint_
=
MPI_Wtime
();
sys_
->
_write
(
job_
.
rundir
(
task_id_
,
run_id_
));
sys_
->
_write_finalize
(
job_
.
rundir
(
task_id_
,
run_id_
));
job_
.
log
(
fmt
::
format
(
"* rank {}: checkpoint {}"
,
rank_
,
job_
.
rundir
(
task_id_
,
run_id_
).
string
()));
job_
.
log
(
fmt
::
format
(
"* rank {}: checkpoint {}"
,
rank_
,
job_
.
rundir
(
task_id_
,
run_id_
).
string
()));
}
void
runner_slave
::
merge_measurements
()
{
...
...
src/runner_pt.cpp
View file @
0bd961b6
#include "runner_pt.h"
#include "util.h"
#include <fstream>
#include <filesystem>
#include <fstream>
namespace
loadl
{
...
...
@@ -769,7 +769,8 @@ void runner_pt_slave::checkpoint_write() {
sys_
->
_write
(
job_
.
rundir
(
task_id_
,
run_id_
));
MPI_Barrier
(
chain_comm_
);
sys_
->
_write_finalize
(
job_
.
rundir
(
task_id_
,
run_id_
));
job_
.
log
(
fmt
::
format
(
"* rank {}: checkpoint {}"
,
rank_
,
job_
.
rundir
(
task_id_
,
run_id_
).
string
()));
job_
.
log
(
fmt
::
format
(
"* rank {}: checkpoint {}"
,
rank_
,
job_
.
rundir
(
task_id_
,
run_id_
).
string
()));
}
void
runner_pt_master
::
send_action
(
int
action
,
int
destination
)
{
...
...
test/bench_rng.cpp
View file @
0bd961b6
#include <loadleveller/random.h>
#include <iostream>
#include <loadleveller/random.h>
int
main
(
int
,
char
**
)
{
const
uint64_t
nsamples
=
200000000
;
...
...
@@ -25,6 +25,6 @@ int main(int, char **) {
sum
+=
rng
.
random_double
();
sum
+=
rng
.
random_double
();
}
std
::
cout
<<
sum
/
(
16
*
nsamples
);
std
::
cout
<<
sum
/
(
16
*
nsamples
);
}
test/catch.hpp
View file @
0bd961b6
...
...
@@ -8921,7 +8921,7 @@ public:
return m_tokenBuffer.front();
}
auto operator->
() const -> Token const * {
auto operator->() const -> Token const * {
assert(!m_tokenBuffer.empty());
return &m_tokenBuffer.front();
}
...
...
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