Browse Source

modify test to be just copy

master
Constantin Fürst 1 year ago
parent
commit
dca38de0f3
  1. BIN
      test-project/binaries/dml-test
  2. 31
      test-project/main.cpp

BIN
test-project/binaries/dml-test

31
test-project/main.cpp

@ -1,30 +1,29 @@
#include <dml/dml.hpp> #include <dml/dml.hpp>
#include <iostream>
#include <string>
#include <numeric>
#include <vector> #include <vector>
#include <iostream>
constexpr auto string = "Calculate CRC value for this string...\n";
constexpr auto size = 1024u;
template <typename path> template <typename path>
int execute_copy_crc(){
std::cout << "Starting dml::copy_crc example...\n";
std::cout << string;
int execute_mem_move() {
std::cout << "Starting dml::mem_move example..." << std::endl;
std::cout << "Copy 1KB of data from source into destination..." << std::endl;
// Prepare data // Prepare data
auto crc_seed = std::uint32_t(0u);
auto src = std::basic_string<std::uint8_t>(reinterpret_cast<const std::uint8_t *>(string));
auto dst = std::basic_string<std::uint8_t>(src.size(), '0');
auto src = std::vector<std::uint8_t>(size);
std::iota(src.begin(), src.end(), 0u);
auto dst = std::vector<std::uint8_t>(size, 0u);
// Run operation // Run operation
auto result = dml::execute<path>(dml::copy_crc, dml::make_view(src), dml::make_view(dst), crc_seed);
auto result = dml::execute<path>(dml::mem_move, dml::make_view(src), dml::make_view(dst));
// Check result // Check result
if (result.status == dml::status_code::ok) { if (result.status == dml::status_code::ok) {
std::cout << "Finished successfully. Calculated CRC is: 0x" << std::hex << result.crc_value << std::dec << std::endl;
std::cout << "Finished successfully." << std::endl;
} }
else { else {
std::cout << "Failure #" << static_cast<uint32_t>(result.status) << " occurred." << std::endl;
std::cout << "Failure occurred." << std::endl;
return -1; return -1;
} }
@ -47,15 +46,15 @@ int main(int argc, char **argv)
std::string path = argv[1]; std::string path = argv[1];
if (path == "hardware_path") { if (path == "hardware_path") {
std::cout << "Executing using dml::hardware path" << std::endl; std::cout << "Executing using dml::hardware path" << std::endl;
return execute_copy_crc<dml::hardware>();
return execute_mem_move<dml::hardware>();
} }
else if (path == "software_path") { else if (path == "software_path") {
std::cout << "Executing using dml::software path" << std::endl; std::cout << "Executing using dml::software path" << std::endl;
return execute_copy_crc<dml::software>();
return execute_mem_move<dml::software>();
} }
else if (path == "auto_path") { else if (path == "auto_path") {
std::cout << "Executing using dml::automatic path" << std::endl; std::cout << "Executing using dml::automatic path" << std::endl;
return execute_copy_crc<dml::automatic>();
return execute_mem_move<dml::automatic>();
} }
else { else {
std::cout << "Unrecognized value for parameter." std::cout << "Unrecognized value for parameter."

Loading…
Cancel
Save