Commit 03701b4f authored by incardon's avatar incardon

Fixing VCluster for broken tags

parent ae607867
......@@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
########################### Executables
add_executable(vcluster_test main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp ../../openfpm_devices/src/memory/CudaMemory.cu VCluster/cuda/VCluster_semantic_unit_cuda_tests.cu )
if (CUDA_FOUND)
set(CUDA_SOURCES ../../openfpm_devices/src/memory/CudaMemory.cu VCluster/cuda/VCluster_semantic_unit_cuda_tests.cu VCluster/cuda/VCluster_unit_tests.cu )
endif()
add_executable(vcluster_test main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp VCluster/VCluster_unit_tests.cpp VCluster/VCluster_semantic_unit_tests.cpp ${CUDA_SOURCES})
if ( CMAKE_COMPILER_IS_GNUCC )
target_compile_options(vcluster_test PRIVATE "-Wno-deprecated-declarations")
......
......@@ -941,6 +941,20 @@ static inline bool is_openfpm_init()
return ofp_initialized;
}
/*! \brief Return true is
*
*
* \return
*/
static inline bool is_mpi_rdma_cuda_active()
{
#if defined(MPIX_CUDA_AWARE_SUPPORT) && MPIX_CUDA_AWARE_SUPPORT
return true;
#else
return false;
#endif
}
/*! \brief Initialize the library
*
* This function MUST be called before any other function
......
......@@ -2,7 +2,12 @@
#define VCLUSTER_BASE_HPP_
#include "config.h"
#ifdef OPENMPI
#include <mpi.h>
#include <mpi-ext.h>
#else
#include <mpi.h>
#endif
#include "MPI_wrapper/MPI_util.hpp"
#include "Vector/map_vector.hpp"
#include "MPI_wrapper/MPI_IallreduceW.hpp"
......@@ -741,7 +746,7 @@ public:
// Allocate the buffers
for (size_t i = 0 ; i < n_send ; i++)
{send(prc[i],SEND_SPARSE + NBX_cnt*131072 + i,ptr[i],sz[i]);}
{send(prc[i],SEND_SPARSE + NBX_cnt*131072,ptr[i],sz[i]);}
for (size_t i = 0 ; i < n_recv ; i++)
{
......
......@@ -5,9 +5,8 @@
* Author: i-bird
*/
#ifndef OPENFPM_VCLUSTER_SRC_VCLUSTER_SEMANTIC_UNIT_TESTS_HPP_
#define OPENFPM_VCLUSTER_SRC_VCLUSTER_SEMANTIC_UNIT_TESTS_HPP_
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "Grid/grid_util_test.hpp"
#include "data_type/aggregate.hpp"
#include "VCluster/cuda/VCluster_semantic_unit_tests_funcs.hpp"
......@@ -539,57 +538,11 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_gather)
}
}
template<typename Memory, template<typename> class layout_base>
void test_different_layouts()
{
for (size_t i = 0 ; i < 100 ; i++)
{
Vcluster<> & vcl = create_vcluster();
if (vcl.getProcessingUnits() >= 32)
return;
openfpm::vector<aggregate<int,float,size_t>,Memory,typename layout_base<aggregate<int,float,size_t>>::type,layout_base> v1;
v1.resize(vcl.getProcessUnitID());
for(size_t i = 0 ; i < vcl.getProcessUnitID() ; i++)
{
v1.template get<0>(i) = 5;
v1.template get<1>(i) = 10.0+1000.0;
v1.template get<2>(i) = 11.0+100000;
}
openfpm::vector<aggregate<int,float,size_t>,Memory,typename layout_base<aggregate<int,float,size_t>>::type,layout_base> v2;
vcl.SGather<decltype(v1),decltype(v2),layout_base>(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_correct = true;
for (size_t i = 0 ; i < v2.size() ; i++)
{
is_correct &= (v2.template get<0>(i) == 5);
is_correct &= (v2.template get<1>(i) == 10.0+1000.0);
is_correct &= (v2.template get<2>(i) == 11.0+100000.0);
}
BOOST_REQUIRE_EQUAL(is_correct,true);
}
if (vcl.getProcessUnitID() == 0 && i == 99)
std::cout << "Semantic gather test stop" << std::endl;
}
}
BOOST_AUTO_TEST_CASE (Vcluster_semantic_layout_inte_gather)
{
test_different_layouts<HeapMemory,memory_traits_inte>();
test_different_layouts<HeapMemory,memory_traits_lin>();
test_different_layouts<CudaMemory,memory_traits_inte>();
test_different_layouts<CudaMemory,memory_traits_lin>();
}
#define SSCATTER_MAX 7
......@@ -1655,5 +1608,4 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_sendrecv_6)
BOOST_AUTO_TEST_SUITE_END()
#endif /* OPENFPM_VCLUSTER_SRC_VCLUSTER_SEMANTIC_UNIT_TESTS_HPP_ */
......@@ -11,6 +11,7 @@
#include "Point_test.hpp"
#include "VCluster_base.hpp"
#include "Vector/vector_test_util.hpp"
#include "VCluster/VCluster.hpp"
#define RECEIVE_UNKNOWN 1
#define RECEIVE_SIZE_UNKNOWN 2
......@@ -861,83 +862,4 @@ template<typename T> void test_single_all_gather_primitives(Vcluster<> & vcl)
}
template<typename T,typename Memory, template <typename> class layout_base> void test_single_all_broadcast_primitives(Vcluster<> & vcl)
{
//! [bcast numbers]
openfpm::vector<T,Memory,typename layout_base<T>::type,layout_base> 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]
}
template<typename T,typename Memory, template <typename> class layout_base> void test_single_all_broadcast_complex(Vcluster<> & vcl)
{
//! [bcast numbers]
openfpm::vector<T,Memory,typename layout_base<T>::type,layout_base> bdata;
if (vcl.getProcessUnitID() == 0)
{
bdata.add();
bdata.template get<0>(bdata.size()-1) = 0;
bdata.template get<1>(bdata.size()-1) = 1000;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 1;
bdata.template get<1>(bdata.size()-1) = 1001;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 2;
bdata.template get<1>(bdata.size()-1) = 1002;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 3;
bdata.template get<1>(bdata.size()-1) = 1003;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 4;
bdata.template get<1>(bdata.size()-1) = 1004;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 5;
bdata.template get<1>(bdata.size()-1) = 1005;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 6;
bdata.template get<1>(bdata.size()-1) = 1006;
}
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.template get<0>(i));
BOOST_REQUIRE_EQUAL(i+1000,(size_t)bdata.template get<1>(i));
}
//! [bcast numbers]
}
#endif /* VCLUSTER_UNIT_TEST_UTIL_HPP_ */
......@@ -5,10 +5,8 @@
* Author: Pietro incardona
*/
#ifndef VCLUSTER_UNIT_TESTS_HPP_
#define VCLUSTER_UNIT_TESTS_HPP_
#include <sstream>
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "timer.hpp"
#include <random>
......@@ -16,6 +14,8 @@
#include "Point_test.hpp"
#include "VCluster_base.hpp"
#include "Vector/vector_test_util.hpp"
#include "VCluster/VCluster.hpp"
#include "VCluster/cuda/VCluster_unit_test_util_cuda.cuh"
BOOST_AUTO_TEST_SUITE( VCluster_test )
......@@ -184,8 +184,6 @@ BOOST_AUTO_TEST_CASE(VCluster_bcast_complex_test)
test_single_all_broadcast_complex<aggregate<int,int>,HeapMemory,memory_traits_lin>(vcl);
test_single_all_broadcast_complex<aggregate<int,int>,HeapMemory,memory_traits_inte>(vcl);
test_single_all_broadcast_complex<aggregate<int,int>,CudaMemory,memory_traits_lin>(vcl);
test_single_all_broadcast_complex<aggregate<int,int>,CudaMemory,memory_traits_inte>(vcl);
}
BOOST_AUTO_TEST_CASE( VCluster_use_sendrecv)
......@@ -227,5 +225,3 @@ BOOST_AUTO_TEST_CASE( VCluster_use_sendrecv_known )
BOOST_AUTO_TEST_SUITE_END()
#endif /* VCLUSTER_UNIT_TESTS_HPP_ */
......@@ -18,4 +18,10 @@ BOOST_AUTO_TEST_CASE( Vcluster_semantic_gpu_direct )
test_ssend_recv_layout_switch<CudaMemory>(MPI_GPU_DIRECT);
}
BOOST_AUTO_TEST_CASE (Vcluster_semantic_layout_inte_gather)
{
test_different_layouts<CudaMemory,memory_traits_inte>();
test_different_layouts<CudaMemory,memory_traits_lin>();
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -8,6 +8,52 @@
#ifndef VCLUSTER_SEMANTIC_UNIT_TESTS_FUNCS_HPP_
#define VCLUSTER_SEMANTIC_UNIT_TESTS_FUNCS_HPP_
#include "VCluster/VCluster.hpp"
template<typename Memory, template<typename> class layout_base>
void test_different_layouts()
{
for (size_t i = 0 ; i < 100 ; i++)
{
Vcluster<> & vcl = create_vcluster();
if (vcl.getProcessingUnits() >= 32)
return;
openfpm::vector<aggregate<int,float,size_t>,Memory,typename layout_base<aggregate<int,float,size_t>>::type,layout_base> v1;
v1.resize(vcl.getProcessUnitID());
for(size_t j = 0 ; j < vcl.getProcessUnitID() ; j++)
{
v1.template get<0>(j) = 5;
v1.template get<1>(j) = 10.0+1000.0;
v1.template get<2>(j) = 11.0+100000;
}
openfpm::vector<aggregate<int,float,size_t>,Memory,typename layout_base<aggregate<int,float,size_t>>::type,layout_base> v2;
vcl.SGather<decltype(v1),decltype(v2),layout_base>(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_correct = true;
for (size_t i = 0 ; i < v2.size() ; i++)
{
is_correct &= (v2.template get<0>(i) == 5);
is_correct &= (v2.template get<1>(i) == 10.0+1000.0);
is_correct &= (v2.template get<2>(i) == 11.0+100000.0);
}
BOOST_REQUIRE_EQUAL(is_correct,true);
}
if (vcl.getProcessUnitID() == 0 && i == 99)
std::cout << "Semantic gather test stop" << std::endl;
}
}
template<typename Memory>
void test_ssend_recv_layout_switch(size_t opt)
{
......@@ -106,8 +152,6 @@ void test_ssend_recv_layout_switch(size_t opt)
{
match &= collect.template get<0>(i*100 +j) == v_cl.rank()*10000 + i*100 + j;
std::cout << "COLLECT: " << collect.template get<0>(i*100 +j) << std::endl;
match &= collect.template get<1>(i*100 +j)[0] == 400000 + v_cl.rank()*10000 + i*100 + j;
match &= collect.template get<1>(i*100 +j)[1] == 400000 + v_cl.rank()*10000 + i*100 + j;
match &= collect.template get<1>(i*100 +j)[2] == 400000 + v_cl.rank()*10000 + i*100 + j;
......
/*
* VCluster_unit_test_util_cuda.cuh
*
* Created on: Dec 21, 2018
* Author: i-bird
*/
#ifndef VCLUSTER_UNIT_TEST_UTIL_CUDA_CUH_
#define VCLUSTER_UNIT_TEST_UTIL_CUDA_CUH_
template<typename T,typename Memory, template <typename> class layout_base> void test_single_all_broadcast_primitives(Vcluster<> & vcl)
{
//! [bcast numbers]
openfpm::vector<T,Memory,typename layout_base<T>::type,layout_base> 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]
}
template<typename T,typename Memory, template <typename> class layout_base> void test_single_all_broadcast_complex(Vcluster<> & vcl)
{
//! [bcast numbers]
openfpm::vector<T,Memory,typename layout_base<T>::type,layout_base> bdata;
if (vcl.getProcessUnitID() == 0)
{
bdata.add();
bdata.template get<0>(bdata.size()-1) = 0;
bdata.template get<1>(bdata.size()-1) = 1000;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 1;
bdata.template get<1>(bdata.size()-1) = 1001;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 2;
bdata.template get<1>(bdata.size()-1) = 1002;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 3;
bdata.template get<1>(bdata.size()-1) = 1003;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 4;
bdata.template get<1>(bdata.size()-1) = 1004;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 5;
bdata.template get<1>(bdata.size()-1) = 1005;
bdata.add();
bdata.template get<0>(bdata.size()-1) = 6;
bdata.template get<1>(bdata.size()-1) = 1006;
}
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.template get<0>(i));
BOOST_REQUIRE_EQUAL(i+1000,(size_t)bdata.template get<1>(i));
}
//! [bcast numbers]
}
#endif /* VCLUSTER_UNIT_TEST_UTIL_CUDA_CUH_ */
#include <sstream>
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "timer.hpp"
#include <random>
#include "Point_test.hpp"
#include "VCluster/VCluster_base.hpp"
#include "VCluster/VCluster.hpp"
#include "VCluster/cuda/VCluster_unit_test_util_cuda.cuh"
BOOST_AUTO_TEST_SUITE( VCluster_test_cuda )
BOOST_AUTO_TEST_CASE(VCluster_bcast_complex_test)
{
Vcluster<> & vcl = create_vcluster();
std::cout << "Broadcast complex test CUDA" << std::endl;
test_single_all_broadcast_complex<aggregate<int,int>,CudaMemory,memory_traits_lin>(vcl);
test_single_all_broadcast_complex<aggregate<int,int>,CudaMemory,memory_traits_inte>(vcl);
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -17,5 +17,3 @@ int main(int argc, char* argv[])
#include "VCluster/VCluster.hpp"
#include "unit_test_init_cleanup.hpp"
#include "VCluster/VCluster_unit_tests.hpp"
#include "VCluster/VCluster_semantic_unit_tests.hpp"
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