Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iker Martín Álvarez
Proteo
Commits
3819a29c
Commit
3819a29c
authored
Jul 06, 2021
by
iker_martin
Browse files
Nueva version. Permite comunicacion uno a muchos en bucle de computo
parent
2663ec23
Changes
5
Hide whitespace changes
Inline
Side-by-side
Codes/IOcodes/read_ini.c
View file @
3819a29c
...
...
@@ -33,6 +33,8 @@ static int handler(void* user, const char* section, const char* name,
}
else
if
(
MATCH
(
"general"
,
"matrix_tam"
))
{
pconfig
->
matrix_tam
=
atoi
(
value
);
}
else
if
(
MATCH
(
"general"
,
"comm_tam"
))
{
pconfig
->
comm_tam
=
atoi
(
value
);
}
else
if
(
MATCH
(
"general"
,
"SDR"
))
{
pconfig
->
sdr
=
atoi
(
value
);
}
else
if
(
MATCH
(
"general"
,
"ADR"
))
{
...
...
@@ -127,7 +129,7 @@ void free_config(configuration *user_config) {
}
}
/*
/*
TODO Añadir COMMTAM
* Imprime por salida estandar toda la informacion que contiene
* la configuracion pasada como argumento
*/
...
...
@@ -245,15 +247,15 @@ configuration *recv_config_file(int root, MPI_Comm intercomm) {
* de la estructura de configuracion con una sola comunicacion.
*/
void
def_struct_config_file
(
configuration
*
config_file
,
MPI_Datatype
*
config_type
)
{
int
i
,
counts
=
8
;
int
blocklengths
[
8
]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
int
i
,
counts
=
9
;
int
blocklengths
[
9
]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
MPI_Aint
displs
[
counts
],
dir
;
MPI_Datatype
types
[
counts
];
// Rellenar vector types
types
[
0
]
=
types
[
1
]
=
types
[
2
]
=
types
[
3
]
=
types
[
4
]
=
types
[
5
]
=
MPI_INT
;
types
[
6
]
=
MPI_FLOAT
;
types
[
7
]
=
MPI_DOUBLE
;
types
[
0
]
=
types
[
1
]
=
types
[
2
]
=
types
[
3
]
=
types
[
4
]
=
types
[
5
]
=
types
[
6
]
=
MPI_INT
;
types
[
7
]
=
MPI_FLOAT
;
types
[
8
]
=
MPI_DOUBLE
;
// Rellenar vector displs
MPI_Get_address
(
config_file
,
&
dir
);
...
...
@@ -261,11 +263,12 @@ void def_struct_config_file(configuration *config_file, MPI_Datatype *config_typ
MPI_Get_address
(
&
(
config_file
->
resizes
),
&
displs
[
0
]);
MPI_Get_address
(
&
(
config_file
->
actual_resize
),
&
displs
[
1
]);
MPI_Get_address
(
&
(
config_file
->
matrix_tam
),
&
displs
[
2
]);
MPI_Get_address
(
&
(
config_file
->
sdr
),
&
displs
[
3
]);
MPI_Get_address
(
&
(
config_file
->
adr
),
&
displs
[
4
]);
MPI_Get_address
(
&
(
config_file
->
aib
),
&
displs
[
5
]);
MPI_Get_address
(
&
(
config_file
->
general_time
),
&
displs
[
6
]);
MPI_Get_address
(
&
(
config_file
->
Top
),
&
displs
[
7
]);
MPI_Get_address
(
&
(
config_file
->
comm_tam
),
&
displs
[
3
]);
MPI_Get_address
(
&
(
config_file
->
sdr
),
&
displs
[
4
]);
MPI_Get_address
(
&
(
config_file
->
adr
),
&
displs
[
5
]);
MPI_Get_address
(
&
(
config_file
->
aib
),
&
displs
[
6
]);
MPI_Get_address
(
&
(
config_file
->
general_time
),
&
displs
[
7
]);
MPI_Get_address
(
&
(
config_file
->
Top
),
&
displs
[
8
]);
for
(
i
=
0
;
i
<
counts
;
i
++
)
displs
[
i
]
-=
dir
;
...
...
Codes/IOcodes/read_ini.h
View file @
3819a29c
...
...
@@ -7,7 +7,7 @@ typedef struct
{
int
resizes
;
int
actual_resize
;
int
matrix_tam
,
sdr
,
adr
;
int
matrix_tam
,
comm_tam
,
sdr
,
adr
;
int
aib
;
float
general_time
;
double
Top
;
...
...
Codes/Main/Main.c
View file @
3819a29c
...
...
@@ -29,6 +29,7 @@ void iterate(double *matrix, int n, int async_comm);
void
init_group_struct
(
char
*
argv
[],
int
argc
,
int
myId
,
int
numP
);
void
init_application
();
void
obtain_op_times
();
void
free_application_data
();
void
print_general_info
(
int
myId
,
int
grp
,
int
numP
);
...
...
@@ -45,6 +46,8 @@ typedef struct {
int
numS
;
// Cantidad de procesos hijos
int
commAsync
;
MPI_Comm
children
,
parents
;
char
*
compute_comm_array
;
char
**
argv
;
char
*
sync_array
,
*
async_array
;
}
group_data
;
...
...
@@ -356,24 +359,27 @@ void Sons_init() {
int
numP_parents
=
config_file
->
procs
[
group
->
grp
-
1
];
init_results_data
(
&
results
,
config_file
->
resizes
-
1
,
config_file
->
iters
[
group
->
grp
]);
if
(
config_file
->
adr
>
0
)
{
// Recibir datos asincronos
if
(
config_file
->
comm_tam
)
{
group
->
compute_comm_array
=
malloc
(
config_file
->
comm_tam
*
sizeof
(
char
));
}
if
(
config_file
->
adr
)
{
// Recibir datos asincronos
recv_sync
(
&
(
group
->
async_array
),
config_file
->
adr
,
group
->
myId
,
group
->
numP
,
ROOT
,
group
->
parents
,
numP_parents
);
results
->
async_time
[
group
->
grp
]
=
MPI_Wtime
();
MPI_Bcast
(
&
(
group
->
iter_start
),
1
,
MPI_INT
,
ROOT
,
group
->
parents
);
}
if
(
config_file
->
sdr
>
0
)
{
// Recibir datos sincronos
if
(
config_file
->
sdr
)
{
// Recibir datos sincronos
recv_sync
(
&
(
group
->
sync_array
),
config_file
->
sdr
,
group
->
myId
,
group
->
numP
,
ROOT
,
group
->
parents
,
numP_parents
);
results
->
sync_time
[
group
->
grp
]
=
MPI_Wtime
();
}
// Guardar los resultados de esta transmision
recv_results
(
results
,
ROOT
,
config_file
->
resizes
,
group
->
parents
);
if
(
config_file
->
sdr
>
0
)
{
// Si no hay datos sincronos, el tiempo es 0
if
(
config_file
->
sdr
)
{
// Si no hay datos sincronos, el tiempo es 0
results
->
sync_time
[
group
->
grp
]
=
MPI_Wtime
()
-
results
->
sync_start
;
}
else
{
results
->
sync_time
[
group
->
grp
]
=
0
;
}
if
(
config_file
->
adr
>
0
)
{
// Si no hay datos asincronos, el tiempo es 0
if
(
config_file
->
adr
)
{
// Si no hay datos asincronos, el tiempo es 0
results
->
async_time
[
group
->
grp
]
=
MPI_Wtime
()
-
results
->
async_start
;
}
else
{
results
->
async_time
[
group
->
grp
]
=
0
;
...
...
@@ -408,6 +414,11 @@ void iterate(double *matrix, int n, int async_comm) {
for
(
i
=
0
;
i
<
operations
;
i
++
)
{
aux
+=
computePiSerial
(
n
);
}
if
(
config_file
->
comm_tam
)
{
MPI_Bcast
(
group
->
compute_comm_array
,
config_file
->
comm_tam
,
MPI_CHAR
,
ROOT
,
MPI_COMM_WORLD
);
}
actual_time
=
MPI_Wtime
();
// Guardar tiempos
if
(
async_comm
==
MAL_ASYNC_PENDING
)
{
// Se esta realizando una redistribucion de datos asincrona
operations
=
0
;
...
...
@@ -513,14 +524,23 @@ void init_application() {
config_file
=
read_ini_file
(
group
->
argv
[
1
]);
init_results_data
(
&
results
,
config_file
->
resizes
,
config_file
->
iters
[
group
->
grp
]);
if
(
config_file
->
sdr
>
0
)
{
if
(
config_file
->
comm_tam
)
{
group
->
compute_comm_array
=
malloc
(
config_file
->
comm_tam
*
sizeof
(
char
));
}
if
(
config_file
->
sdr
)
{
malloc_comm_array
(
&
(
group
->
sync_array
),
config_file
->
sdr
,
group
->
myId
,
group
->
numP
);
}
if
(
config_file
->
adr
>
0
)
{
if
(
config_file
->
adr
)
{
malloc_comm_array
(
&
(
group
->
async_array
),
config_file
->
adr
,
group
->
myId
,
group
->
numP
);
}
obtain_op_times
();
}
/*
* Obtiene cuanto tiempo es necesario para realizar una operacion de PI
*/
void
obtain_op_times
()
{
double
result
,
start_time
=
MPI_Wtime
();
int
i
;
result
=
0
;
...
...
@@ -530,20 +550,24 @@ void init_application() {
printf
(
"Creado Top con valor %lf
\n
"
,
result
);
fflush
(
stdout
);
config_file
->
Top
=
(
MPI_Wtime
()
-
start_time
)
/
20000
;
//Tiempo de una
iteracion en numero de it
eracion
es
MPI_Bcast
(
&
(
config_file
->
Top
),
1
,
MPI_DOUBLE
,
ROOT
,
MPI_COMM_WORLD
);
config_file
->
Top
=
(
MPI_Wtime
()
-
start_time
)
/
20000
;
//Tiempo de una
op
eracion
MPI_Bcast
(
&
(
config_file
->
Top
),
1
,
MPI_DOUBLE
,
ROOT
,
MPI_COMM_WORLD
);
}
/*
* Libera toda la memoria asociada con la aplicacion
*/
void
free_application_data
()
{
if
(
config_file
->
sdr
>
0
)
{
if
(
config_file
->
comm_tam
)
{
free
(
group
->
compute_comm_array
);
}
if
(
config_file
->
sdr
)
{
free
(
group
->
sync_array
);
}
if
(
config_file
->
adr
>
0
)
{
if
(
config_file
->
adr
)
{
free
(
group
->
async_array
);
}
free
(
group
);
free_config
(
config_file
);
free_results_data
(
&
results
);
...
...
Exec/create_ini.py
View file @
3819a29c
import
sys
import
glob
def
general
(
f
,
resizes
,
matrix_tam
,
sdr
,
adr
,
aib
,
time
):
def
general
(
f
,
resizes
,
matrix_tam
,
comm_tam
,
sdr
,
adr
,
aib
,
time
):
f
.
write
(
"[general]
\n
"
)
f
.
write
(
"resizes="
+
resizes
+
"
\n
"
)
f
.
write
(
"matrix_tam="
+
matrix_tam
+
"
\n
"
)
f
.
write
(
"comm_tam="
+
comm_tam
+
"
\n
"
)
f
.
write
(
"SDR="
+
sdr
+
"
\n
"
)
f
.
write
(
"ADR="
+
adr
+
"
\n
"
)
f
.
write
(
"AIB="
+
aib
+
"
\n
"
)
...
...
@@ -30,11 +31,12 @@ if len(sys.argv) < 12:
name
=
sys
.
argv
[
1
]
resizes
=
int
(
sys
.
argv
[
2
])
matrix_tam
=
sys
.
argv
[
3
]
sdr
=
int
(
sys
.
argv
[
4
])
adr_perc
=
float
(
sys
.
argv
[
5
])
aib
=
sys
.
argv
[
6
]
time
=
sys
.
argv
[
7
]
proc_time
=
float
(
sys
.
argv
[
8
])
# Usado para calcular el factor de cada proceso
comm_tam
=
sys
.
argv
[
4
]
sdr
=
int
(
sys
.
argv
[
5
])
adr_perc
=
float
(
sys
.
argv
[
6
])
aib
=
sys
.
argv
[
7
]
time
=
sys
.
argv
[
8
]
proc_time
=
float
(
sys
.
argv
[
9
])
# Usado para calcular el factor de cada proceso
adr
=
(
sdr
*
adr_perc
)
/
100
sdr
=
sdr
-
adr
...
...
@@ -44,13 +46,13 @@ sdr = str(sdr)
factor
=
0
f
=
open
(
name
,
"w"
)
general
(
f
,
str
(
resizes
),
matrix_tam
,
sdr
,
adr
,
aib
,
time
)
general
(
f
,
str
(
resizes
),
matrix_tam
,
comm_tam
,
sdr
,
adr
,
aib
,
time
)
resizes
=
resizes
+
1
# Internamente, los primeros procesos se muestran como un grupo
for
resize
in
range
(
resizes
):
iters
=
sys
.
argv
[
9
+
3
*
resize
]
procs
=
sys
.
argv
[
9
+
3
*
resize
+
1
]
physical_dist
=
sys
.
argv
[
9
+
3
*
resize
+
2
]
iters
=
sys
.
argv
[
10
+
3
*
resize
]
procs
=
sys
.
argv
[
10
+
3
*
resize
+
1
]
physical_dist
=
sys
.
argv
[
10
+
3
*
resize
+
2
]
if
proc_time
!=
0
:
# Si el argumento proc_time es 0, todos los grupos tienen un factor de 1
factor
=
proc_time
/
float
(
procs
)
...
...
Exec/run.sh
View file @
3819a29c
...
...
@@ -10,11 +10,12 @@ echo "START TEST"
groups
=
$1
#TODO Modificar para que admita más de dos grupos de procesos
matrix_tam
=
$2
N_qty
=
$3
# Datos a redistribuir
time
=
$4
proc_init
=
$5
#El tiempo por iteracion es para esta cantidad de procesos
iters
=
$6
node_qty
=
$7
comm_tam
=
$3
N_qty
=
$4
# Datos a redistribuir
time
=
$5
proc_init
=
$6
#El tiempo por iteracion es para esta cantidad de procesos
iters
=
$7
node_qty
=
$8
max_procs
=
$((
$node_qty
*
20
))
procs_array
=()
...
...
@@ -69,7 +70,7 @@ do
array
=(
"
${
array0
[@]
}
"
)
array0
=(
$iters
$procs_sons
$phy_dist
)
array+
=(
"
${
array0
[@]
}
"
)
python3
$dir$execDir
/./create_ini.py config
$i
.ini 1
$matrix_tam
$N_qty
$adr_perc
$ibarrier_use
$time
$proc_init
"
${
array
[@]
}
"
python3
$dir$execDir
/./create_ini.py config
$i
.ini 1
$matrix_tam
$comm_tam
$N_qty
$adr_perc
$ibarrier_use
$time
$proc_init
"
${
array
[@]
}
"
done
done
...
...
Write
Preview
Supports
Markdown
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