Commit 19be3810 authored by incardon's avatar incardon

Adding skeleton of pack selector + script fixing for taurus 2

parent fc67fe7c
......@@ -77,15 +77,15 @@ then
make
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=1 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy mpirun -np 16 src/vcluster
salloc --nodes=1 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 16 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=2 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy mpirun -np 32 src/vcluster
salloc --nodes=2 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bach -c "ulimit -s unlimited && mpirun -np 32 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=4 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy mpirun -np 64 src/vcluster
salloc --nodes=4 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 64 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=8 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy mpirun -np 128 src/vcluster
salloc --nodes=8 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 128 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=16 --ntasks-per-node=16 --time=00:5:00 --mem-per-cpu=1900 --partition=sandy mpirun -np 256 src/vcluster
salloc --nodes=16 --ntasks-per-node=16 --time=00:5:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 256 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
else
......
......@@ -17,10 +17,10 @@
*
*/
template<typename T> class MPI_IsendW
template<typename T, typename ly, typename Mem, typename gr> class MPI_IsendW
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<T> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<T,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size() * sizeof(T),MPI_BYTE, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -30,10 +30,10 @@ public:
/*! \brief specialization for vector of integer
*
*/
template<> class MPI_IsendW<int>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<int,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<int> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<int,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_INT, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -42,10 +42,10 @@ public:
/*! \brief specialization for unsigned integer
*
*/
template<> class MPI_IsendW<unsigned int>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<unsigned int,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned int> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned int,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -54,10 +54,10 @@ public:
/*! \brief specialization for short
*
*/
template<> class MPI_IsendW<short>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<short,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<short> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<short,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_SHORT, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -66,10 +66,10 @@ public:
/*! \brief specialization for short
*
*/
template<> class MPI_IsendW<unsigned short>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<unsigned short,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned short> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned short,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_SHORT, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -78,10 +78,10 @@ public:
/*! \brief specialization for char
*
*/
template<> class MPI_IsendW<char>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<char,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<char> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<char,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_CHAR, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -90,10 +90,10 @@ public:
/*! \brief specialization for char
*
*/
template<> class MPI_IsendW<unsigned char>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<unsigned char,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned char> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned char,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_CHAR, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -102,10 +102,10 @@ public:
/*! \brief specialization for size_t
*
*/
template<> class MPI_IsendW<size_t>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<size_t,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<size_t> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<size_t,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_LONG, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -114,10 +114,10 @@ public:
/*! \brief specialization for size_t
*
*/
template<> class MPI_IsendW<long int>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<long int,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<long int> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<long int,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_LONG, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -126,10 +126,10 @@ public:
/*! \brief specialization for float
*
*/
template<> class MPI_IsendW<float>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<float,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<float> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<float,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_FLOAT, proc, tag , MPI_COMM_WORLD,&req);
}
......@@ -138,10 +138,10 @@ public:
/*! \brief specialization for double
*
*/
template<> class MPI_IsendW<double>
template<typename ly, typename Mem, typename gr> class MPI_IsendW<double,ly,Mem,gr>
{
public:
static inline void send(size_t proc , size_t tag ,openfpm::vector<double> & v, MPI_Request & req)
static inline void send(size_t proc , size_t tag ,openfpm::vector<double,ly,Mem,gr> & v, MPI_Request & req)
{
MPI_Isend(v.getPointer(), v.size(),MPI_DOUBLE, proc, tag , MPI_COMM_WORLD,&req);
}
......
......@@ -187,8 +187,8 @@ CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPPFLAGS =
CUDA_CFLAGS = -I -I -I/usr/local/cuda-5.5/include
CUDA_LIBS = -L -L -L/usr/local/cuda-5.5/lib64 -lcuda -lcudart
CUDA_CFLAGS = -I -I -I/usr/local/cuda/include
CUDA_LIBS = -L -L -L/usr/local/cuda/lib64 -lcuda -lcudart
CXX = mpic++
CXXDEPMODE = depmode=gcc3
CXXFLAGS = --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter -Wall -O3 -g3 -funroll-loops
......@@ -212,7 +212,7 @@ LIBS =
LTLIBOBJS =
MAKEINFO = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing makeinfo
MKDIR_P = /usr/bin/mkdir -p
NVCC = /usr/local/cuda-5.5/bin/nvcc
NVCC = /usr/local/cuda/bin/nvcc
NVCCFLAGS = -O3
NVCC_EXIST = yes
OBJEXT = o
......
/*
* Pack_selector.hpp
*
* Created on: Jul 15, 2015
* Author: Pietro Incardona
*/
#include <type_traits>
//! Primitive packing
#define PACKER_PRIMITIVE 1
//! Object packing
#define PACKER_OBJECTS 2
//! Encapsulated Object packing
#define PACKER_ENCAP_OBJECTS 3
//! Vector of objects packing
#define PACKER_VECTOR 4
//! Grid packing
#define PACKER_GRID 5
//! Packer cannot check for pointers
#define PACKER_OBJECTS_WITH_WARNING_POINTERS 6
//! Packer error structure has pointers
#define PACKER_OBJECTS_WITH_POINTER_CHECK 7
#ifndef SRC_PACK_SELECTOR_HPP_
#define SRC_PACK_SELECTOR_HPP_
#define IS_ENCAP 4
#define IS_GRID 2
#define IS_VECTOR 1
/*! \brief Pack selector for unknown type
*
*
*/
template <typename T, bool has_noPointers>
struct Pack_selector_unknown_type_impl
{
enum
{
value = PACKER_OBJECTS_WITH_POINTER_CHECK
};
};
template <typename T>
struct Pack_selector_unknown_type_impl<T,false>
{
enum
{
value = PACKER_OBJECTS_WITH_WARNING_POINTERS
};
};
/*! \brief Pack selector for unknown type
*
*
*/
template <typename T, int known_type>
struct Pack_selector_known_type_impl
{
enum
{
value = Pack_selector_unknown_type_impl<T, has_noPointers<T>::value >::value
};
};
template <typename T>
struct Pack_selector_known_type_impl<T,IS_GRID>
{
enum
{
value = PACKER_GRID
};
};
template <typename T>
struct Pack_selector_known_type_impl<T,IS_VECTOR>
{
enum
{
value = PACKER_VECTOR
};
};
template <typename T>
struct Pack_selector_known_type_impl<T,IS_ENCAP>
{
enum
{
value = PACKER_ENCAP_OBJECTS
};
};
/////////////////////// ---------- CHECKING FOR PRIMITIVES --------------
/*! \brief it is not a fundamental type
*
*/
template<typename T, bool is_foundamental>
struct Pack_selector_impl
{
enum
{
value = Pack_selector_known_type_impl< T, is_grid<T>::value * 2 + is_vector<T>::value >::value
};
};
/*! \brief Select the primitive packing
*
*/
template<typename T>
struct Pack_selector_impl<T,true>
{
enum
{
value = PACKER_PRIMITIVE
};
};
//////////////////////////////////////////////////////////////////////////
/*! \brief Pack selector
*
*
*/
template <typename T>
struct Pack_selector
{
enum
{
value = Pack_selector_impl< T,std::is_fundamental<T>::value >::value
};
};
#endif /* SRC_PACK_SELECTOR_HPP_ */
/*
* Packer_cls.hpp
*
* Created on: Jul 15, 2015
* Author: i-bird
*/
#ifndef SRC_PACKER_HPP_
#define SRC_PACKER_HPP_
#include "util/object_util.hpp"
#include "Grid/util.hpp"
#include "Vector/util.hpp"
/*! \brief Packing class
*
* This class is going to pack objects
*
* \tparam T base type
* \tparam Mem Memory type
* \tparam pack_type type of packing
*
*/
template<typename T, typename Mem, int pack_type>
class Packer
{
public:
/*! \brief Error, no implementation
*
*/
void pack(ExtPreAlloc<Mem> , T & obj)
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " packing for the type " << demangle(typeid(T).name()) << " is not implemented\n";
}
/*! \brief Error, no implementation
*
*/
size_t packRequest(std::vector<size_t> & req)
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " packing for the type " << demangle(typeid(T).name()) << " is not implemented\n";
return 0;
}
};
/*! \brief Packer class for primitives
*
* \tparam T base type
* \tparam Mem Memory type
* \tparam pack_type type of packing
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_PRIMITIVE>
{
public:
/*! \brief
*
* It pack any C++ primitives
*
*/
void pack(ExtPreAlloc<Mem> & ext, T & obj)
{
ext.allocate(sizeof(T));
*(T *)ext.getPointer() = obj;
}
/*! \brief
*
*
*/
size_t packRequest(std::vector<size_t> & req)
{
return req.push_back(sizeof(T));
}
};
/*! \brief Packer class for objects
*
* \tparam T Type of Memory
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_OBJECTS>
{
public:
/*! \brief
*
*
*/
void pack(ExtPreAlloc<Mem> & ext, T & obj)
{
ext.allocate(sizeof(T));
memcpy((T *)ext.getPointer(),&obj,sizeof(T));
}
/*! \brief
*
*
*/
size_t packRequest(std::vector<size_t> & req)
{
return req.push_back(sizeof(T));
}
};
/*! \brief Packer class for vectors
*
* \tparam T Type of Memory
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_VECTOR>
{
public:
/*! \brief pack a vector of objects selecting the properties to pack
*
*
*/
template<unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, T & obj)
{
}
/*! \brief Insert an allocation request into the vector
*
* \param vector of request
*
*/
template<unsigned int ... prp> void packRequest(T & obj, std::vector<size_t> & v)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(obj.size(),0);
v.push_back(alloc_ele);
}
};
/*! \brief Packer class for grids
*
* \tparam T Type of Memory
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_GRID>
{
/*! \brief Pack the object into the memory given an iterator
*
* \tparam it Type of iterator
* \tparam dim Dimensionality of the grid
* \tparam properties to pack
*
*/
template <typename it,unsigned int dim, unsigned int ... prp> static void pack_with_iterator(ExtPreAlloc<Mem> & mem, it & sub_it, T & obj)
{
// Sending property object
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
// Packing the information
while (sub_it.isNext())
{
// copy all the object in the send buffer
typedef encapc<dim,T,typename grid_cpu<dim,T>::memory_conf > encap_src;
// destination object type
typedef encapc<1,prp_object,typename grid_cpu<dim,prp_object>::memory_conf > encap_dst;
// Copy only the selected properties
object_si_d<encap_src,encap_dst,ENCAP,prp...>(obj.get_o(sub_it.get()),dest.get(sub_it.getLoc()));
++sub_it;
}
}
public:
/*! \brief Pack the object into the memory given an iterator
*
* \tparam dim Dimensionality of the grid
* \tparam prp properties to pack
*
* \param mem Memory type
* \param obj object to pack
*
*/
template<unsigned int dim, unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, T & obj)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(obj.size(),0);
// Allocate memory
mem.allocate(alloc_ele);
// Sending property object
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
// Create an object over the preallocated memory (No allocation is produced)
openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>> dest;
dest.setMemory(mem);
dest.resize(obj.size());
auto it = obj.getIterator();
pack_with_iterator(mem,it,obj);
}
/*! \brief Pack the object into the memory given an iterator
*
* \tparam dim Dimensionality of the grid
* \tparam prp properties to pack
*
* \param mem Memory type
* \param sub_it sub grid iterator ( or the element in the grid to pack )
* \param obj object to pack
*
*/
template<unsigned int dim, unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, grid_key_dx_iterator_sub<dim> & sub_it, T & obj)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(sub_it.getVolume(),0);
// Allocate memory
mem.allocate(alloc_ele);
// Sending property object
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
// Create an object over the preallocated memory (No allocation is produced)
openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>> dest;
dest.setMemory(mem);
dest.resize(sub_it.getVolume());
pack_with_iterator(mem,sub_it,obj);
}
/*! \brief Insert an allocation request into the vector
*
* \param vector of request
*
*/
template<unsigned int dim, unsigned int ... prp> void packRequest(T & obj, std::vector<size_t> & v)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(obj.size(),0);
v.push_back(alloc_ele);
}
};
/*! \brief Packer class for encapsulated objects
*
* \tparam T Type of Memory
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_ENCAP_OBJECT>
{
public:
/*! \brief
*
*
*/
void pack(ExtPreAlloc<Mem> , T & obj)
{
}
/*! \brief
*
*
*/
size_t packRequest()
{
return sizeof(T);
}
};
#endif /* SRC_PACKER_HPP_ */
/*
* Packer_unit_tests.hpp
*
* Created on: Jul 15, 2015
* Author: Pietro Incardona
*/
#ifndef SRC_PACKER_UNIT_TESTS_HPP_
#define SRC_PACKER_UNIT_TESTS_HPP_
BOOST_AUTO_TEST_SUITE( Packer )
#include "Pack_selector.hpp"
BOOST_AUTO_TEST_CASE ( Packer_test )
{
//! [Pack selector usage]
int val = Pack_selector<unsigned char>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<char>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<short>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<unsigned short>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<int>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<unsigned int>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<long int>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<unsigned long int>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<float>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<double>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector< openfpm::vector<Point_test<float>> >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_VECTOR);
val = Pack_selector< grid_cpu<3,Point_test<float>> >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
val = Pack_selector< encapc<3,Point_test<float>, memory_traits_lin<Point_test<float>> > >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
struct test_s
{
float a;
float b;
bool noPointers() {return true;}
};
val = Pack_selector< test_s >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
//! [Pack selector usage]
//! [Pack into a message primitives objects vector and grids]
unsigned char uc = 1;
char c = 2;
short s = 3;
unsigned short us = 4;
int i = 5;
unsigned int ui = 6;
long int li = 7;
unsigned long int uli = 8;
float f = 9;
double d = 10;
std::vector<size_t> pap_prp;
/* Packer<unsigned char>::packRequest(pap_prp);
Packer<char>::packRequest();
Packer<short>*/
// try to pack all the primitives
//! [Pack into a message primitives objects vector and grids]
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_PACKER_UNIT_TESTS_HPP_ */
......@@ -496,6 +496,11 @@ public:
void sendrecvMultipleMessagesNBX(size_t n_send , size_t sz[], size_t prc[] , void * ptr[], void * (* msg_alloc)(size_t,size_t,size_t,size_t,size_t,void *), void * ptr_arg, long int opt)
{
if (stat.size() != 0 || req.size() != 0)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " this function must be called when no other requests are in progress \n";
stat.clear();
req.clear();
// Do MPI_Issend
......@@ -620,7 +625,12 @@ public:
void sendrecvMultipleMessagesPCX(size_t n_send, size_t * map, size_t sz[], size_t prc[] , void * ptr[], void * (* msg_alloc)(size_t,size_t,size_t,size_t,size_t,void *), void * ptr_arg, long int opt)
{
if (stat.size() != 0 || req.size() != 0)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " this function must be called when no other requests are in progress \n";
stat.clear();
req.clear();
req.add();
stat.add();
......@@ -735,7 +745,7 @@ public:
req.add();
// send
MPI_IsendW<T>::send(proc,SEND_RECV_BASE + tag,v,req.last());
MPI_IsendW<T,ly,Mem,gr>::send(proc,SEND_RECV_BASE + tag,v,req.last());
return true;
}
......@@ -757,7 +767,7 @@ public:
* \return true if succeed false otherwise
*
*/
template<typename T> bool recv(size_t proc, size_t tag, openfpm::vector<T> & v)
template<typename T, typename ly, typename Mem, typename gr