diff --git a/test-project/CMakeLists.txt b/test-project/CMakeLists.txt new file mode 100755 index 0000000..fa76768 --- /dev/null +++ b/test-project/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.18) + +project(dml-test) + +set(CMAKE_CXX_STANDARD 20) + +include_directories("../DML/include/") + +set(SOURCES main.cpp) + +add_executable(dml-test ${SOURCES}) + +target_link_libraries(dml-test libdml.a ${CMAKE_DL_LIBS}) diff --git a/test-project/dml-test b/test-project/dml-test new file mode 100755 index 0000000..e477bfd Binary files /dev/null and b/test-project/dml-test differ diff --git a/test-project/main.cpp b/test-project/main.cpp new file mode 100644 index 0000000..0f02654 --- /dev/null +++ b/test-project/main.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +constexpr auto string = "Calculate CRC value for this string...\n"; + +template + + +template +int execute_copy_crc(){ + std::cout << "Starting dml::copy_crc example...\n"; + std::cout << string; + + // Prepare data + auto crc_seed = std::uint32_t(0u); + auto src = std::basic_string(reinterpret_cast(string)); + auto dst = std::basic_string(src.size(), '0'); + + // Run operation + auto result = dml::execute(dml::copy_crc, dml::make_view(src), dml::make_view(dst), crc_seed); + dml::submit() + + // Check result + if (result.status == dml::status_code::ok) { + std::cout << "Finished successfully. Calculated CRC is: 0x" << std::hex << result.crc_value << std::dec << std::endl; + } + else { + std::cout << "Failure occurred." << std::endl; + return -1; + } + + if (src != dst) { + std::cout << "Operation result is incorrect" << std::endl; + return -1; + } + + return 0; +} + +int main(int argc, char **argv) +{ + if (argc < 2) { + std::cout << "Missing the execution path as the first parameter." + << "Use hardware_path, software_path or automatic_path." << std::endl; + return 1; + } + + std::string path = argv[1]; + if (path == "hardware_path") { + std::cout << "Executing using dml::hardware path" << std::endl; + return execute_copy_crc(); + } + else if (path == "software_path") { + std::cout << "Executing using dml::software path" << std::endl; + return execute_copy_crc(); + } + else if (path == "auto_path") { + std::cout << "Executing using dml::automatic path" << std::endl; + return execute_copy_crc(); + } + else { + std::cout << "Unrecognized value for parameter." + << "Use hardware_path, software_path or automatic_path." << std::endl; + return 1; + } +} \ No newline at end of file