Commit 0e11f9b4 authored by incardon's avatar incardon

Adding broad cast

parent dcf398d0
......@@ -45,13 +45,13 @@ exit(0)\n"
bsub -o output_compile.%J -K -n 1 -J compile sh ./compile_script
## Run on the cluster
bsub -o output_run2.%J -K -n 2 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 2 ./src/vcluster"
bsub -o output_run2.%J -K -n 2 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 2 ./src/vcluster_test"
if [ $? -ne 0 ]; then exit 1 ; fi
bsub -o output_run4.%J -K -n 4 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 4 ./src/vcluster"
bsub -o output_run4.%J -K -n 4 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 4 ./src/vcluster_test"
if [ $? -ne 0 ]; then exit 1 ; fi
bsub -o output_run8.%J -K -n 8 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 8 ./src/vcluster"
bsub -o output_run8.%J -K -n 8 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 8 ./src/vcluster_test"
if [ $? -ne 0 ]; then exit 1 ; fi
bsub -o output_run12.%J -K -n 12 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 12 ./src/vcluster"
bsub -o output_run12.%J -K -n 12 -R "span[hosts=1]" "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 12 ./src/vcluster_test"
if [ $? -ne 0 ]; then exit 1 ; fi
# bsub -o output_run32.%J -K -n 32 "module load openmpi/1.8.1 ; module load gcc/4.9.2; mpirun -np 32 ./src/vcluster"
# if [ $? -ne 0 ]; then exit 1 ; fi
......@@ -75,19 +75,19 @@ elif [ "$2" == "taurus" ]; then
### to exclude --exclude=taurusi[6300-6400],taurusi[5400-5500]
salloc --nodes=1 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 24 src/vcluster --report_level=no"
salloc --nodes=1 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 24 src/vcluster_test --report_level=no"
if [ $? -ne 0 ]; then exit 1 ; fi
sleep 5
salloc --nodes=2 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 48 src/vcluster --report_level=no"
salloc --nodes=2 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 48 src/vcluster_test --report_level=no"
if [ $? -ne 0 ]; then exit 1 ; fi
sleep 5
salloc --nodes=4 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 96 src/vcluster --report_level=no"
salloc --nodes=4 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 96 src/vcluster_test --report_level=no"
if [ $? -ne 0 ]; then exit 1 ; fi
sleep 5
salloc --nodes=8 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 192 src/vcluster --report_level=no"
salloc --nodes=8 --ntasks-per-node=24 --time=00:05:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 192 src/vcluster_test --report_level=no"
if [ $? -ne 0 ]; then exit 1 ; fi
sleep 5
salloc --nodes=10 --ntasks-per-node=24 --time=00:5:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 240 src/vcluster --report_level=no"
salloc --nodes=10 --ntasks-per-node=24 --time=00:5:00 --mem-per-cpu=1800 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 240 src/vcluster_test --report_level=no"
if [ $? -ne 0 ]; then exit 1 ; fi
else
......@@ -99,11 +99,11 @@ else
sh ./configure CXX=mpic++
make
mpirun -np 2 ./src/vcluster
mpirun -np 2 ./src/vcluster_test
if [ $? -ne 0 ]; then exit 1 ; fi
mpirun -np 3 ./src/vcluster
mpirun -np 3 ./src/vcluster_test
if [ $? -ne 0 ]; then exit 1 ; fi
mpirun -np 4 ./src/vcluster
mpirun -np 4 ./src/vcluster_test
if [ $? -ne 0 ]; then exit 1 ; fi
fi
......
......@@ -12,7 +12,7 @@ libvcluster_a_SOURCES = VCluster/VCluster.cpp
libvcluster_a_CXXFLAGS = $(AM_CXXFLAGS) $(INCLUDES_PATH) $(BOOST_CPPFLAGS)
libvcluster_a_CFLAGS =
nobase_include_HEADERS = MPI_wrapper/MPI_IallreduceW.hpp MPI_wrapper/MPI_IrecvW.hpp MPI_wrapper/MPI_IsendW.hpp MPI_wrapper/MPI_util.hpp MPI_wrapper/MPI_IAllGather.hpp \
nobase_include_HEADERS = MPI_wrapper/MPI_IallreduceW.hpp MPI_wrapper/MPI_IrecvW.hpp MPI_wrapper/MPI_IBcastW.hpp MPI_wrapper/MPI_IsendW.hpp MPI_wrapper/MPI_util.hpp MPI_wrapper/MPI_IAllGather.hpp \
VCluster/VCluster_base.hpp VCluster/VCluster.hpp VCluster/VCluster_meta_function.hpp\
util/Vcluster_log.hpp
......
......@@ -371,9 +371,6 @@ class Vcluster: public Vcluster_base
// If we are on master collect the information
if (getProcessUnitID() == root)
{
#ifdef DEBUG
std::cout << "Inside root " << root << std::endl;
#endif
// send buffer (master does not send anything) so send req and send_buf
// remain buffer with size 0
openfpm::vector<size_t> send_req;
......@@ -398,9 +395,6 @@ class Vcluster: public Vcluster_base
}
else
{
#ifdef DEBUG
std::cout << "Inside slave " << getProcessUnitID() << std::endl;
#endif
// send buffer (master does not send anything) so send req and send_buf
// remain buffer with size 0
openfpm::vector<size_t> send_prc;
......
......@@ -9,6 +9,7 @@
#include "MPI_wrapper/MPI_IrecvW.hpp"
#include "MPI_wrapper/MPI_IsendW.hpp"
#include "MPI_wrapper/MPI_IAllGather.hpp"
#include "MPI_wrapper/MPI_IBcastW.hpp"
#include <exception>
#include "Vector/map_vector.hpp"
#ifdef DEBUG
......@@ -260,7 +261,7 @@ public:
bar_stat = MPI_Status();
}
#ifdef DEBUG
#ifdef SE_CLASS1
/*! \brief Check for wrong types
*
......@@ -343,7 +344,7 @@ public:
template<typename T> void sum(T & num)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
......@@ -363,7 +364,7 @@ public:
*/
template<typename T> void max(T & num)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
// reduce over MPI
......@@ -383,7 +384,7 @@ public:
template<typename T> void min(T & num)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
// reduce over MPI
......@@ -556,7 +557,7 @@ public:
*/
template<typename T> void sendrecvMultipleMessagesNBX(openfpm::vector< size_t > & prc, openfpm::vector< T > & data, void * (* msg_alloc)(size_t,size_t,size_t,size_t,size_t,void *), void * ptr_arg, long int opt=NONE)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<typename T::value_type>();
#endif
// resize the pointer list
......@@ -617,7 +618,7 @@ 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 = NONE)
{
if (stat.size() != 0 || req.size() != 0)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " this function must be called when no other requests are in progress. Please remember that id you use function like max(),sum(),send(),recv() check that you did not miss to call the function execute() \n";
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " this function must be called when no other requests are in progress. Please remember that if you use function like max(),sum(),send(),recv() check that you did not miss to call the function execute() \n";
stat.clear();
......@@ -770,7 +771,7 @@ public:
*/
template<typename T, typename Mem, typename gr> bool send(size_t proc, size_t tag, openfpm::vector<T,Mem,gr> & v)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
......@@ -835,7 +836,7 @@ public:
*/
template<typename T, typename Mem, typename gr> bool recv(size_t proc, size_t tag, openfpm::vector<T,Mem,gr> & v)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
......@@ -864,7 +865,7 @@ public:
*/
template<typename T, typename Mem, typename gr> bool allGather(T & send, openfpm::vector<T,Mem,gr> & v)
{
#ifdef DEBUG
#ifdef SE_CLASS1
checkType<T>();
#endif
......@@ -880,6 +881,37 @@ public:
return true;
}
/*! \brief Broadcast the data to all processors
*
* broadcast a vector of primitives.
*
* \warning operation is asynchronous execute must be called to ensure the operation is executed
*
* \warning the non-root processor must resize the vector to the exact receive size. This mean the
* each processor must known a priory the receiving size
*
* \param v vector to send in the case of the root processor and vector where to receive in the case of
* non-root
* \param root processor (who broadcast)
*
* \return true if succeed false otherwise
*
*/
template<typename T, typename Mem, typename gr> bool Bcast(openfpm::vector<T,Mem,gr> & v, size_t root)
{
#ifdef SE_CLASS1
checkType<T>();
#endif
// Create one request
req.add();
// gather
MPI_IBcastW<T>::bcast(root,v,req.last());
return true;
}
/*! \brief Execute all the requests
*
*/
......
......@@ -814,4 +814,35 @@ template<typename T> void test_single_all_gather_primitives(Vcluster & vcl)
}
template<typename T> void test_single_all_broadcast_primitives(Vcluster & vcl)
{
//! [bcast numbers]
openfpm::vector<T> bdata;
if (vcl.getProcessUnitID() == 0)
{
bdata.add(0);
bdata.add(1);
bdata.add(2);
bdata.add(3);
bdata.add(4);
bdata.add(5);
bdata.add(6);
}
else
{
bdata.resize(7);
}
vcl.Bcast(bdata,0);
vcl.execute();
for (size_t i = 0 ; i < bdata.size() ; i++)
BOOST_REQUIRE_EQUAL(i,(size_t)bdata.get(i));
//! [bcast numbers]
}
#endif /* VCLUSTER_UNIT_TEST_UTIL_HPP_ */
......@@ -152,9 +152,33 @@ BOOST_AUTO_TEST_CASE(VCluster_allgather)
test_single_all_gather_primitives<double>(vcl);
}
struct brt_test
{
double a;
double b;
};
BOOST_AUTO_TEST_CASE(VCluster_bcast_test)
{
Vcluster & vcl = create_vcluster();
std::cout << "Broadcast test" << std::endl;
test_single_all_broadcast_primitives<unsigned char>(vcl);
test_single_all_broadcast_primitives<char>(vcl);
test_single_all_broadcast_primitives<short>(vcl);
test_single_all_broadcast_primitives<unsigned short>(vcl);
test_single_all_broadcast_primitives<int>(vcl);
test_single_all_broadcast_primitives<unsigned int>(vcl);
test_single_all_broadcast_primitives<long int>(vcl);
test_single_all_broadcast_primitives<unsigned long int>(vcl);
test_single_all_broadcast_primitives<float>(vcl);
test_single_all_broadcast_primitives<double>(vcl);
}
BOOST_AUTO_TEST_CASE( VCluster_use_sendrecv)
{
std::cout << "VCluster unit test start" << "\n";
std::cout << "VCluster unit test start sendrecv" << "\n";
totp_check = false;
test<NBX>();
......@@ -162,16 +186,16 @@ BOOST_AUTO_TEST_CASE( VCluster_use_sendrecv)
totp_check = false;
test_no_send_some_peer<NBX>();
std::cout << "VCluster unit test stop" << "\n";
std::cout << "VCluster unit test stop sendrecv" << "\n";
}
BOOST_AUTO_TEST_CASE( VCluster_use_sendrecv_known)
{
std::cout << "VCluster unit test start" << "\n";
std::cout << "VCluster unit test start known" << "\n";
test_known<NBX>();
std::cout << "VCluster unit test stop" << "\n";
std::cout << "VCluster unit test stop known" << "\n";
}
......
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