Commit 9cfc0941 authored by Francois Tessier's avatar Francois Tessier

C and F90 bindings. Need to be improved.

parent 599efbb1
......@@ -11,12 +11,15 @@ libtapioca.a:$(OBJ_FILES)
%.o:%.cpp
$(MPICXX) $(MPI_CFLAGS) -c $? -o $@ $(MPI_LDFLAGS)
cbinding:bindings/tapioca_capi.cpp
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:
cp -r tapioca.hpp tp_utils.hpp $(TP_INCLUDE) $(INSTALL_PATH)/include
cp libtapioca.a $(INSTALL_PATH)/lib
clean:
rm -f *.a *.o architectures/$(ARCHI)/*.o
rm -f *.a *.o architectures/$(ARCHI)/*.o bindings/tapioca_capi.o
#include "tapioca.hpp"
extern "C" {
class Tapioca;
typedef Tapioca TAPIOCA;
TAPIOCA* create_tapioca ();
void delete_tapioca( TAPIOCA* tapioca );
void tapioca_init ( TAPIOCA *tapioca, int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm);
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm);
void tapioca_set_aggregation_tier ( TAPIOCA *tapioca, int nBuffers, mem_t mem, char* fileName );
void tapioca_set_target_tier ( TAPIOCA *tapioca, mem_t mem, int64_t buffSize, char* fileName );
int tapioca_write ( TAPIOCA *tapioca, MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status );
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_Datatype datatype, MPI_Status *status );
int tapioca_read ( TAPIOCA *tapioca, MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status );
int tapioca_read_ ( MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status );
void tapioca_finalize ( TAPIOCA *tapioca );
void tapioca_finalize_ ( );
}
#include "tapioca.h"
#include "tapioca_singleton.hpp"
TAPIOCA* create_tapioca ()
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm)
{
fprintf ( stdout, "C API - create_tapioca\n" );
return new Tapioca ();
Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, c_comm );
}
void delete_tapioca( TAPIOCA* tapioca )
void tapioca_set_aggregation_tier_ ( int nBuffers, mem_t mem, char* fileName )
{
fprintf ( stdout, "C API - delete_tapioca\n" );
delete tapioca;
Tapioca_S::getInstance()->setAggregationTier ( nBuffers, mem, fileName );
}
void tapioca_init ( TAPIOCA *tapioca, int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm)
void tapioca_set_target_tier_ ( mem_t mem, int64_t buffSize, char* fileName )
{
return tapioca->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, comm );
Tapioca_S::getInstance()->setTargetTier ( mem, buffSize, fileName );
}
void tapioca_set_aggregation_tier ( TAPIOCA *tapioca, int nBuffers, mem_t mem, char* fileName )
int tapioca_write_ ( MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
{
return tapioca->setAggregationTier ( nBuffers, mem, fileName );
return Tapioca_S::getInstance()->Write ( offset, buf, count, datatype, status );
}
void tapioca_set_target_tier ( TAPIOCA *tapioca, mem_t mem, int64_t buffSize, char* fileName )
int tapioca_read_ ( MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
{
return tapioca->setTargetTier ( mem, buffSize, fileName );
return Tapioca_S::getInstance()->Read ( offset, buf, count, datatype, status );
}
int tapioca_write ( TAPIOCA *tapioca, MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
void tapioca_finalize_ ( )
{
return tapioca->Write ( offset, buf, count, datatype, status );
}
int tapioca_read ( TAPIOCA *tapioca, MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
{
return tapioca->Read ( offset, buf, count, datatype, status );
}
void tapioca_finalize ( TAPIOCA *tapioca )
{
return tapioca->Finalize ();
Tapioca_S::getInstance()->Finalize ();
}
#include "tapioca.h"
#include "tapioca_singleton.hpp"
void tapioca_init_ ( int64_t *chunkCount, int *chunkSize,
int64_t *chunkOffset, int nChunks, int64_t header, MPI_Comm comm)
{
MPI_Comm c_comm = MPI_Comm_f2c ( (MPI_Fint)comm );
Tapioca_S::getInstance()->Init ( chunkCount, chunkSize, chunkOffset, nChunks, header, c_comm );
Tapioca_S::getInstance()->setAggregationTier ( 2, DDR, "" );
Tapioca_S::getInstance()->setTargetTier ( HDD, 7680000, "/projects/visualization/ftessier/debug/f90_HACC.dat" );
}
void tapioca_set_aggregation_tier_ ( int nBuffers, mem_t mem, char* fileName )
{
Tapioca_S::getInstance()->setAggregationTier ( nBuffers, mem, fileName );
}
void tapioca_set_target_tier_ ( mem_t mem, int64_t buffSize, char* fileName )
{
Tapioca_S::getInstance()->setTargetTier ( mem, buffSize, fileName );
}
int tapioca_write_ ( MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
{
MPI_Datatype c_datatype = MPI_Type_f2c ( (MPI_Fint)datatype );
return Tapioca_S::getInstance()->Write ( offset, buf, count, c_datatype, status );
}
int tapioca_read_ ( MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Status *status )
{
MPI_Datatype c_datatype = MPI_Type_f2c ( (MPI_Fint)datatype );
return Tapioca_S::getInstance()->Read ( offset, buf, count, c_datatype, status );
}
void tapioca_finalize_ ( )
{
Tapioca_S::getInstance()->Finalize ();
}
#include "tapioca.hpp"
class Tapioca_S : public Tapioca
{
public:
static Tapioca_S* getInstance ();
private:
Tapioca_S () {};
Tapioca_S ( Tapioca_S const& );
void operator=( Tapioca_S const& );
static Tapioca_S *tapiocaInstance;
};
Tapioca_S* Tapioca_S::tapiocaInstance = NULL;
Tapioca_S* Tapioca_S::getInstance ()
{
if ( !tapiocaInstance )
tapiocaInstance = new Tapioca_S;
return tapiocaInstance;
}
......@@ -23,7 +23,6 @@ int main (int argc, char * argv[])
MPI_File file_handle;
MPI_Status status;
char output[100];
TAPIOCA* tp;
int64_t chunkCount[1], chunkOffset[1];
int chunkSize[1];
......@@ -31,8 +30,6 @@ int main (int argc, char * argv[])
MPI_Comm_size(MPI_COMM_WORLD, &world_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &world_myrank);
tp = create_tapioca ();
mycolor = 42;
mykey = world_myrank;
......@@ -87,16 +84,16 @@ int main (int argc, char * argv[])
chunkSize[0] = sizeof(float);
chunkOffset[0] = hdr + scan_size * particle_size;
tapioca_init ( tp, chunkCount, chunkSize, chunkOffset, 1, hdr, sub_comm);
tapioca_set_aggregation_tier ( tp, 2, DDR, "" );
tapioca_set_target_tier ( tp, HDD, file_size, output );
tapioca_init_ ( chunkCount, chunkSize, chunkOffset, 1, hdr, sub_comm);
tapioca_set_aggregation_tier_ ( 2, DDR, "" );
tapioca_set_target_tier_ ( HDD, file_size, output );
/*****************/
MPI_Barrier (MPI_COMM_WORLD);
start_time = MPI_Wtime();
offset = scan_size * particle_size;
tapioca_write ( tp, offset, xx, num_particles, MPI_FLOAT, &status );
tapioca_write_ ( offset, xx, num_particles, MPI_FLOAT, &status );
end_time = MPI_Wtime();
tot_time = end_time - start_time;
......@@ -108,7 +105,7 @@ int main (int argc, char * argv[])
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
tapioca_finalize ( tp );
tapioca_finalize_ ( );
MPI_Barrier (MPI_COMM_WORLD);
/*****************/
......@@ -120,15 +117,15 @@ int main (int argc, char * argv[])
/*****************/
/* INIT TAPIOCA */
/*****************/
tapioca_init ( tp, chunkCount, chunkSize, chunkOffset, 1, hdr, sub_comm);
tapioca_set_aggregation_tier ( tp, 2,DDR, "");
tapioca_set_target_tier ( tp,HDD, file_size, output );
tapioca_init_ ( chunkCount, chunkSize, chunkOffset, 1, hdr, sub_comm);
tapioca_set_aggregation_tier_ ( 2,DDR, "");
tapioca_set_target_tier_ ( HDD, file_size, output );
/*****************/
start_time = MPI_Wtime();
offset = scan_size * particle_size;
tapioca_read ( tp, offset, xx_r, num_particles, MPI_FLOAT, &status );
tapioca_read_ ( offset, xx_r, num_particles, MPI_FLOAT, &status );
end_time = MPI_Wtime();
tot_time = end_time - start_time;
......@@ -140,7 +137,7 @@ int main (int argc, char * argv[])
io_bw, (double)tot_size/(1024*1024), max_time * 1000);
}
tapioca_finalize ( tp );
tapioca_finalize_ ( );
MPI_Barrier (MPI_COMM_WORLD);
/*****************/
......
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