list_devices.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #include <iostream>
  11. #include <boost/compute/core.hpp>
  12. namespace compute = boost::compute;
  13. int main()
  14. {
  15. std::vector<compute::platform> platforms = compute::system::platforms();
  16. for(size_t i = 0; i < platforms.size(); i++){
  17. const compute::platform &platform = platforms[i];
  18. std::cout << "Platform '" << platform.name() << "'" << std::endl;
  19. std::vector<compute::device> devices = platform.devices();
  20. for(size_t j = 0; j < devices.size(); j++){
  21. const compute::device &device = devices[j];
  22. std::string type;
  23. if(device.type() & compute::device::gpu)
  24. type = "GPU Device";
  25. else if(device.type() & compute::device::cpu)
  26. type = "CPU Device";
  27. else if(device.type() & compute::device::accelerator)
  28. type = "Accelerator Device";
  29. else
  30. type = "Unknown Device";
  31. std::cout << " " << type << ": " << device.name() << std::endl;
  32. }
  33. }
  34. return 0;
  35. }