Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65529400
dls_core.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 4, 11:04
Size
7 KB
Mime Type
text/x-c
Expires
Thu, Jun 6, 11:04 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18087887
Attached To
R8042 Dynamic loop scheduling using MPI passive-target remote memory access
dls_core.c
View Options
/*********************************************************************************
* Copyright (c) 2018 *
* Ahmed Eleliemy <ahmed.eleliemy@unibas.ch> *
* University of Basel, Switzerland *
* All rights reserved. *
* This code is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the license (GNU LGPL) which comes with this package. *
*********************************************************************************/
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#include "dls_core.h"
#include <math.h>
void
calculate_next_chunk_stateless
(
struct
Scheduling_params
params
,
int
*
start
,
int
*
end
)
{
int
number_of_scheduled_tasks
=
params
.
scheduled_tasks
;
int
step
=
params
.
step
;
int
total_tasks
=
params
.
total_tasks
;
int
world_size
=
params
.
total_workers
;
int
method
=
params
.
method
;
int
c
=
params
.
constant
;
int
last_chunk
=
params
.
last_chunk
;
int
minimum_chunk
=
params
.
minimum_chunk
;
double
weight
=
params
.
my_weight
;
switch
(
method
)
{
case
0
:
STATIC_sl
(
number_of_scheduled_tasks
,
total_tasks
,
start
,
end
,
world_size
);
break
;
case
1
:
SS_sl
(
number_of_scheduled_tasks
,
total_tasks
,
start
,
end
,
world_size
);
break
;
case
2
:
FSC_sl
(
number_of_scheduled_tasks
,
total_tasks
,
start
,
end
,
world_size
,
c
);
break
;
case
3
:
GSS_sl
(
number_of_scheduled_tasks
,
total_tasks
,
start
,
end
,
world_size
);
break
;
case
4
:
FAC_sl
(
number_of_scheduled_tasks
,
total_tasks
,
step
,
start
,
end
,
world_size
,
last_chunk
);
break
;
case
5
:
TSS_sl
(
number_of_scheduled_tasks
,
total_tasks
,
start
,
end
,
world_size
,
c
,
last_chunk
,
minimum_chunk
);
break
;
case
6
:
WF_sl
(
number_of_scheduled_tasks
,
total_tasks
,
step
,
start
,
end
,
world_size
,
last_chunk
,
weight
);
break
;
}
}
void
STATIC_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
*
start
,
int
*
end
,
int
world_size
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
(
int
)
ceil
((
double
)
total_tasks
/
world_size
);
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
total_tasks
-
number_of_scheduled_tasks
);
}
void
SS_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
*
start
,
int
*
end
,
int
world_size
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
1
;
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
void
GSS_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
*
start
,
int
*
end
,
int
world_size
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
(
int
)
ceil
(
remaining_tasks
/
(
double
)
world_size
);
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
void
FAC_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
step
,
int
*
start
,
int
*
end
,
int
world_size
,
int
last_chunk
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
-
1
;
if
(
step
%
world_size
!=
0
)
{
chunk_size
=
last_chunk
;
}
else
{
chunk_size
=
(
int
)
ceil
(
remaining_tasks
/
(
world_size
*
2.0
));
}
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
void
FSC_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
*
start
,
int
*
end
,
int
world_size
,
int
fixed_chunk
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
fixed_chunk
;
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
void
TSS_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
*
start
,
int
*
end
,
int
world_size
,
int
fixed_decrement
,
int
last_chunk
,
int
minimum_chunk
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
last_chunk
-
fixed_decrement
;
chunk_size
=
max
(
chunk_size
,
minimum_chunk
);
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
void
WF_sl
(
int
number_of_scheduled_tasks
,
int
total_tasks
,
int
step
,
int
*
start
,
int
*
end
,
int
world_size
,
int
last_chunk
,
double
weight
)
{
int
remaining_tasks
=
total_tasks
-
number_of_scheduled_tasks
;
int
chunk_size
=
-
1
;
FAC_sf
(
total_tasks
,
step
,
&
chunk_size
,
world_size
);
if
(
chunk_size
>
1
)
{
chunk_size
=
ceil
(
chunk_size
*
weight
);
}
*
start
=
number_of_scheduled_tasks
;
*
end
=
number_of_scheduled_tasks
+
min
(
chunk_size
,
remaining_tasks
);
}
int
helper_FSC
(
int
number_of_workers
,
int
number_of_tasks
,
double
h
,
double
sigma
)
{
int
result
=
ceil
(
pow
((
double
)((
sqrt
(
2.0
)
*
(
double
)
number_of_tasks
*
h
)
/
(
sigma
*
(
double
)
number_of_workers
*
sqrt
(
log
((
double
)
number_of_workers
)))),
2.0
/
3.0
));
return
result
;
}
int
helper_TSS
(
int
number_of_workers
,
int
number_of_tasks
,
int
F
,
int
L
)
{
double
N
=
ceil
(
(
2.00
*
number_of_tasks
)
/
(
F
+
L
)
);
return
(
int
)
floor
((
F
-
L
)
/
(
N
-
1
));
}
void
calculate_next_chunk_stateful
(
struct
Scheduling_params
params
,
int
*
chunk_size
)
{
int
step
=
params
.
step
;
int
total_tasks
=
params
.
total_tasks
;
int
world_size
=
params
.
total_workers
;
int
method
=
params
.
method
;
int
c
=
params
.
constant
;
int
initial_chunk
=
params
.
last_chunk
;
int
minimum_chunk
=
params
.
minimum_chunk
;
double
my_weight
=
params
.
my_weight
;
switch
(
method
)
{
case
0
:
STATIC_sf
(
total_tasks
,
chunk_size
,
world_size
);
break
;
case
1
:
SS_sf
(
chunk_size
);
break
;
case
2
:
FSC_sf
(
chunk_size
,
c
);
break
;
case
3
:
GSS_sf
(
total_tasks
,
step
,
chunk_size
,
world_size
);
break
;
case
4
:
FAC_sf
(
total_tasks
,
step
,
chunk_size
,
world_size
);
break
;
case
5
:
TSS_sf
(
total_tasks
,
step
,
chunk_size
,
world_size
,
c
,
initial_chunk
);
break
;
case
6
:
WF_sf
(
total_tasks
,
step
,
chunk_size
,
world_size
,
my_weight
);
break
;
}
}
void
STATIC_sf
(
int
total_tasks
,
int
*
chunk_size
,
int
world_size
)
{
*
chunk_size
=
(
int
)
ceil
((
double
)
total_tasks
/
world_size
);
}
void
SS_sf
(
int
*
chunk_size
)
{
*
chunk_size
=
1
;
}
void
FSC_sf
(
int
*
chunk_size
,
int
fixed_chunk
)
{
*
chunk_size
=
fixed_chunk
;
}
void
GSS_sf
(
int
total_tasks
,
int
step
,
int
*
chunk_size
,
int
world_size
)
{
*
chunk_size
=
(
int
)
ceil
(
pow
((
1
-
(
1.0
/
(
double
)
world_size
)),
step
)
*
total_tasks
/
(
double
)
world_size
);
}
void
FAC_sf
(
int
total_tasks
,
int
step
,
int
*
chunk_size
,
int
world_size
)
{
int
actual_step
=
step
/
world_size
;
*
chunk_size
=
(
int
)
ceil
(
pow
(
0.5
,
actual_step
+
1
)
*
total_tasks
/
(
double
)
world_size
);
}
void
TSS_sf
(
int
total_tasks
,
int
step
,
int
*
chunk_size
,
int
world_size
,
int
c
,
int
initial_chunk
)
{
if
(
initial_chunk
-
(
step
*
c
)
>=
c
)
{
*
chunk_size
=
initial_chunk
-
(
step
*
c
);
}
else
{
*
chunk_size
=
initial_chunk
-
(
(
step
-
1
)
*
c
);
}
}
void
WF_sf
(
int
total_tasks
,
int
step
,
int
*
chunk_size
,
int
world_size
,
double
my_weight
)
{
FAC_sf
(
total_tasks
,
step
,
chunk_size
,
world_size
);
if
(
chunk_size
[
0
]
>
1
)
{
chunk_size
[
0
]
=
ceil
(
chunk_size
[
0
]
*
my_weight
);
}
}
double
WF_helper
(
int
knl_count
,
char
processor_name
[],
int
total_number_of_cores
)
{
double
weight
=
0
;
const
double
knl_speed
=
1
;
const
double
xeon_speed
=
2.5
;
const
double
total_speed
=
knl_count
*
knl_speed
+
(
total_number_of_cores
-
knl_count
)
*
xeon_speed
;
// knl_count
if
(
processor_name
[
12
]
==
'2'
&&
processor_name
[
13
]
>=
'3'
)
{
weight
=
total_number_of_cores
*
(
knl_speed
/
total_speed
);
}
else
{
weight
=
total_number_of_cores
*
(
xeon_speed
/
total_speed
);
}
return
weight
;
}
Event Timeline
Log In to Comment