Commit f453a143 authored by iker_martin's avatar iker_martin
Browse files

Anyadido uso de Makefile para compilar, aun tiene que ser mejorado

parent 4b37d0dd
objects1 := ini
objects2 := results read_ini
CC := gcc
MCC := mpicc
CFLAGS := -Wall
all: $(objects1) $(objects2)
$(objects1): %: %.c %.h
$(CC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
$(objects2): %: %.c %.h $(objects1).h $(TOP)/malleability/distribution_methods/block_distribution.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
......@@ -6,6 +6,8 @@
#include <sys/stat.h>
#include "process_stage.h"
#include "Main_datatypes.h"
#include "../IOcodes/read_ini.h"
#include "../IOcodes/results.h"
#include "../malleability/CommDist.h"
#include "../malleability/malleabilityManager.h"
#include "../malleability/malleabilityStates.h"
......@@ -374,8 +376,11 @@ void init_application() {
int message_tam = 100000000;
message_tam = 10240000;
//for(int i=0; i<10; i++) {
config_file->latency_m = latency(group->myId, group->numP, comm);
config_file->bw_m = bandwidth(group->myId, group->numP, comm, config_file->latency_m, message_tam);
//if(group->myId == ROOT) printf("numP=%d Lat=%lf Bw=%lf\n", group->numP, config_file->latency_m, config_file->bw_m);
//}
obtain_op_times(1);
}
......
objects1 := computing_func comunication_func linear_reg
objects2 := process_stage
objects3 := Main
depends := Main_datatypes
CC := gcc
MCC := mpicc
CFLAGS := -Wall
all: $(objects1) $(objects2) $(objects3)
$(objects1): %: %.c %.h $(depends).h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
$(objects2): %: %.c %.h $(objects1).h $(depends).h $(TOP)/IOcodes/read_ini.h \
$(TOP)/malleability/distribution_methods/block_distribution.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
$(objects3): %: %.c $(objects2).h $(depends).h $(TOP)/IOcodes/read_ini.h $(TOP)/IOcodes/results.h \
$(TOP)/malleability/CommDist.h $(TOP)/malleability/malleabilityStates.h \
$(TOP)/malleability/malleabilityManager.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
......@@ -122,36 +122,30 @@ double process_stage(configuration config_file, iter_stage_t stage, group_data g
// Devuelve la latencia del sistema.
double latency(int myId, int numP, MPI_Comm comm) {
int i, loop_count = 100;
double start_time, stop_time, elapsed_time, max_time;
double start_time, stop_time, time;
char aux;
aux = '0';
elapsed_time = 0;
//if(myId+1 != numP || (myId+1 == numP && numP % 2 == 0)) {
MPI_Barrier(comm);
start_time = MPI_Wtime();
//if(myId % 2 == 0){
if(myId == 0) {
for(i=0; i<loop_count; i++){
MPI_Ssend(&aux, 0, MPI_CHAR, numP-1, 99, comm);
MPI_Send(&aux, 0, MPI_CHAR, numP-1, 99, comm);
}
MPI_Recv(&aux, 0, MPI_CHAR, numP-1, 99, comm, MPI_STATUS_IGNORE);
} else if(myId+1 == numP) {
for(i=0; i<loop_count; i++){
MPI_Recv(&aux, 0, MPI_CHAR, 0, 99, comm, MPI_STATUS_IGNORE);
}
MPI_Ssend(&aux, 0, MPI_CHAR, 0, 99, comm);
MPI_Send(&aux, 0, MPI_CHAR, 0, 99, comm);
}
MPI_Barrier(comm);
stop_time = MPI_Wtime();
max_time = (stop_time - start_time) / loop_count;
//}
time = (stop_time - start_time) / loop_count;
//MPI_Allreduce(&elapsed_time, &max_time, 1, MPI_DOUBLE, MPI_MAX, comm);
MPI_Bcast(&max_time, 1, MPI_DOUBLE, ROOT, comm);
return max_time;
MPI_Bcast(&time, 1, MPI_DOUBLE, ROOT, comm);
return time;
}
......@@ -163,42 +157,33 @@ double latency(int myId, int numP, MPI_Comm comm) {
// Devuelve el tiempo necesario para realizar las pruebas
double bandwidth(int myId, int numP, MPI_Comm comm, double latency, int n) {
int i, loop_count = 100, n_bytes;
double start_time, stop_time, elapsed_time, bw, time, max_time;
double start_time, stop_time, bw, time;
char *aux;
n_bytes = n * sizeof(char);
aux = malloc(n_bytes);
elapsed_time = 0;
time = 0;
// if(myId+1 != numP || (myId+1 == numP && numP % 2 == 0)) {
MPI_Barrier(comm);
start_time = MPI_Wtime();
//if(myId % 2 == 0){
if(myId == 0) {
for(i=0; i<loop_count; i++){
MPI_Ssend(aux, n, MPI_CHAR, numP-1, 99, comm);
MPI_Send(aux, n, MPI_CHAR, numP-1, 99, comm);
}
MPI_Recv(aux, 0, MPI_CHAR, numP-1, 99, comm, MPI_STATUS_IGNORE);
} else if(myId+1 == numP) {
for(i=0; i<loop_count; i++){
MPI_Recv(aux, n, MPI_CHAR, 0, 99, comm, MPI_STATUS_IGNORE);
}
MPI_Ssend(aux, 0, MPI_CHAR, 0, 99, comm);
MPI_Send(aux, 0, MPI_CHAR, 0, 99, comm);
}
MPI_Barrier(comm);
stop_time = MPI_Wtime();
elapsed_time = (stop_time - start_time) / loop_count;
//}
if(myId %2 == 0) {
time = elapsed_time - latency;
}
time = (stop_time - start_time) / loop_count;
bw = ((double)n_bytes) / (time - latency);
MPI_Allreduce(&time, &max_time, 1, MPI_DOUBLE, MPI_MAX, comm);
//TODO Cambiar a Bcast si solo se realiza por Root
bw = ((double)n_bytes) / max_time;
MPI_Bcast(&bw, 1, MPI_DOUBLE, ROOT, comm);
free(aux);
return bw;
}
......
export TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
BUILD := build
export BUILDDIR = $(addprefix $(TOP),$(BUILD))
SUBDIRS := IOcodes Main malleability
.PHONY: subdirs $(SUBDIRS) build all
#
#
#
#
CC := gcc
MCC := mpicc
CFLAGS := -Wall
LIBFLAGS := -lm -lslurm -pthread
#
#
#
#
all: subdirs exec
exec: subdirs
$(MCC) $(CFLAGS) -o test.out $(wildcard $(BUILDDIR)/*.o) $(LIBFLAGS)
subdirs: $(SUBDIRS)
$(SUBDIRS): | $(BUILD)
$(MAKE) -C $@
# Orden de compilacion para las carpetas
# Carpeta en la que almacenar los compilados
$(BUILD):
mkdir -p $(BUILD)
clean:
-rm -rf $(BUILD)
dir_targets := distribution_methods
objects1 := CommDist
objects2 := malleabilityTypes malleabilityZombies ProcessDist
objects3 := malleabilityManager
depends := $(addsuffix .h, malleabilityDataStructures malleabilityStates)
CC := gcc
MCC := mpicc
CFLAGS := -Wall
.PHONY: $(dir_targets) subdir
all: subdir $(objects1) $(objects2) $(objects3)
subdir: $(dir_targets)
$(dir_targets): %:
$(MAKE) -C $@
$(objects1): %: %.c %.h $(depends) $(dir_targets)/block_distribution.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
$(objects2): %: %.c %.h $(depends) $(TOP)/IOcodes/results.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
$(objects3): %: %.c %.h $(objects1).h $(objects2).h $(depends) \
$(TOP)/IOcodes/read_ini.h $(TOP)/IOcodes/results.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
#$(objects1) $(objects2) $(objects3)
# CommDist.c
# malleabilityTypes.c malleabilityZombies.c ProcessDist.c
#
# malleabilityManager.c
# malleabilityDataStructures.h malleabilityStates.h
objects1 := block_distribution
CC := gcc
MCC := mpicc
CFLAGS := -Wall
all: $(objects1)
$(objects1): %: %.c %.h
$(MCC) $(CFLAGS) -c -o $(BUILDDIR)/$@.o $<
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment