Commit 028e3be4 authored by Francois Tessier's avatar Francois Tessier
Browse files

C and Fortran bindings with simple examples

parent dd442b80
...@@ -11,12 +11,6 @@ libtapioca.a:$(OBJ_FILES) ...@@ -11,12 +11,6 @@ libtapioca.a:$(OBJ_FILES)
%.o:%.cpp %.o:%.cpp
$(MPICXX) $(MPI_CFLAGS) -c $? -o $@ $(MPI_LDFLAGS) $(MPICXX) $(MPI_CFLAGS) -c $? -o $@ $(MPI_LDFLAGS)
cbinding:bindings/tapioca_capi.cpp
$(MPICXX) $(MPI_CFLAGS) -c $? -o bindings/tapioca_capi.o $(MPI_LDFLAGS)
fbinding:bindings/tapioca_f90api.cpp
$(MPICXX) $(MPI_CFLAGS) -c $? -o bindings/tapioca_f90api.o $(MPI_LDFLAGS)
install: install:
cp -r tapioca.hpp tp_utils.hpp $(TP_INCLUDE) $(INSTALL_PATH)/include cp -r tapioca.hpp tp_utils.hpp $(TP_INCLUDE) $(INSTALL_PATH)/include
cp libtapioca.a $(INSTALL_PATH)/lib cp libtapioca.a $(INSTALL_PATH)/lib
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize, void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm) int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm)
{ {
Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, c_comm ); Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, comm );
} }
void tapioca_set_aggregation_tier_ ( int nBuffers, mem_t mem, char* fileName ) void tapioca_set_aggregation_tier_ ( int nBuffers, mem_t mem, char* fileName )
......
#include "tapioca.hpp"
extern "C" {
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int* nChunks, int64_t* header, MPI_Fint* comm);
void tapioca_set_aggregation_tier_ ( int* nBuffers, mem_t* mem, char* fileName );
void tapioca_set_target_tier_ ( mem_t* mem, int64_t* buffSize, char* fileName );
int tapioca_write_ ( MPI_Offset* offset, void* buf, int* count,
MPI_Fint* datatype, MPI_Status* status );
int tapioca_read_ ( MPI_Offset* offset, void *buf, int* count,
MPI_Fint* datatype, MPI_Status *status );
void tapioca_finalize_ ( );
}
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
#include "tapioca_singleton.hpp" #include "tapioca_singleton.hpp"
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize, void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm) int64_t *chunkOffset, int *nChunks, int64_t *header, MPI_Fint *comm)
{ {
MPI_Comm c_comm = MPI_Comm_f2c ( (MPI_Fint)comm ); int nChunks_ = *nChunks;
int64_t header_ = (int64_t)*header;
Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, c_comm ); MPI_Comm comm_ = MPI_Comm_f2c ( *comm );
Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks_, header_, comm_ );
Tapioca_S::getInstance()->setAggregationTier ( 2, DDR, "" ); Tapioca_S::getInstance()->setAggregationTier ( 2, DDR, "" );
Tapioca_S::getInstance()->setTargetTier ( HDD, 7680000, "/projects/visualization/ftessier/debug/f90_HACC.dat" ); Tapioca_S::getInstance()->setTargetTier ( HDD, 7680000, "/projects/visualization/ftessier/debug/f90_HACC.dat" );
} }
...@@ -21,18 +23,24 @@ void tapioca_set_target_tier_ ( mem_t mem, int64_t buffSize, char* fileName ) ...@@ -21,18 +23,24 @@ void tapioca_set_target_tier_ ( mem_t mem, int64_t buffSize, char* fileName )
Tapioca_S::getInstance()->setTargetTier ( mem, buffSize, fileName ); Tapioca_S::getInstance()->setTargetTier ( mem, buffSize, fileName );
} }
int tapioca_write_ ( MPI_Offset offset, void *buf, int count, int tapioca_write_ ( MPI_Offset* offset, void *buf, int* count,
MPI_Datatype datatype, MPI_Status *status ) MPI_Fint* datatype, MPI_Status *status )
{ {
MPI_Datatype c_datatype = MPI_Type_f2c ( (MPI_Fint)datatype ); MPI_Datatype datatype_ = MPI_Type_f2c ( *datatype );
return Tapioca_S::getInstance()->Write ( offset, buf, count, c_datatype, status ); MPI_Offset offset_ = *offset;
int count_ = *count;
return Tapioca_S::getInstance()->Write ( offset_, buf, count_, datatype_, status );
} }
int tapioca_read_ ( MPI_Offset offset, void *buf, int count, int tapioca_read_ ( MPI_Offset* offset, void *buf, int* count,
MPI_Datatype datatype, MPI_Status *status ) MPI_Fint* datatype, MPI_Status *status )
{ {
MPI_Datatype c_datatype = MPI_Type_f2c ( (MPI_Fint)datatype ); MPI_Datatype datatype_ = MPI_Type_f2c ( *datatype );
return Tapioca_S::getInstance()->Read ( offset, buf, count, c_datatype, status ); MPI_Offset offset_ = *offset;
int count_ = *count;
return Tapioca_S::getInstance()->Read ( offset_, buf, count_, datatype_, status );
} }
void tapioca_finalize_ ( ) void tapioca_finalize_ ( )
......
include ../make.inc/Makefile.$(ARCHI)
MPI_CFLAGS = -g -O3 -I../ -I. -I../architectures -I../architectures/$(ARCHI)
MPI_CFLAGS += -DDBG -DCOLOR #-DTIMING
TP_INCLUDE = ../architectures/tp_network_interface.hpp \
../architectures/tp_memory_interface.hpp \
../architectures/$(ARCHI)/*
C_CPP_FILES := $(wildcard C/*.cpp)
C_OBJ_FILES := $(C_CPP_FILES:.cpp=.o)
F90_CPP_FILES := $(wildcard F90/*.cpp)
F90_OBJ_FILES := $(F90_CPP_FILES:.cpp=.o)
all:c_bindings f90_bindings
c_bindings:$(C_CPP_FILES)
$(MPICXX) $(MPI_CFLAGS) -c $? -o $(C_OBJ_FILES) $(MPI_LDFLAGS)
f90_bindings:$(F90_CPP_FILES)
$(MPICXX) $(MPI_CFLAGS) -c $? -o $(F90_OBJ_FILES) $(MPI_LDFLAGS)
clean:
rm -f $(F90_OBJ_FILES) $(C_OBJ_FILES)
MPICXX = mpicxx MPICXX = mpicxx
MPI_CFLAGS = -g -O3 -I$(HOME)/install/$(ARCHI)/include/ -I ../../bindings/ -DBGQ -DDBG -DCOLOR MPI_CFLAGS = -g -O3 -I$(HOME)/install/$(ARCHI)/include/ -I ../../bindings/C/ -DBGQ -DDBG -DCOLOR
MPI_LDFLAGS = -L$(HOME)/install/$(ARCHI)/lib/ -ltapioca MPI_LDFLAGS = -L$(HOME)/install/$(ARCHI)/lib/ -ltapioca
INSTALL_PATH = $(HOME)/install/$(ARCHI) INSTALL_PATH = $(HOME)/install/$(ARCHI)
all: 1d_array all: 1d_array
1d_array:1d_array.c ../../bindings/tapioca_capi.o 1d_array:1d_array.c ../../bindings/C/tapioca_capi.o
$(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS) $(MPICXX) $(MPI_CFLAGS) $? -o $@ $(MPI_LDFLAGS)
install: install:
......
...@@ -29,6 +29,6 @@ function outputFile () ...@@ -29,6 +29,6 @@ function outputFile ()
printenv | egrep "TAPIOCA_" printenv | egrep "TAPIOCA_"
PARTICLES=60000 PARTICLES=20000
rm $TARGET/* rm $TARGET/*
mpirun -f $COBALT_NODEFILE -n $NPROCS ./1d_array $PARTICLES mpirun -f $COBALT_NODEFILE -n $NPROCS ./1d_array $PARTICLES
MPIF90 = mpif90 MPIF90 = mpif90
FLAGS = -g -I$(HOME)/install/$(ARCHI)/include/ -I ../../bindings/ -DBGQ -DDBG -DCOLOR FLAGS = -g -I$(HOME)/install/$(ARCHI)/include/ -I ../../bindings/F90 -DBGQ -DDBG -DCOLOR
LDFLAGS = -L$(HOME)/install/$(ARCHI)/lib/ -ltapioca -lstdc++ LDFLAGS = -L$(HOME)/install/$(ARCHI)/lib/ -ltapioca -lstdc++
all: simple_array all: simple_array
simple_array:simple_array.o ../../bindings/tapioca_f90api.o simple_array:simple_array.o ../../bindings/F90/tapioca_f90api.o
$(MPIF90) $(FLAGS) $? -o $@ $(LDFLAGS) $(MPIF90) $(FLAGS) $? -o $@ $(LDFLAGS)
simple_array.o:simple_array.f90 simple_array.o:simple_array.f90
......
...@@ -4,10 +4,11 @@ PROGRAM main ...@@ -4,10 +4,11 @@ PROGRAM main
use iso_c_binding use iso_c_binding
integer ierr, i, myrank, mysize, filehandle integer ierr, i, myrank, mysize, filehandle
integer*8 BUFSIZE, TOTSIZE, SCANSIZE integer*8 BUFSIZE, TOTSIZE, SCANSIZE, HDR
integer buf(20000) integer buf(20000), buf_r(20000)
integer(kind=MPI_OFFSET_KIND) disp integer(kind=MPI_OFFSET_KIND) disp
integer status(MPI_STATUS_SIZE) integer status(MPI_STATUS_SIZE)
real*8 start, finish, duration, max_duration, io_bw
integer*8 chunkcount(1) integer*8 chunkcount(1)
integer chunksize(1) integer chunksize(1)
...@@ -15,6 +16,7 @@ PROGRAM main ...@@ -15,6 +16,7 @@ PROGRAM main
BUFSIZE = 20000 BUFSIZE = 20000
SCANSIZE = 0 SCANSIZE = 0
HDR = 0
call MPI_INIT(ierr) call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr)
...@@ -22,7 +24,7 @@ PROGRAM main ...@@ -22,7 +24,7 @@ PROGRAM main
call MPI_BARRIER(MPI_COMM_WORLD, ierr) call MPI_BARRIER(MPI_COMM_WORLD, ierr)
do i = 0, BUFSIZE do i = 1, BUFSIZE
buf(i) = myrank * BUFSIZE + i buf(i) = myrank * BUFSIZE + i
enddo enddo
...@@ -33,11 +35,46 @@ PROGRAM main ...@@ -33,11 +35,46 @@ PROGRAM main
chunksize (1) = 4 chunksize (1) = 4
chunkoffset (1) = SCANSIZE * chunksize (1) chunkoffset (1) = SCANSIZE * chunksize (1)
call tapioca_init ( chunkcount, chunksize, chunkoffset, %VAL(1), %VAL(0), %VAL(mpi_comm_world) ) call tapioca_init ( chunkcount, chunksize, chunkoffset, 1, HDR, mpi_comm_world )
call tapioca_write ( %VAL(chunkoffset(1)), buf, %VAL(BUFSIZE), %VAL(MPI_INT), status ) start = MPI_Wtime()
call tapioca_write ( chunkoffset(1), buf, BUFSIZE, MPI_INT, status )
call tapioca_finalize ( ) call tapioca_finalize ( )
finish = MPI_Wtime()
duration = finish - start
call MPI_REDUCE ( duration, max_duration, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD, ierr )
if ( myrank == 0 ) then
io_bw = TOTSIZE * 4 / max_duration / ( 1024 * 1024 )
write(*, '(a,f10.2,a)') "[TIMING] Write I/O bandwidth ",io_bw," MBps"
endif
call MPI_BARRIER ( MPI_COMM_WORLD, ierr )
call tapioca_init ( chunkcount, chunksize, chunkoffset, 1, HDR, mpi_comm_world )
start = MPI_Wtime()
call tapioca_read ( chunkoffset(1), buf_r, BUFSIZE, MPI_INT, status )
call tapioca_finalize ( )
finish = MPI_Wtime()
duration = finish - start
call MPI_REDUCE ( duration, max_duration, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD, ierr )
if ( myrank == 0 ) then
io_bw = TOTSIZE * 4 / max_duration / ( 1024 * 1024 )
write(*, '(a,f10.2,a)') "[TIMING] Read I/O bandwidth ",io_bw," MBps"
endif
call MPI_BARRIER ( MPI_COMM_WORLD, ierr )
do i = 1, BUFSIZE
if ( buf(i) .NE. buf_r(i) ) then
write (*,*) myrank,"Failed !"
call MPI_ABORT ( MPI_COMM_WORLD, -1, ierr )
endif
enddo
call MPI_FINALIZE(ierr) call MPI_FINALIZE(ierr)
......
...@@ -71,7 +71,7 @@ class Tapioca ...@@ -71,7 +71,7 @@ class Tapioca
/***********************/ /***********************/
Topology topology; Topology topology;
private: protected:
/***********************/ /***********************/
/* INITIALIZATION */ /* INITIALIZATION */
/***********************/ /***********************/
......
Markdown is supported
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