diff --git a/test/host/hls/test.cpp b/test/host/hls/test.cpp index 12b2e35a..1da8bb48 100644 --- a/test/host/hls/test.cpp +++ b/test/host/hls/test.cpp @@ -143,52 +143,6 @@ std::unique_ptr test_vadd_put(options_t options) { return accl; } -void test_copy(ACCL::ACCL& accl, options_t options) { - //run test here: - //initialize a CCLO BFM and streams as needed - hlslib::Stream callreq, callack; - hlslib::Stream data_cclo2krnl("cclo2krnl"), data_krnl2cclo("krnl2cclo"); - - std::vector dest = {0}; - std::unique_ptr cclo; - - if (!options.hardware) { - cclo = std::make_unique(options.start_port, rank, size, dest, callreq, callack, data_cclo2krnl, data_krnl2cclo); - cclo->run(); - std::cout << "CCLO BFM started" << std::endl; - } - MPI_Barrier(MPI_COMM_WORLD); - - //allocate float arrays for the HLS function to use - auto src_buffer = accl.create_buffer(options.count, ACCL::dataType::int32, 0); - auto dst_buffer = accl.create_buffer(options.count, ACCL::dataType::int32, 0); - for(int i=0; ibuffer()[i] = rank; - dst_buffer->buffer()[i] = 0; - } - - accl.copy_to_stream(*src_buffer, options.count, false); - - //loop back data (divide count by 16 and round up to get number of stream words) - for (int i=0; i < (options.count+15)/16; i++) { - data_krnl2cclo.write(data_cclo2krnl.read()); - } - - accl.copy_from_stream(*dst_buffer, options.count, false); - - //check HLS function outputs - unsigned int err_count = 0; - for(int i=0; ibuffer()[i] != rank); - } - - std::cout << "Test finished with " << err_count << " errors" << std::endl; - if (!options.hardware) { - //clean up - cclo->stop(); - } -} - void test_loopback_local_res(ACCL::ACCL& accl, options_t options) { //run test here: @@ -344,8 +298,6 @@ int main(int argc, char *argv[]) { auto accl = test_vadd_put(options); MPI_Barrier(MPI_COMM_WORLD); - test_copy(*accl, options); - MPI_Barrier(MPI_COMM_WORLD); if(!options.hardware){ std::srand(42); for(int i=0; i(count, dataType::float32); + auto res_buf = accl.create_buffer(count, dataType::float32); + random_array(op_buf->buffer(), count); + + test_debug("Copy data from buffer to stream", options); + accl.copy_to_stream(*op_buf, count, false); + test_debug("Copy data from stream to buffer", options); + accl.copy_from_stream(*res_buf, count, false); + int errors = 0; + for (unsigned int i = 0; i < count; ++i) { + float ref = (*op_buf)[i]; + float res = (*res_buf)[i]; + if (res != ref) { + std::cout << i + 1 + << "th item is incorrect! (" + std::to_string(res) + + " != " + std::to_string(ref) + ")" + << std::endl; + errors += 1; + } + } + + if (errors > 0) { + std::cout << errors << " errors!" << std::endl; + } else { + std::cout << "Test succesfull!" << std::endl; + } +} + void test_copy_p2p(ACCL::ACCL &accl, options_t &options) { std::cout << "Start copy p2p test..." << std::endl; unsigned int count = options.count; @@ -1304,7 +1335,7 @@ int start_test(options_t options) { auto cclo_ip = xrt::ip(device, xclbin_uuid, "ccl_offload:{ccl_offload_" + cclo_id + "}"); auto hostctrl_ip = xrt::kernel(device, xclbin_uuid, - "hostctrl:{hostctrl_" + cclo_id + "_0}", + "hostctrl:{hostctrl_" + cclo_id + "}", xrt::kernel::cu_access_mode::exclusive); int devicemem; @@ -1350,6 +1381,8 @@ int start_test(options_t options) { MPI_Barrier(MPI_COMM_WORLD); test_copy(*accl, options); MPI_Barrier(MPI_COMM_WORLD); + test_copy_stream(*accl, options); + MPI_Barrier(MPI_COMM_WORLD); test_copy_p2p(*accl, options); MPI_Barrier(MPI_COMM_WORLD); test_combine_sum(*accl, options);