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.

66 lines
1.9 KiB

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