Skip to content

Commit

Permalink
Updated tests to new version of hlslib
Browse files Browse the repository at this point in the history
  • Loading branch information
TizianoDeMatteis committed Apr 7, 2020
1 parent e9d7440 commit ef17c39
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 88 deletions.
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lgtest")

#p2p
smi_target(test_p2p "${CMAKE_CURRENT_SOURCE_DIR}/p2p/p2p.json" "${CMAKE_CURRENT_SOURCE_DIR}/p2p/test_p2p.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/p2p/p2p_rank0.cl;${CMAKE_CURRENT_SOURCE_DIR}/p2p/p2p_rank1.cl" 8)
target_link_libraries(test_p2p_host gtest)

add_test(
NAME p2p
Expand All @@ -51,6 +52,7 @@ add_test(

#broadcast
smi_target(test_broadcast "${CMAKE_CURRENT_SOURCE_DIR}/broadcast/broadcast.json" "${CMAKE_CURRENT_SOURCE_DIR}/broadcast/test_broadcast.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/broadcast/broadcast.cl" 8)
target_link_libraries(test_broadcast_host gtest)

add_test(
NAME broadcast
Expand All @@ -60,6 +62,7 @@ add_test(

#reduce
smi_target(test_reduce "${CMAKE_CURRENT_SOURCE_DIR}/reduce/reduce.json" "${CMAKE_CURRENT_SOURCE_DIR}/reduce/test_reduce.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/reduce/reduce.cl" 8)
target_link_libraries(test_reduce_host gtest)

add_test(
NAME reduce
Expand All @@ -69,6 +72,7 @@ add_test(


smi_target(test_scatter "${CMAKE_CURRENT_SOURCE_DIR}/scatter/scatter.json" "${CMAKE_CURRENT_SOURCE_DIR}/scatter/test_scatter.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/scatter/scatter.cl" 8)
target_link_libraries(test_scatter_host gtest)

add_test(
NAME scatter
Expand All @@ -77,6 +81,7 @@ add_test(
)

smi_target(test_gather "${CMAKE_CURRENT_SOURCE_DIR}/gather/gather.json" "${CMAKE_CURRENT_SOURCE_DIR}/gather/test_gather.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/gather/gather.cl" 8)
target_link_libraries(test_gather_host gtest)

add_test(
NAME gather
Expand All @@ -86,6 +91,7 @@ add_test(


smi_target(test_mixed "${CMAKE_CURRENT_SOURCE_DIR}/mixed/mixed.json" "${CMAKE_CURRENT_SOURCE_DIR}/mixed/test_mixed.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/mixed/mixed.cl" 8)
target_link_libraries(test_mixed_host gtest)

add_test(
NAME mixed
Expand Down
35 changes: 18 additions & 17 deletions test/broadcast/test_broadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using namespace std;
std::string program_path;
int rank_count, my_rank;

hlslib::ocl::Context *context; //global context
SMI_Comm comm;
//https://github.com/google/googletest/issues/348#issuecomment-492785854
#define ASSERT_DURATION_LE(secs, stmt) { \
Expand Down Expand Up @@ -63,8 +63,8 @@ TEST(Broadcast, MPIinit)
TEST(Broadcast, CharMessages)
{
//with this test we evaluate the correctness of char messages transmission
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_char");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_char");
std::vector<int> message_lengths={1,128,1024,1000};
std::vector<int> roots={0,4,5};
int runs=2;
Expand Down Expand Up @@ -99,8 +99,8 @@ TEST(Broadcast, CharMessages)
TEST(Broadcast, ShortMessages)
{
//with this test we evaluate the correctness of integer messages transmission
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_short");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_short");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -137,8 +137,8 @@ TEST(Broadcast, IntegerMessages)
{
//with this test we evaluate the correctness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_int");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_int");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -175,8 +175,8 @@ TEST(Broadcast, FloatMessages)
{
//with this test we evaluate the correctness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_float");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_float");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -213,8 +213,8 @@ TEST(Broadcast, DoubleMessages)
{
//with this test we evaluate the correctness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_double");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_double");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -252,8 +252,8 @@ TEST(Broadcast, IntegerMessagesAD)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_int_ad");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_int_ad");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -290,8 +290,8 @@ TEST(Broadcast, FloatMessagesAD)
{
//with this test we evaluate the correctness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_float_ad");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_float_ad");

std::vector<int> message_lengths={1,128,1024,10000};
std::vector<int> roots={0,4,7};
Expand Down Expand Up @@ -350,9 +350,10 @@ int main(int argc, char *argv[])
//create environemnt
int fpga=my_rank%2;
program_path = replace(program_path, "<rank>", std::to_string(my_rank));
auto program = hlslib::ocl::GlobalContext().MakeProgram(program_path);
context = new hlslib::ocl::Context();
auto program = context->MakeProgram(program_path);
std::vector<hlslib::ocl::Buffer<char, hlslib::ocl::Access::read>> buffers;
comm=SmiInit_broadcast(my_rank, rank_count, ROUTING_DIR, hlslib::ocl::GlobalContext(), program, buffers);
comm=SmiInit_broadcast(my_rank, rank_count, ROUTING_DIR, *context, program, buffers);
result = RUN_ALL_TESTS();
MPI_Finalize();

Expand Down
22 changes: 12 additions & 10 deletions test/gather/test_gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using namespace std;
std::string program_path;
int rank_count, my_rank;
hlslib::ocl::Context *context; //global context

SMI_Comm comm;

Expand Down Expand Up @@ -72,8 +73,8 @@ TEST(Gather, CharMessages)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_char");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_char");

std::vector<int> message_lengths={1,16,128};
std::vector<int> roots={0,1,3};
Expand Down Expand Up @@ -113,8 +114,8 @@ TEST(Gather, ShortMessages)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_short");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_short");

std::vector<int> message_lengths={1,16,128};
std::vector<int> roots={0,1,3};
Expand Down Expand Up @@ -153,8 +154,8 @@ TEST(Gather, IntegerMessages)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_int");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_int");

std::vector<int> message_lengths={1,16,128};
std::vector<int> roots={0,1,3};
Expand Down Expand Up @@ -194,8 +195,8 @@ TEST(Gather, FloatMessages)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_float");
hlslib::ocl::Buffer<char, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<char, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_float");

std::vector<int> message_lengths={1,16,128};
std::vector<int> roots={0,1,3};
Expand Down Expand Up @@ -256,9 +257,10 @@ int main(int argc, char *argv[])
program_path = replace(program_path, "<rank>", std::to_string(my_rank));

program_path = replace(program_path, "<rank>", std::to_string(my_rank));
auto program = hlslib::ocl::GlobalContext().MakeProgram(program_path);
context = new hlslib::ocl::Context();
auto program = context->MakeProgram(program_path);
std::vector<hlslib::ocl::Buffer<char, hlslib::ocl::Access::read>> buffers;
comm=SmiInit_gather(my_rank, rank_count, ROUTING_DIR, hlslib::ocl::GlobalContext(), program, buffers);
comm=SmiInit_gather(my_rank, rank_count, ROUTING_DIR, *context, program, buffers);


result = RUN_ALL_TESTS();
Expand Down
10 changes: 6 additions & 4 deletions test/mixed/test_mixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using namespace std;
std::string program_path;
int rank_count, my_rank;
hlslib::ocl::Context *context;

SMI_Comm comm;
//https://github.com/google/googletest/issues/348#issuecomment-492785854
Expand Down Expand Up @@ -70,8 +71,8 @@ TEST(Gather, IntegerMessages)
{
//with this test we evaluate the correcteness of integer messages transmission

hlslib::ocl::Buffer<int, hlslib::ocl::Access::readWrite> check = hlslib::ocl::GlobalContext().MakeBuffer<int, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = hlslib::ocl::GlobalContext().CurrentlyLoadedProgram().MakeKernel("test_int");
hlslib::ocl::Buffer<int, hlslib::ocl::Access::readWrite> check = context->MakeBuffer<int, hlslib::ocl::Access::readWrite>(1);
hlslib::ocl::Kernel kernel = context->CurrentlyLoadedProgram().MakeKernel("test_int");


std::vector<int> starts={1,100,300};
Expand Down Expand Up @@ -125,9 +126,10 @@ int main(int argc, char *argv[])
//create environemnt
int fpga=my_rank%2;
program_path = replace(program_path, "<rank>", std::to_string(my_rank));
auto program = hlslib::ocl::GlobalContext().MakeProgram(program_path);
context = new hlslib::ocl::Context();
auto program = context->MakeProgram(program_path);
std::vector<hlslib::ocl::Buffer<char, hlslib::ocl::Access::read>> buffers;
comm=SmiInit_mixed(my_rank, rank_count, ROUTING_DIR, hlslib::ocl::GlobalContext(), program, buffers);
comm=SmiInit_mixed(my_rank, rank_count, ROUTING_DIR, *context, program, buffers);


result = RUN_ALL_TESTS();
Expand Down
Loading

0 comments on commit ef17c39

Please sign in to comment.