• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 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 
11 #define BOOST_TEST_MODULE TestPlatform
12 #include <boost/test/unit_test.hpp>
13 
14 #include <iostream>
15 
16 #include <boost/compute/platform.hpp>
17 #include <boost/compute/system.hpp>
18 
BOOST_AUTO_TEST_CASE(platform_id)19 BOOST_AUTO_TEST_CASE(platform_id)
20 {
21     boost::compute::platform platform =
22         boost::compute::system::platforms().front();
23 
24     boost::compute::platform platform_copy(platform.id());
25 
26     BOOST_CHECK(platform == platform_copy);
27     BOOST_CHECK(platform.id() == platform_copy.id());
28 }
29 
BOOST_AUTO_TEST_CASE(platform_supports_extension)30 BOOST_AUTO_TEST_CASE(platform_supports_extension)
31 {
32     boost::compute::platform platform =
33         boost::compute::system::platforms().front();
34 
35     std::string extensions = platform.get_info<CL_PLATFORM_EXTENSIONS>();
36     if(extensions.empty()){
37         std::cerr << "platform doesn't support any extensions" << std::endl;
38         return;
39     }
40 
41     size_t space = extensions.find(' ');
42     std::string first_extension = extensions.substr(0, space);
43     BOOST_CHECK(platform.supports_extension(first_extension) == true);
44     BOOST_CHECK(platform.supports_extension("invalid_extension_name") == false);
45 }
46