This contains my bachelors thesis and associated tex files, code snippets and maybe more. Topic: Data Movement in Heterogeneous Memories with Intel Data Streaming Accelerator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.0 KiB

  1. #include <dml/dml.hpp>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. constexpr auto string = "Calculate CRC value for this string...\n";
  6. template <typename path>
  7. template <typename path>
  8. int execute_copy_crc(){
  9. std::cout << "Starting dml::copy_crc example...\n";
  10. std::cout << string;
  11. // Prepare data
  12. auto crc_seed = std::uint32_t(0u);
  13. auto src = std::basic_string<std::uint8_t>(reinterpret_cast<const std::uint8_t *>(string));
  14. auto dst = std::basic_string<std::uint8_t>(src.size(), '0');
  15. // Run operation
  16. auto result = dml::execute<path>(dml::copy_crc, dml::make_view(src), dml::make_view(dst), crc_seed);
  17. dml::submit<path>()
  18. // Check result
  19. if (result.status == dml::status_code::ok) {
  20. std::cout << "Finished successfully. Calculated CRC is: 0x" << std::hex << result.crc_value << std::dec << std::endl;
  21. }
  22. else {
  23. std::cout << "Failure occurred." << std::endl;
  24. return -1;
  25. }
  26. if (src != dst) {
  27. std::cout << "Operation result is incorrect" << std::endl;
  28. return -1;
  29. }
  30. return 0;
  31. }
  32. int main(int argc, char **argv)
  33. {
  34. if (argc < 2) {
  35. std::cout << "Missing the execution path as the first parameter."
  36. << "Use hardware_path, software_path or automatic_path." << std::endl;
  37. return 1;
  38. }
  39. std::string path = argv[1];
  40. if (path == "hardware_path") {
  41. std::cout << "Executing using dml::hardware path" << std::endl;
  42. return execute_copy_crc<dml::hardware>();
  43. }
  44. else if (path == "software_path") {
  45. std::cout << "Executing using dml::software path" << std::endl;
  46. return execute_copy_crc<dml::software>();
  47. }
  48. else if (path == "auto_path") {
  49. std::cout << "Executing using dml::automatic path" << std::endl;
  50. return execute_copy_crc<dml::automatic>();
  51. }
  52. else {
  53. std::cout << "Unrecognized value for parameter."
  54. << "Use hardware_path, software_path or automatic_path." << std::endl;
  55. return 1;
  56. }
  57. }