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.

63 lines
1.9 KiB

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