Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batsched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
poquet
millian
batsched
Commits
63d459f7
Commit
63d459f7
authored
5 years ago
by
Millian Poquet
Browse files
Options
Downloads
Patches
Plain Diff
[code] dump schedule as batsim jobs output format
https://batsim.readthedocs.io/en/latest/output-jobs.html
parent
112c6758
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/algo/conservative_bf.cpp
+22
-0
22 additions, 0 deletions
src/algo/conservative_bf.cpp
src/algo/conservative_bf.hpp
+2
-0
2 additions, 0 deletions
src/algo/conservative_bf.hpp
src/schedule.cpp
+91
-1
91 additions, 1 deletion
src/schedule.cpp
src/schedule.hpp
+3
-0
3 additions, 0 deletions
src/schedule.hpp
with
118 additions
and
1 deletion
src/algo/conservative_bf.cpp
+
22
−
0
View file @
63d459f7
...
@@ -2,12 +2,27 @@
...
@@ -2,12 +2,27 @@
#include
<loguru.hpp>
#include
<loguru.hpp>
#include
"../pempek_assert.hpp"
using
namespace
std
;
using
namespace
std
;
ConservativeBackfilling
::
ConservativeBackfilling
(
Workload
*
workload
,
SchedulingDecision
*
decision
,
ConservativeBackfilling
::
ConservativeBackfilling
(
Workload
*
workload
,
SchedulingDecision
*
decision
,
Queue
*
queue
,
ResourceSelector
*
selector
,
double
rjms_delay
,
rapidjson
::
Document
*
variant_options
)
:
Queue
*
queue
,
ResourceSelector
*
selector
,
double
rjms_delay
,
rapidjson
::
Document
*
variant_options
)
:
ISchedulingAlgorithm
(
workload
,
decision
,
queue
,
selector
,
rjms_delay
,
variant_options
)
ISchedulingAlgorithm
(
workload
,
decision
,
queue
,
selector
,
rjms_delay
,
variant_options
)
{
{
if
(
variant_options
->
HasMember
(
"dump_previsional_schedules"
))
{
PPK_ASSERT_ERROR
((
*
variant_options
)[
"dump_previsional_schedules"
].
IsBool
(),
"Invalid options: 'dump_previsional_schedules' should be a boolean"
);
_dump_provisional_schedules
=
(
*
variant_options
)[
"dump_previsional_schedules"
].
GetBool
();
}
if
(
variant_options
->
HasMember
(
"dump_prefix"
))
{
PPK_ASSERT_ERROR
((
*
variant_options
)[
"dump_prefix"
].
IsString
(),
"Invalid options: 'dump_prefix' should be a string"
);
_dump_prefix
=
(
*
variant_options
)[
"dump_prefix"
].
GetString
();
}
}
}
ConservativeBackfilling
::~
ConservativeBackfilling
()
ConservativeBackfilling
::~
ConservativeBackfilling
()
...
@@ -92,7 +107,11 @@ void ConservativeBackfilling::make_decisions(double date,
...
@@ -92,7 +107,11 @@ void ConservativeBackfilling::make_decisions(double date,
const
Job
*
job
=
(
*
job_it
)
->
job
;
const
Job
*
job
=
(
*
job_it
)
->
job
;
_schedule
.
remove_job_if_exists
(
job
);
_schedule
.
remove_job_if_exists
(
job
);
// if (_dump_provisional_schedules)
// _schedule.incremental_dump_as_batsim_jobs_file(_dump_prefix);
Schedule
::
JobAlloc
alloc
=
_schedule
.
add_job_first_fit
(
job
,
_selector
);
Schedule
::
JobAlloc
alloc
=
_schedule
.
add_job_first_fit
(
job
,
_selector
);
// if (_dump_provisional_schedules)
// _schedule.incremental_dump_as_batsim_jobs_file(_dump_prefix);
if
(
alloc
.
started_in_first_slice
)
if
(
alloc
.
started_in_first_slice
)
{
{
...
@@ -112,4 +131,7 @@ void ConservativeBackfilling::make_decisions(double date,
...
@@ -112,4 +131,7 @@ void ConservativeBackfilling::make_decisions(double date,
double
answer
=
_schedule
.
query_wait
(
new_job
->
nb_requested_resources
,
new_job
->
walltime
,
_selector
);
double
answer
=
_schedule
.
query_wait
(
new_job
->
nb_requested_resources
,
new_job
->
walltime
,
_selector
);
_decision
->
add_answer_estimate_waiting_time
(
job_id
,
answer
,
date
);
_decision
->
add_answer_estimate_waiting_time
(
job_id
,
answer
,
date
);
}
}
if
(
_dump_provisional_schedules
)
_schedule
.
incremental_dump_as_batsim_jobs_file
(
_dump_prefix
);
}
}
This diff is collapsed.
Click to expand it.
src/algo/conservative_bf.hpp
+
2
−
0
View file @
63d459f7
...
@@ -24,4 +24,6 @@ public:
...
@@ -24,4 +24,6 @@ public:
private:
private:
Schedule
_schedule
;
Schedule
_schedule
;
bool
_dump_provisional_schedules
=
false
;
std
::
string
_dump_prefix
=
"/tmp/dump"
;
};
};
This diff is collapsed.
Click to expand it.
src/schedule.cpp
+
91
−
1
View file @
63d459f7
...
@@ -896,7 +896,7 @@ void Schedule::write_svg_to_file(const string &filename) const
...
@@ -896,7 +896,7 @@ void Schedule::write_svg_to_file(const string &filename) const
void
Schedule
::
output_to_svg
(
const
string
&
filename_prefix
)
void
Schedule
::
output_to_svg
(
const
string
&
filename_prefix
)
{
{
const
int
bufsize
=
128
;
const
int
bufsize
=
4096
;
char
*
buf
=
new
char
[
bufsize
];
char
*
buf
=
new
char
[
bufsize
];
snprintf
(
buf
,
bufsize
,
"%s%06d.svg"
,
filename_prefix
.
c_str
(),
_output_number
);
snprintf
(
buf
,
bufsize
,
"%s%06d.svg"
,
filename_prefix
.
c_str
(),
_output_number
);
...
@@ -907,6 +907,96 @@ void Schedule::output_to_svg(const string &filename_prefix)
...
@@ -907,6 +907,96 @@ void Schedule::output_to_svg(const string &filename_prefix)
delete
[]
buf
;
delete
[]
buf
;
}
}
void
Schedule
::
dump_to_batsim_jobs_file
(
const
string
&
filename
)
const
{
ofstream
f
(
filename
);
if
(
f
.
is_open
())
{
f
<<
"job_id,submission_time,requested_number_of_resources,requested_time,starting_time,finish_time,allocated_resources
\n
"
;
PPK_ASSERT_ERROR
(
_profile
.
size
()
>
0
);
const
int
buf_size
=
4096
;
char
*
buf
=
new
char
[
buf_size
];
map
<
const
Job
*
,
Rational
>
jobs_starting_times
;
set
<
const
Job
*>
current_jobs
;
for
(
auto
mit
:
_profile
.
begin
()
->
allocated_jobs
)
{
const
Job
*
allocated_job
=
mit
.
first
;
current_jobs
.
insert
(
allocated_job
);
jobs_starting_times
[
allocated_job
]
=
_profile
.
begin
()
->
begin
;
}
// Let's traverse the profile to find the beginning of each job
for
(
auto
slice_it
=
_profile
.
begin
();
slice_it
!=
_profile
.
end
();
++
slice_it
)
{
const
TimeSlice
&
slice
=
*
slice_it
;
set
<
const
Job
*>
allocated_jobs
;
for
(
auto
mit
:
slice
.
allocated_jobs
)
{
const
Job
*
job
=
mit
.
first
;
allocated_jobs
.
insert
(
job
);
}
set
<
const
Job
*>
finished_jobs
;
set_difference
(
current_jobs
.
begin
(),
current_jobs
.
end
(),
allocated_jobs
.
begin
(),
allocated_jobs
.
end
(),
std
::
inserter
(
finished_jobs
,
finished_jobs
.
end
()));
for
(
const
Job
*
job
:
finished_jobs
)
{
// Find where the job has been allocated
PPK_ASSERT_ERROR
(
slice_it
!=
_profile
.
begin
());
auto
previous_slice_it
=
slice_it
;
--
previous_slice_it
;
IntervalSet
job_machines
=
previous_slice_it
->
allocated_jobs
.
at
(
job
);
snprintf
(
buf
,
buf_size
,
"%s,%g,%d,%g,%g,%g,%s
\n
"
,
job
->
id
.
c_str
(),
job
->
submission_time
,
job
->
nb_requested_resources
,
(
double
)
job
->
walltime
,
(
double
)
jobs_starting_times
[
job
],
(
double
)
slice_it
->
begin
,
job_machines
.
to_string_hyphen
(
" "
,
"-"
).
c_str
());
f
<<
buf
;
}
set
<
const
Job
*>
new_jobs
;
set_difference
(
allocated_jobs
.
begin
(),
allocated_jobs
.
end
(),
current_jobs
.
begin
(),
current_jobs
.
end
(),
std
::
inserter
(
new_jobs
,
new_jobs
.
end
()));
for
(
const
Job
*
job
:
new_jobs
)
{
jobs_starting_times
[
job
]
=
slice
.
begin
;
}
// Update current_jobs
for
(
const
Job
*
job
:
finished_jobs
)
current_jobs
.
erase
(
job
);
for
(
const
Job
*
job
:
new_jobs
)
current_jobs
.
insert
(
job
);
}
delete
[]
buf
;
}
f
.
close
();
}
void
Schedule
::
incremental_dump_as_batsim_jobs_file
(
const
string
&
filename_prefix
)
{
const
int
bufsize
=
4096
;
char
*
buf
=
new
char
[
bufsize
];
snprintf
(
buf
,
bufsize
,
"%s%06d.csv"
,
filename_prefix
.
c_str
(),
_output_number
);
_output_number
=
(
_output_number
+
1
)
%
10000000
;
dump_to_batsim_jobs_file
(
buf
);
delete
[]
buf
;
}
int
Schedule
::
nb_machines
()
const
int
Schedule
::
nb_machines
()
const
{
{
return
_nb_machines
;
return
_nb_machines
;
...
...
This diff is collapsed.
Click to expand it.
src/schedule.hpp
+
3
−
0
View file @
63d459f7
...
@@ -101,6 +101,9 @@ public:
...
@@ -101,6 +101,9 @@ public:
void
write_svg_to_file
(
const
std
::
string
&
filename
)
const
;
void
write_svg_to_file
(
const
std
::
string
&
filename
)
const
;
void
output_to_svg
(
const
std
::
string
&
filename_prefix
=
"/tmp/schedule"
);
void
output_to_svg
(
const
std
::
string
&
filename_prefix
=
"/tmp/schedule"
);
void
dump_to_batsim_jobs_file
(
const
std
::
string
&
filename
)
const
;
void
incremental_dump_as_batsim_jobs_file
(
const
std
::
string
&
filename_prefix
=
"/tmp/schedule"
);
int
nb_machines
()
const
;
int
nb_machines
()
const
;
private
:
private
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment