<commit_before>#ifndef VIENNAGRID_STORAGE_HOOK_HPP
#define VIENNAGRID_STORAGE_HOOK_HPP

#include <iterator>
#include <vector>
#include <map>
#include "viennagrid/meta/typemap.hpp"
#include "viennagrid/storage/forwards.hpp"

namespace viennagrid
{
    namespace storage
    {

        namespace hook
        {
            template<typename base_container_type, typename view_reference_tag>
            struct hook_type
            {};

            template<typename base_container_type>
            struct hook_type<base_container_type, no_hook_tag>
            {
                typedef viennameta::null_type type;
            };

            template<typename base_container_type>
            struct hook_type<base_container_type, pointer_hook_tag>
            {
                typedef typename base_container_type::pointer type;
            };

            template<typename base_container_type>
            struct hook_type<base_container_type, iterator_hook_tag>
            {
                typedef typename base_container_type::iterator type;
            };

            template<typename base_container_type, typename id_type>
            struct hook_type<base_container_type, id_hook_tag<id_type> >
            {
                typedef id_type type;
            };

            template<typename base_container_type, typename view_reference_tag>
            struct const_hook_type
            {};

            template<typename base_container_type>
            struct const_hook_type<base_container_type, no_hook_tag>
            {
                typedef const viennameta::null_type type;
            };

            template<typename base_container_type>
            struct const_hook_type<base_container_type, pointer_hook_tag>
            {
                typedef typename base_container_type::const_pointer type;
            };

            template<typename base_container_type>
            struct const_hook_type<base_container_type, iterator_hook_tag>
            {
                typedef typename base_container_type::const_iterator type;
            };

            template<typename base_container_type, typename id_type>
            struct const_hook_type<base_container_type, id_hook_tag<id_type> >
            {
                typedef const id_type type;
            };

            template<typename container_type, typename hook_tag>
            struct iterator_to_hook;

            template<typename container_type>
            struct iterator_to_hook<container_type, no_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, no_hook_tag>::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return hook_type(); }
            };

            template<typename container_type>
            struct iterator_to_hook<container_type, iterator_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, iterator_hook_tag>::type hook_type;

                static hook_type convert( hook_type it ) { return it; }
            };

            template<typename container_type>
            struct iterator_to_hook<container_type, pointer_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, pointer_hook_tag>::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return &* it; }
            };

            template<typename container_type, typename id_type>
            struct iterator_to_hook<container_type, id_hook_tag<id_type> >
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, id_hook_tag<id_type> >::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return it->id(); }
            };

//             template<typename reference_type>
//             struct value_type_from_reference_type;
//
//             template<typename value_type>
//             struct value_type_from_reference_type< value_type * >
//             {
//                 typedef value_type type;
//             };
//
//             template<typename category, typename value_type, typename distance, typename pointer, typename reference>
//             struct value_type_from_reference_type< std::iterator<category, value_type, distance, pointer, reference> >
//             {
//                 typedef value_type type;
//             };

//             template<typename value_type, typename reference_tag_config>
//             struct reference_tag_from_config
//             {
//                 typedef typename viennameta::typemap::result_of::find<reference_tag_config, value_type>::type search_result;
//                 typedef typename viennameta::typemap::result_of::find<reference_tag_config, viennagrid::storage::default_tag>::type default_reference_tag;
//
//                 typedef typename viennameta::_if<
//                     !viennameta::_equal<search_result, viennameta::not_found>::value,
//                     search_result,
//                     default_reference_tag
//                 >::type::second type;
//             };
//
//             template<typename container_type, typename reference_tag_config>
//             struct reference_type_from_config
//             {
//                 typedef typename reference_type<
//                     container_type,
//                     typename reference_tag_from_config<typename container_type::iterator, reference_tag_config>::type
//                 >::type type;
//             };

//             template<typename iterator_type>
//             typename iterator_type::value_type * iterator_to_reference(iterator_type it, pointer_reference_tag)
//             { return &* it; }
//
//             template<typename iterator_type>
//             iterator_type iterator_to_reference(iterator_type it, iterator_reference_tag)
//             { return it; }
//
//             template<typename iterator_type>
//             typename iterator_type::value_type::id_type iterator_to_reference(iterator_type it, id_reference_tag)
//             { return it->id(); }

//             template<typename dst_reference_type>
//             struct reference_converter
//             {
//                 static dst_reference_type convert( dst_reference_type ref )
//                 {
//                     return ref;
//                 }
//             };
//
//             template<typename value_type>
//             struct reference_converter<value_type *>
//             {
//                 template<typename iterator_type>
//                 static value_type * convert( iterator_type it )
//                 {
//                     typedef typename iterator_type::iterator_category tmp;
//                     return &* it;
//                 }
//             };

        }
    }
}

#endif<commit_msg>adapted to id_hook_type without id_type<commit_after>#ifndef VIENNAGRID_STORAGE_HOOK_HPP
#define VIENNAGRID_STORAGE_HOOK_HPP

#include <iterator>
#include <vector>
#include <map>
#include "viennagrid/meta/typemap.hpp"
#include "viennagrid/storage/id.hpp"
#include "viennagrid/storage/forwards.hpp"

namespace viennagrid
{
    namespace storage
    {

        namespace hook
        {

            template<typename base_container_type, typename view_reference_tag>
            struct hook_type
            {};

            template<typename base_container_type>
            struct hook_type<base_container_type, no_hook_tag>
            {
                typedef viennameta::null_type type;
            };

            template<typename base_container_type>
            struct hook_type<base_container_type, pointer_hook_tag>
            {
                typedef typename base_container_type::pointer type;
            };

            template<typename base_container_type>
            struct hook_type<base_container_type, iterator_hook_tag>
            {
                typedef typename base_container_type::iterator type;
            };

            template<typename base_container_type>
            struct hook_type<base_container_type, id_hook_tag>
            {
                typedef typename base_container_type::value_type::id_type type;
            };

            template<typename base_container_type, typename view_reference_tag>
            struct const_hook_type
            {};

            template<typename base_container_type>
            struct const_hook_type<base_container_type, no_hook_tag>
            {
                typedef const viennameta::null_type type;
            };

            template<typename base_container_type>
            struct const_hook_type<base_container_type, pointer_hook_tag>
            {
                typedef typename base_container_type::const_pointer type;
            };

            template<typename base_container_type>
            struct const_hook_type<base_container_type, iterator_hook_tag>
            {
                typedef typename base_container_type::const_iterator type;
            };

            template<typename base_container_type>
            struct const_hook_type<base_container_type, id_hook_tag>
            {
                typedef const typename base_container_type::value_type::id_type type;
            };

            template<typename container_type, typename hook_tag>
            struct iterator_to_hook;

            template<typename container_type>
            struct iterator_to_hook<container_type, no_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, no_hook_tag>::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return hook_type(); }
            };

            template<typename container_type>
            struct iterator_to_hook<container_type, iterator_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, iterator_hook_tag>::type hook_type;

                static hook_type convert( hook_type it ) { return it; }
            };

            template<typename container_type>
            struct iterator_to_hook<container_type, pointer_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, pointer_hook_tag>::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return &* it; }
            };

            template<typename container_type>
            struct iterator_to_hook<container_type, id_hook_tag>
            {
                typedef typename viennagrid::storage::hook::hook_type<container_type, id_hook_tag>::type hook_type;

                template<typename iterator>
                static hook_type convert( iterator it ) { return it->id(); }
            };

//             template<typename reference_type>
//             struct value_type_from_reference_type;
//
//             template<typename value_type>
//             struct value_type_from_reference_type< value_type * >
//             {
//                 typedef value_type type;
//             };
//
//             template<typename category, typename value_type, typename distance, typename pointer, typename reference>
//             struct value_type_from_reference_type< std::iterator<category, value_type, distance, pointer, reference> >
//             {
//                 typedef value_type type;
//             };

//             template<typename value_type, typename reference_tag_config>
//             struct reference_tag_from_config
//             {
//                 typedef typename viennameta::typemap::result_of::find<reference_tag_config, value_type>::type search_result;
//                 typedef typename viennameta::typemap::result_of::find<reference_tag_config, viennagrid::storage::default_tag>::type default_reference_tag;
//
//                 typedef typename viennameta::_if<
//                     !viennameta::_equal<search_result, viennameta::not_found>::value,
//                     search_result,
//                     default_reference_tag
//                 >::type::second type;
//             };
//
//             template<typename container_type, typename reference_tag_config>
//             struct reference_type_from_config
//             {
//                 typedef typename reference_type<
//                     container_type,
//                     typename reference_tag_from_config<typename container_type::iterator, reference_tag_config>::type
//                 >::type type;
//             };

//             template<typename iterator_type>
//             typename iterator_type::value_type * iterator_to_reference(iterator_type it, pointer_reference_tag)
//             { return &* it; }
//
//             template<typename iterator_type>
//             iterator_type iterator_to_reference(iterator_type it, iterator_reference_tag)
//             { return it; }
//
//             template<typename iterator_type>
//             typename iterator_type::value_type::id_type iterator_to_reference(iterator_type it, id_reference_tag)
//             { return it->id(); }

//             template<typename dst_reference_type>
//             struct reference_converter
//             {
//                 static dst_reference_type convert( dst_reference_type ref )
//                 {
//                     return ref;
//                 }
//             };
//
//             template<typename value_type>
//             struct reference_converter<value_type *>
//             {
//                 template<typename iterator_type>
//                 static value_type * convert( iterator_type it )
//                 {
//                     typedef typename iterator_type::iterator_category tmp;
//                     return &* it;
//                 }
//             };

        }
    }
}

#endif<|endoftext|>


<commit_before>/*
 *
 * Copyright (C) 2015 Jason Gowan
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 */

#include <gtest/gtest.h>
#include "simple_constraint_handler.h"
#include <vector>

TEST(SimpleConstraintHandlerTest, canCreate) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  std::vector<dither::dval> tmp;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);
  dither::SimpleConstraintHandler handler(arr, constraints);
}

TEST(SimpleConstraintHandlerTest, canTestCaseViolateConstraint) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  std::vector<dither::dval> test_case;
  test_case.push_back(0);
  test_case.push_back(-1);
  test_case.push_back(-1);
  test_case.push_back(-1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  test_case[1] = 0;
  test_case[2] = 0;
  ASSERT_TRUE(handler.violate_constraints(test_case));
  test_case[1] = 1;
  test_case[3] = 0;
  ASSERT_FALSE(handler.violate_constraints(test_case));
}

TEST(SimpleConstraintHandlerTest, canParamsViolateConstraint) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  std::vector<dither::param> test_case;
  dither::param param1;
  param1.first = 0;
  param1.second = 0;
  test_case.push_back(param1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  dither::param param2;
  param2.first = 1;
  param2.second = 0;
  test_case.push_back(param2);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  dither::param param3;
  param3.first = 2;
  param3.second = 0;
  test_case.push_back(param3);
  ASSERT_TRUE(handler.violate_constraints(test_case));
}

TEST(SimpleConstraintHandlerTest, canGroundTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  dither::dval constraint3[] = {0, -1, -1, 0};
  dither::dval constraint4[] = {1, -1, -1, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  std::vector<dither::dval> tmp3;
  std::vector<dither::dval> tmp4;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
    tmp3.push_back(constraint3[i]);
    tmp4.push_back(constraint4[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  constraints.push_back(tmp3);
  constraints.push_back(tmp4);
  std::vector<dither::dval> test_case;
  test_case.push_back(0);
  test_case.push_back(-1);
  test_case.push_back(-1);
  test_case.push_back(-1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_TRUE(handler.ground(test_case));
  std::vector<dither::dval> test_case2;
  test_case2.push_back(0);
  test_case2.push_back(0);
  test_case2.push_back(0);
  test_case2.push_back(-1);
  ASSERT_FALSE(handler.ground(test_case2));
  std::vector<dither::dval> test_case3;
  test_case3.push_back(0);
  test_case3.push_back(-1);
  test_case3.push_back(0);
  test_case3.push_back(-1);
  // constraint solver should be able to unwind
  ASSERT_TRUE(handler.ground(test_case3));
}

TEST(GecodeCompatibilityConstraintTest, canValidateGecodeConstraintOnTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  int constraint[] = {-1, 0, 0, -1};
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);

  dither::SimpleConstraintHandler handler(arr, constraints);
  dither::dtest_case dcase(4, -1);
  dcase[0] = 0;
  ASSERT_FALSE(handler.violate_constraints(dcase));
  // test specific to gecode edge case
  /* dcase[1] = 20; */
  /* ASSERT_TRUE(handler.violate_constraints(dcase)); */
  dcase[1] = 0;
  dcase[2] = 0;
  ASSERT_TRUE(handler.violate_constraints(dcase));

}

TEST(GecodeCompatibilityConstraintTest, canValidateGecodeConstraintOnParams) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  int constraint[] = {-1, 0, 0, -1};
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);

  dither::SimpleConstraintHandler handler(arr, constraints);
  std::vector<dither::param> params;
  dither::param my_param;
  my_param.first = 0;
  my_param.second = 1;
  params.push_back(my_param);
  dither::dtest_case dcase(4, -1);
  dcase[0] = 0;
  ASSERT_FALSE(handler.violate_constraints(params));

  // test specific to gecode edge case
  /* params.clear(); */
  /* my_param.second = 20; */
  /* params.push_back(my_param); */
  /* ASSERT_TRUE(handler.violate_constraints(params)); */

  params.clear();
  my_param.first = 1;
  my_param.second = 0;
  params.push_back(my_param);
  my_param.first = 2;
  my_param.second = 0;
  params.push_back(my_param);
  ASSERT_TRUE(handler.violate_constraints(params));
}

TEST(GecodeCompatibilityConstraintTest, canGroundSimpleConstraintOnTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  std::vector<dither::dval> tmp3;
  std::vector<dither::dval> tmp4;
  int constraint[] = {-1, 0, 0, -1};
  int constraint2[] = {-1, 0, -1, -1};
  int constraint3[] = {-1, -1, 0, 0};
  int constraint4[] = {-1, -1, 0, 1};
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
    tmp3.push_back(constraint3[i]);
    tmp4.push_back(constraint4[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  constraints.push_back(tmp3);
  constraints.push_back(tmp4);

  dither::SimpleConstraintHandler handler(arr, constraints);
  dither::dtest_case dcase(4, -1);
  dcase[0] = 0;
  ASSERT_TRUE(handler.ground(dcase));
  ASSERT_EQ(dcase[1], 1);
  ASSERT_EQ(dcase[0], 0);

  // test specific to gecode edge case
  /* std::fill(dcase.begin(), dcase.end(), -1); */
  /* dcase[1] = 20; */
  /* ASSERT_FALSE(handler.ground(dcase)); */

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[1] = 0;
  dcase[2] = 0;
  ASSERT_FALSE(handler.ground(dcase));

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[2] = 0;
  dcase[3] = 0;
  ASSERT_FALSE(handler.ground(dcase));
}
<commit_msg>create failing test case<commit_after>/*
 *
 * Copyright (C) 2015 Jason Gowan
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 */

#include <gtest/gtest.h>
#include "simple_constraint_handler.h"
#include <vector>

TEST(SimpleConstraintHandlerTest, canCreate) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  std::vector<dither::dval> tmp;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);
  dither::SimpleConstraintHandler handler(arr, constraints);
}

TEST(SimpleConstraintHandlerTest, canTestCaseViolateConstraint) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  std::vector<dither::dval> test_case;
  test_case.push_back(0);
  test_case.push_back(-1);
  test_case.push_back(-1);
  test_case.push_back(-1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  test_case[1] = 0;
  test_case[2] = 0;
  ASSERT_TRUE(handler.violate_constraints(test_case));
  test_case[1] = 1;
  test_case[3] = 0;
  ASSERT_FALSE(handler.violate_constraints(test_case));
}

TEST(SimpleConstraintHandlerTest, canParamsViolateConstraint) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  std::vector<dither::param> test_case;
  dither::param param1;
  param1.first = 0;
  param1.second = 0;
  test_case.push_back(param1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  dither::param param2;
  param2.first = 1;
  param2.second = 0;
  test_case.push_back(param2);
  ASSERT_FALSE(handler.violate_constraints(test_case));
  dither::param param3;
  param3.first = 2;
  param3.second = 0;
  test_case.push_back(param3);
  ASSERT_TRUE(handler.violate_constraints(test_case));
}

TEST(SimpleConstraintHandlerTest, canGroundTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  dither::dval constraint[] = {-1, 0, 0, -1};
  dither::dval constraint2[] = {-1, 0, 0, 0};
  dither::dval constraint3[] = {0, -1, -1, 0};
  dither::dval constraint4[] = {1, -1, -1, 0};
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  std::vector<dither::dval> tmp3;
  std::vector<dither::dval> tmp4;
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
    tmp3.push_back(constraint3[i]);
    tmp4.push_back(constraint4[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  constraints.push_back(tmp3);
  constraints.push_back(tmp4);
  std::vector<dither::dval> test_case;
  test_case.push_back(0);
  test_case.push_back(-1);
  test_case.push_back(-1);
  test_case.push_back(-1);
  dither::SimpleConstraintHandler handler(arr, constraints);
  ASSERT_TRUE(handler.ground(test_case));
  std::vector<dither::dval> test_case2;
  test_case2.push_back(0);
  test_case2.push_back(0);
  test_case2.push_back(0);
  test_case2.push_back(-1);
  ASSERT_FALSE(handler.ground(test_case2));
  std::vector<dither::dval> test_case3;
  test_case3.push_back(0);
  test_case3.push_back(-1);
  test_case3.push_back(0);
  test_case3.push_back(-1);
  // constraint solver should be able to unwind
  ASSERT_TRUE(handler.ground(test_case3));
}

TEST(GecodeCompatibilityConstraintTest, canValidateGecodeConstraintOnTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  int constraint[] = {-1, 0, 0, -1};
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);

  dither::SimpleConstraintHandler handler(arr, constraints);
  dither::dtest_case dcase(4, -1);
  dcase[0] = 0;
  ASSERT_FALSE(handler.violate_constraints(dcase));
  // test specific to gecode edge case
  /* dcase[1] = 20; */
  /* ASSERT_TRUE(handler.violate_constraints(dcase)); */
  dcase[1] = 0;
  dcase[2] = 0;
  ASSERT_TRUE(handler.violate_constraints(dcase));

}

TEST(GecodeCompatibilityConstraintTest, canValidateGecodeConstraintOnParams) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(3);
  arr.push_back(4);
  arr.push_back(5);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  int constraint[] = {-1, 0, 0, -1};
  for(unsigned int i = 0; i < 4; i++) {
    tmp.push_back(constraint[i]);
  }
  constraints.push_back(tmp);

  dither::SimpleConstraintHandler handler(arr, constraints);
  std::vector<dither::param> params;
  dither::param my_param;
  my_param.first = 0;
  my_param.second = 1;
  params.push_back(my_param);
  dither::dtest_case dcase(4, -1);
  dcase[0] = 0;
  ASSERT_FALSE(handler.violate_constraints(params));

  // test specific to gecode edge case
  /* params.clear(); */
  /* my_param.second = 20; */
  /* params.push_back(my_param); */
  /* ASSERT_TRUE(handler.violate_constraints(params)); */

  params.clear();
  my_param.first = 1;
  my_param.second = 0;
  params.push_back(my_param);
  my_param.first = 2;
  my_param.second = 0;
  params.push_back(my_param);
  ASSERT_TRUE(handler.violate_constraints(params));
}

TEST(GecodeCompatibilityConstraintTest, canGroundSimpleConstraintOnTestCase) {
  std::vector<dither::dval> arr;
  arr.push_back(2);
  arr.push_back(2);
  arr.push_back(4);
  arr.push_back(5);
  arr.push_back(1);
  std::vector<std::vector<dither::dval>> constraints;
  std::vector<dither::dval> tmp;
  std::vector<dither::dval> tmp2;
  std::vector<dither::dval> tmp3;
  std::vector<dither::dval> tmp4;
  std::vector<dither::dval> tmp5;
  std::vector<dither::dval> tmp6;
  int constraint[] = {-1, 0, 0, -1, -1};
  int constraint2[] = {-1, 0, -1, -1, -1};
  int constraint3[] = {-1, -1, 0, 0, -1};
  int constraint4[] = {-1, -1, 0, 1, -1};
  int constraint5[] = {-1, -1, 0, -1, 0};
  int constraint6[] = {-1, -1, 0, -1, 1};
  for(unsigned int i = 0; i < 5; i++) {
    tmp.push_back(constraint[i]);
    tmp2.push_back(constraint2[i]);
    tmp3.push_back(constraint3[i]);
    tmp4.push_back(constraint4[i]);
    tmp5.push_back(constraint5[i]);
    tmp6.push_back(constraint6[i]);
  }
  constraints.push_back(tmp);
  constraints.push_back(tmp2);
  constraints.push_back(tmp3);
  constraints.push_back(tmp4);
  constraints.push_back(tmp5);
  constraints.push_back(tmp6);

  dither::SimpleConstraintHandler handler(arr, constraints);
  dither::dtest_case dcase(5, -1);
  dcase[0] = 0;
  ASSERT_TRUE(handler.ground(dcase));
  ASSERT_EQ(dcase[1], 1);
  ASSERT_EQ(dcase[0], 0);

  // test specific to gecode edge case
  /* std::fill(dcase.begin(), dcase.end(), -1); */
  /* dcase[1] = 20; */
  /* ASSERT_FALSE(handler.ground(dcase)); */

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[1] = 0;
  dcase[2] = 0;
  ASSERT_FALSE(handler.ground(dcase));

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[2] = 0;
  dcase[3] = 0;
  ASSERT_FALSE(handler.ground(dcase));

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[1] = 0;
  dcase[4] = 0;
  ASSERT_FALSE(handler.ground(dcase));

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[3] = 2;
  ASSERT_TRUE(handler.ground(dcase));

  std::fill(dcase.begin(), dcase.end(), -1);
  dcase[4] = 0;
  ASSERT_TRUE(handler.ground(dcase));
}
<|endoftext|>


<commit_before>#include "tests.h"

// Work efficient prefix sum

template <typename F, typename std::enable_if<std::is_floating_point<F>::value>::type* = nullptr>
bool check_sum(cl::sycl::buffer<F, 1>& data) {
	using namespace cl::sycl;

	auto d = data.get_access<access::read, access::host_buffer>();
	F sum = 0;
	for(size_t i = 0; i < data.get_count(); ++i) {
		sum += (F)i;
		auto diff = std::abs(sum - d[i]);
		if(diff > 0.01) {
			debug() << "wrong sum, should be" << sum << "- is" << d[i];
			return false;
		}
	}

	return true;
}

template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
bool check_sum(cl::sycl::buffer<I, 1>& data) {
	using namespace cl::sycl;

	auto d = data.get_access<access::read, access::host_buffer>();
	I sum = 0;
	for(size_t i = 0; i < data.get_count(); ++i) {
		sum += (I)i;
		if(d[i] != sum) {
			debug() << "wrong sum, should be" << sum << "- is" << d[i];
			return false;
		}
	}

	return true;
}

template <typename T>
struct prefix_sum_kernel {
protected:
	using mode = cl::sycl::access::mode;
	using target = cl::sycl::access::target;

	// Global memory
	cl::sycl::accessor<T, 1> input;

	// Local memory
	cl::sycl::accessor<T, 1, mode::read_write, target::local> localBlock;

public:
	prefix_sum_kernel(cl::sycl::buffer<T>& data, size_t group_size)
		: input(data.get_access<mode::read_write>()), localBlock(group_size) {}

	void operator()(cl::sycl::nd_item<1> index) {
		using namespace cl::sycl;

		uint1 GID = 2 * index.get_global_id(0);
		uint1 LID = 2 * index.get_local_id(0);

		localBlock[LID] = input[GID];
		localBlock[LID + 1] = input[GID + 1];

		index.barrier(access::fence_space::local);

		uint1 N = 2 * index.get_local_size(0);
		uint1 first;
		uint1 second;

		LID /= 2;

		// Up-sweep
		uint1 offset = 1;
		SYCL_WHILE(offset < N)
			SYCL_BEGIN{
			SYCL_IF(LID % offset == 0)
			SYCL_BEGIN{
				first = 2 * LID + offset - 1;
				second = first + offset;
				localBlock[second] = localBlock[first] + localBlock[second];
			}
			SYCL_END

			index.barrier(access::fence_space::local);
			offset *= 2;
		}
		SYCL_END

		SYCL_IF(LID == 0)
		SYCL_THEN({
			localBlock[N - 1] = 0;
		})
		index.barrier(access::fence_space::local);

		// TODO: Need to make this generic
		uint1 tmp;

		// Down-sweep
		offset = N;
		SYCL_WHILE(offset > 0)
		SYCL_BEGIN{
			SYCL_IF(LID % offset == 0)
			SYCL_BEGIN{
				first = 2 * LID + offset - 1;
				second = first + offset;
				tmp = localBlock[second];
				localBlock[second] = localBlock[first] + tmp;
				localBlock[first] = tmp;
			}
			SYCL_END

			index.barrier(access::fence_space::local);
			offset /= 2;
		}
		SYCL_END

		LID *= 2;
		input[GID] += localBlock[LID];
		input[GID + 1] += localBlock[LID + 1];
	}
};

bool test9() {
	using namespace cl::sycl;

	{
		queue myQueue;

		const auto group_size = myQueue.get_device().get_info<CL_DEVICE_MAX_WORK_GROUP_SIZE>();
		const auto size = group_size * 2;

		buffer<float> data(size);

		// Init
		command_group(myQueue, [&]() {
			auto d = data.get_access<access::write>();

			parallel_for<>(range<1>(size), [=](id<1> index) {
				d[index] = index;
			});
		});

		command_group(myQueue, [&]() {
			// TODO: Extend for large arrays
			parallel_for<>(
				nd_range<1>(size / 2, group_size),
				prefix_sum_kernel<float>(data, group_size)
			);
		});

		return check_sum(data);
	}

	return true;
}
<commit_msg>made test9 truly generic.<commit_after>#include "tests.h"

// Work efficient prefix sum

template <typename F, typename std::enable_if<std::is_floating_point<F>::value>::type* = nullptr>
bool check_sum(cl::sycl::buffer<F, 1>& data) {
	using namespace cl::sycl;

	auto d = data.get_access<access::read, access::host_buffer>();
	F sum = 0;
	for(size_t i = 0; i < data.get_count(); ++i) {
		sum += (F)i;
		auto diff = std::abs(sum - d[i]);
		if(diff > 0.01) {
			debug() << "wrong sum, should be" << sum << "- is" << d[i];
			return false;
		}
	}

	return true;
}

template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
bool check_sum(cl::sycl::buffer<I, 1>& data) {
	using namespace cl::sycl;

	auto d = data.get_access<access::read, access::host_buffer>();
	I sum = 0;
	for(size_t i = 0; i < data.get_count(); ++i) {
		sum += (I)i;
		if(d[i] != sum) {
			debug() << "wrong sum, should be" << sum << "- is" << d[i];
			return false;
		}
	}

	return true;
}

template <typename T>
struct prefix_sum_kernel {
protected:
	using mode = cl::sycl::access::mode;
	using target = cl::sycl::access::target;

	// Global memory
	cl::sycl::accessor<T, 1> input;

	// Local memory
	cl::sycl::accessor<T, 1, mode::read_write, target::local> localBlock;

public:
	prefix_sum_kernel(cl::sycl::buffer<T>& data, size_t group_size)
		: input(data.get_access<mode::read_write>()), localBlock(group_size) {}

	void operator()(cl::sycl::nd_item<1> index) {
		using namespace cl::sycl;

		uint1 GID = 2 * index.get_global_id(0);
		uint1 LID = 2 * index.get_local_id(0);

		localBlock[LID] = input[GID];
		localBlock[LID + 1] = input[GID + 1];

		index.barrier(access::fence_space::local);

		uint1 N = 2 * index.get_local_size(0);
		uint1 first;
		uint1 second;

		LID /= 2;

		// Up-sweep
		uint1 offset = 1;
		SYCL_WHILE(offset < N)
			SYCL_BEGIN{
			SYCL_IF(LID % offset == 0)
			SYCL_BEGIN{
				first = 2 * LID + offset - 1;
				second = first + offset;
				localBlock[second] = localBlock[first] + localBlock[second];
			}
			SYCL_END

			index.barrier(access::fence_space::local);
			offset *= 2;
		}
		SYCL_END

		SYCL_IF(LID == 0)
		SYCL_THEN({
			localBlock[N - 1] = 0;
		})
		index.barrier(access::fence_space::local);

		vec<T, 1> tmp;

		// Down-sweep
		offset = N;
		SYCL_WHILE(offset > 0)
		SYCL_BEGIN{
			SYCL_IF(LID % offset == 0)
			SYCL_BEGIN{
				first = 2 * LID + offset - 1;
				second = first + offset;
				tmp = localBlock[second];
				localBlock[second] = localBlock[first] + tmp;
				localBlock[first] = tmp;
			}
			SYCL_END

			index.barrier(access::fence_space::local);
			offset /= 2;
		}
		SYCL_END

		LID *= 2;
		input[GID] += localBlock[LID];
		input[GID + 1] += localBlock[LID + 1];
	}
};

bool test9() {
	using namespace cl::sycl;

	{
		queue myQueue;

		const auto group_size = myQueue.get_device().get_info<CL_DEVICE_MAX_WORK_GROUP_SIZE>();
		const auto size = group_size * 2;

		using type = double;
		buffer<type> data(size);

		// Init
		command_group(myQueue, [&]() {
			auto d = data.get_access<access::write>();

			parallel_for<>(range<1>(size), [=](id<1> index) {
				d[index] = index;
			});
		});

		command_group(myQueue, [&]() {
			// TODO: Extend for large arrays
			parallel_for<>(
				nd_range<1>(size / 2, group_size),
				prefix_sum_kernel<type>(data, group_size)
			);
		});

		return check_sum(data);
	}

	return true;
}
<|endoftext|>


<commit_before>#include <QAbstractButton>

#include "KVSettingsDialog.h"
#include "ui_KVSettingsDialog.h"
#include "KVMainWindow.h"
#include "KVDefaults.h"

KVSettingsDialog::KVSettingsDialog(KVMainWindow *parent, Qt::WindowFlags f) :
	QDialog(parent, f),
	ui(new Ui::KVSettingsDialog)
{
	ui->setupUi(this);

	ui->translationCheckbox->setChecked(
		settings.value("viewerTranslation", kDefaultTranslation).toBool());
	ui->proxyCheckbox->setChecked(settings.value("proxy", kDefaultProxy).toBool());
	ui->proxyServerEdit->setText(settings.value("proxyServer", kDefaultProxyServer).toString());
	ui->proxyPortBox->setValue(settings.value("proxyPort", kDefaultProxyPort).toInt());
	ui->proxyUserEdit->setText(settings.value("proxyUser", kDefaultProxyUser).toString());
	ui->proxyPassEdit->setText(settings.value("proxyPass", kDefaultProxyPass).toString());
	switch(settings.value("proxyType", kDefaultProxyType).toInt())
	{
	default:
	case QNetworkProxy::Socks5Proxy:
		ui->socksProxyRadio->setChecked(true);
		break;
	case QNetworkProxy::HttpProxy:
		ui->httpProxyRadio->setChecked(true);
		break;
	}

	connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)),
	        SLOT(buttonClicked(QAbstractButton*)));

	this->adjustSize();
}

KVSettingsDialog::~KVSettingsDialog()
{

}

void KVSettingsDialog::accept()
{
	this->setSettings();

	QDialog::accept();
}

void KVSettingsDialog::setSettings()
{
	settings.setValue("viewerTranslation", ui->translationCheckbox->isChecked());
	settings.setValue("proxy", ui->proxyCheckbox->isChecked());
	settings.setValue("proxyServer", ui->proxyServerEdit->text());
	settings.setValue("proxyPort", ui->proxyPortBox->value());
	if(ui->socksProxyRadio->isChecked())
		settings.setValue("proxyType", QNetworkProxy::Socks5Proxy);
	else if(ui->httpProxyRadio->isChecked())
		settings.setValue("proxyType", QNetworkProxy::HttpProxy);

	settings.sync();

	emit apply();
}

void KVSettingsDialog::buttonClicked(QAbstractButton *button)
{
	if(ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
		setSettings();
}
<commit_msg>Fix the size of the Viewer Settings dialog<commit_after>#include <QAbstractButton>

#include "KVSettingsDialog.h"
#include "ui_KVSettingsDialog.h"
#include "KVMainWindow.h"
#include "KVDefaults.h"

KVSettingsDialog::KVSettingsDialog(KVMainWindow *parent, Qt::WindowFlags f) :
	QDialog(parent, f),
	ui(new Ui::KVSettingsDialog)
{
	ui->setupUi(this);

	ui->translationCheckbox->setChecked(
		settings.value("viewerTranslation", kDefaultTranslation).toBool());
	ui->proxyCheckbox->setChecked(settings.value("proxy", kDefaultProxy).toBool());
	ui->proxyServerEdit->setText(settings.value("proxyServer", kDefaultProxyServer).toString());
	ui->proxyPortBox->setValue(settings.value("proxyPort", kDefaultProxyPort).toInt());
	ui->proxyUserEdit->setText(settings.value("proxyUser", kDefaultProxyUser).toString());
	ui->proxyPassEdit->setText(settings.value("proxyPass", kDefaultProxyPass).toString());
	switch(settings.value("proxyType", kDefaultProxyType).toInt())
	{
	default:
	case QNetworkProxy::Socks5Proxy:
		ui->socksProxyRadio->setChecked(true);
		break;
	case QNetworkProxy::HttpProxy:
		ui->httpProxyRadio->setChecked(true);
		break;
	}

	connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)),
	        SLOT(buttonClicked(QAbstractButton*)));

	this->adjustSize();
	this->setFixedSize(this->size());
}

KVSettingsDialog::~KVSettingsDialog()
{

}

void KVSettingsDialog::accept()
{
	this->setSettings();

	QDialog::accept();
}

void KVSettingsDialog::setSettings()
{
	settings.setValue("viewerTranslation", ui->translationCheckbox->isChecked());
	settings.setValue("proxy", ui->proxyCheckbox->isChecked());
	settings.setValue("proxyServer", ui->proxyServerEdit->text());
	settings.setValue("proxyPort", ui->proxyPortBox->value());
	if(ui->socksProxyRadio->isChecked())
		settings.setValue("proxyType", QNetworkProxy::Socks5Proxy);
	else if(ui->httpProxyRadio->isChecked())
		settings.setValue("proxyType", QNetworkProxy::HttpProxy);

	settings.sync();

	emit apply();
}

void KVSettingsDialog::buttonClicked(QAbstractButton *button)
{
	if(ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
		setSettings();
}
<|endoftext|>


<commit_before>// Copyright (c) 2010 Nickolas Pohilets
//
// This file is a part of the unit test suit for the CppEvents library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <Cpp/Events/AbstractObjectRef.hpp>
#include "TestClasses.hpp"
#include <gtest/gtest.h>

using Cpp::Private::Events::IsPolymorphic;

////////////////////////////////////////////////////////////////////////////////
// For checking polymorphy special template class is derived from class being tested.
// This potentially may cause compilation problems if some special members of base class are inaccessible.
// This test is designed for detecting these problems. Test is passed if it compiles.

TEST(Test_IsPolymorphic, Compilability)
{
	bool const b = IsPolymorphic<ClassWithUndefinedPrivateCtorAndDtor>::value;
	(void)b;
}

////////////////////////////////////////////////////////////////////////////////
// Class alignment may possibly cause false detection of polymorphic classes.
// This test is designed for detecting them.

namespace {
	template<int n> void doTestAlignmentIssues(ClassOfSize<n> const & x)
	{
		ASSERT_FALSE(IsPolymorphic< ClassOfSize<n> >::value);
	}

	template<int n> void testAlignmentIssues(ClassOfSize<n> const & x)
	{
		doTestAlignmentIssues(x);
		testAlignmentIssues(ClassOfSize<n-1>());
	}

	void testAlignmentIssues(ClassOfSize<0> const & x)
	{
		doTestAlignmentIssues(x);
	}
}

TEST(Test_IsPolymorphic, AlignmentIssues)
{
	testAlignmentIssues(ClassOfSize< sizeof(void*) * 2 >());
}

////////////////////////////////////////////////////////////////////////////////
// This test checks classes that are naturally non-polymorphic.
// The TestAlignmentIssues does the same but does it better.
// Thus this test is not much useful but let it be.
TEST(Test_IsPolymorphic, NaturallyNonPolymorphic)
{
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass2_1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass3_1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass4_2_3 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass2 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass3 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass4 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass5 >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that all naturally polymorphic classes are detected as polymorphic.
TEST(Test_IsPolymorphic, NaturallyPolymorphic)
{
	//This class are naturally polymorphic
	ASSERT_TRUE(IsPolymorphic< VirtualByDestructor >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualByFunction >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualByPureFunction >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualBaseClass >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualDerivedClass1 >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualDerivedClass2 >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualCommonDerived >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that have non-virtual hierarchy root and have
// added virtuality later in the hierarchy tree are detected as polymorphic.
TEST(Test_IsPolymorphic, Polymorphized)
{
	//This classes
	ASSERT_TRUE(IsPolymorphic< ClassThatAddsVirtuality1 >::value);
	ASSERT_TRUE(IsPolymorphic< ClassThatAddsVirtuality2 >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass2_1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass3_1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass4_2_3> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass2> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass3> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass4> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass5> >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that use virtual inheritance, but does not
// have any virtual functions are detected as non-polymorphic.
TEST(Test_IsPolymorphic, VirtualInheritanceDoesNotMakeClassesPolymorphic)
{
	ASSERT_FALSE(IsPolymorphic< VirtualInhLeft >::value);
	ASSERT_FALSE(IsPolymorphic< VirtualInhRight >::value);
	ASSERT_FALSE(IsPolymorphic< VirtualInhBottom >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that have virtual functions, but use virtual
// inheritance still are polymorphic.
TEST(Test_IsPolymorphic, VirtualInheritanceDoesNotExcludePolymorphism)
{
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraL >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraR >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraX >::value);
}
<commit_msg>-: Fixed: infinite recursion in  testAlignmentIssues(ClassOfSize<n> const &) under GCC<commit_after>// Copyright (c) 2010 Nickolas Pohilets
//
// This file is a part of the unit test suit for the CppEvents library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include <Cpp/Events/AbstractObjectRef.hpp>
#include "TestClasses.hpp"
#include <gtest/gtest.h>

using Cpp::Private::Events::IsPolymorphic;

////////////////////////////////////////////////////////////////////////////////
// For checking polymorphy special template class is derived from class being tested.
// This potentially may cause compilation problems if some special members of base class are inaccessible.
// This test is designed for detecting these problems. Test is passed if it compiles.

TEST(Test_IsPolymorphic, Compilability)
{
	bool const b = IsPolymorphic<ClassWithUndefinedPrivateCtorAndDtor>::value;
	(void)b;
}

////////////////////////////////////////////////////////////////////////////////
// Class alignment may possibly cause false detection of polymorphic classes.
// This test is designed for detecting them.

namespace {
	template<int n> void doTestAlignmentIssues(ClassOfSize<n> const & x)
	{
		ASSERT_FALSE(IsPolymorphic< ClassOfSize<n> >::value);
	}

	void testAlignmentIssues(ClassOfSize<0> const & x)
	{
		doTestAlignmentIssues(x);
	}

	template<int n> void testAlignmentIssues(ClassOfSize<n> const & x)
	{
		doTestAlignmentIssues(x);
		testAlignmentIssues(ClassOfSize<n-1>());
	}
}

TEST(Test_IsPolymorphic, AlignmentIssues)
{
	testAlignmentIssues(ClassOfSize< sizeof(void*) * 2 >());
}

////////////////////////////////////////////////////////////////////////////////
// This test checks classes that are naturally non-polymorphic.
// The TestAlignmentIssues does the same but does it better.
// Thus this test is not much useful but let it be.
TEST(Test_IsPolymorphic, NaturallyNonPolymorphic)
{
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass2_1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass3_1 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass4_2_3 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass2 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass3 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass4 >::value);
	ASSERT_FALSE(IsPolymorphic< NonVirtualClass5 >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that all naturally polymorphic classes are detected as polymorphic.
TEST(Test_IsPolymorphic, NaturallyPolymorphic)
{
	//This class are naturally polymorphic
	ASSERT_TRUE(IsPolymorphic< VirtualByDestructor >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualByFunction >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualByPureFunction >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualBaseClass >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualDerivedClass1 >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualDerivedClass2 >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualCommonDerived >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that have non-virtual hierarchy root and have
// added virtuality later in the hierarchy tree are detected as polymorphic.
TEST(Test_IsPolymorphic, Polymorphized)
{
	//This classes
	ASSERT_TRUE(IsPolymorphic< ClassThatAddsVirtuality1 >::value);
	ASSERT_TRUE(IsPolymorphic< ClassThatAddsVirtuality2 >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass2_1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass3_1> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass4_2_3> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass2> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass3> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass4> >::value);
	ASSERT_TRUE(IsPolymorphic< Virtualizer<NonVirtualClass5> >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that use virtual inheritance, but does not
// have any virtual functions are detected as non-polymorphic.
TEST(Test_IsPolymorphic, VirtualInheritanceDoesNotMakeClassesPolymorphic)
{
	ASSERT_FALSE(IsPolymorphic< VirtualInhLeft >::value);
	ASSERT_FALSE(IsPolymorphic< VirtualInhRight >::value);
	ASSERT_FALSE(IsPolymorphic< VirtualInhBottom >::value);
}

////////////////////////////////////////////////////////////////////////////////
// This test ensures that classes that have virtual functions, but use virtual
// inheritance still are polymorphic.
TEST(Test_IsPolymorphic, VirtualInheritanceDoesNotExcludePolymorphism)
{
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraL >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraR >::value);
	ASSERT_TRUE(IsPolymorphic< VirtualInhExtraX >::value);
}
<|endoftext|>


<commit_before>// Virvo - Virtual Reality Volume Rendering
// Copyright (C) 1999-2003 University of Stuttgart, 2004-2005 Brown University
// Contact: Jurgen P. Schulze, jschulze@ucsd.edu
//
// This file is part of Virvo.
//
// Virvo is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library (see license.txt); if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#ifdef HAVE_CONFIG_H
#include "vvconfig.h"
#endif

#include "vvdebugmsg.h"
#include "vvinttypes.h"
#include "vvmulticast.h"
#include "vvsocketmonitor.h"

#ifdef HAVE_NORM
#include <normApi.h>
#include <stdlib.h>
#include <sys/select.h>
#endif

vvMulticast::vvMulticast(const char* addr, const ushort port, const MulticastType type)
: _type(type)
{
#ifdef HAVE_NORM
  _instance = NormCreateInstance();
  _session = NormCreateSession(_instance, addr, port, NORM_NODE_ANY);

  NormSetCongestionControl(_session, true);
  if(VV_SENDER == type)
  {
    NormSessionId sessionId = (NormSessionId)rand();
    // TODO: Adjust these numbers depending on the used network topology
    NormStartSender(_session, sessionId, 1024*1024, 1400, 64, 16);
    NormSetTxSocketBuffer(_session, 512000);
  }
  else if(VV_RECEIVER == type)
  {
    NormStartReceiver(_session, 1024*1024);
    NormDescriptor normDesc = NormGetDescriptor(_instance);
    _normSocket = new vvSocket(normDesc, vvSocket::VV_UDP);
  }
#else
  (void)addr;
  (void)port;
#endif
}

vvMulticast::~vvMulticast()
{
#ifdef HAVE_NORM
  if(VV_SENDER == _type)
  {
    NormStopSender(_session);
  }
  else if(VV_RECEIVER == _type)
  {
    NormStopReceiver(_session);
    delete _normSocket;
  }
  NormDestroySession(_session);
  NormDestroyInstance(_instance);
#endif
}

ssize_t vvMulticast::write(const uchar* bytes, const uint size, double timeout)
{
  vvDebugMsg::msg(3, "vvMulticast::write()");
#ifdef HAVE_NORM
  _object = NormDataEnqueue(_session, (char*)bytes, size);

  if(NORM_OBJECT_INVALID ==_object)
  {
    vvDebugMsg::msg(2, "vvMulticast::write(): Norm Object is invalid!");
    return false;
  }

  NormDescriptor normDesc = NormGetDescriptor(_instance);

  vvSocketMonitor* monitor = new vvSocketMonitor;

  std::vector<vvSocket*> sock;
  sock.push_back(new vvSocket(normDesc, vvSocket::VV_UDP));
  monitor->setReadFds(sock);

  vvSocket* ready;
  NormEvent theEvent;
  while(true)
  {
    ready = monitor->wait(&timeout);
    if(NULL == ready)
    {
      vvDebugMsg::msg(2, "vvMulticast::write() error or timeout reached!");
      return 0;
    }
    else
    {
      NormGetNextEvent(_instance, &theEvent);
      switch(theEvent.type)
      {
      case NORM_CC_ACTIVE:
        vvDebugMsg::msg(3, "vvMulticast::write() NORM_CC_ACTIVE: transmission still active");
        break;
      case NORM_TX_FLUSH_COMPLETED:
      case NORM_LOCAL_SENDER_CLOSED:
      case NORM_TX_OBJECT_SENT:
        vvDebugMsg::msg(3, "vvMulticast::write() NORM_TX_FLUSH_COMPLETED: transfer completed.");
        return NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        break;
      default:
        {
          std::string eventmsg = std::string("vvMulticast::write() Norm-Event: ");
          eventmsg += theEvent.type;
          vvDebugMsg::msg(3, eventmsg.c_str());
          break;
        }
      }
    }
  }
#else
  (void)bytes;
  (void)size;
  (void)timeout;
  return -1;
#endif
}

ssize_t vvMulticast::read(const uint size, uchar*& data, double timeout)
{
  vvDebugMsg::msg(3, "vvMulticast::read()");
#ifdef HAVE_NORM
  vvSocketMonitor monitor;

  std::vector<vvSocket*> sock;
  sock.push_back(_normSocket);
  monitor.setReadFds(sock);

  NormEvent theEvent;
  uint bytesReceived = 0;
  bool keepGoing = true;
  do
  {
    vvSocket* ready = monitor.wait(&timeout);
    if(NULL == ready)
    {
      vvDebugMsg::msg(2, "vvMulticast::read() error or timeout reached!");
      return 0;
    }
    else
    {
      NormGetNextEvent(_instance, &theEvent);
      switch(theEvent.type)
      {
      case NORM_RX_OBJECT_UPDATED:
        vvDebugMsg::msg(3, "vvMulticast::read() NORM_RX_OBJECT_UPDATED: the identified receive object has newly received data content.");
        bytesReceived = NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        break;
      case NORM_RX_OBJECT_COMPLETED:
        vvDebugMsg::msg(3, "vvMulticast::read() NORM_RX_OBJECT_COMPLETED: transfer completed.");
        bytesReceived = NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        keepGoing = false;
        break;
      case NORM_RX_OBJECT_ABORTED:
        vvDebugMsg::msg(2, "vvMulticast::read() NORM_RX_OBJECT_ABORTED: transfer incomplete!");
        return -1;
        break;
      default:
        {
          std::string eventmsg = std::string("vvMulticast::read() Norm-Event: ");
          eventmsg += theEvent.type;
          std::cerr << theEvent.type << std::endl;
          vvDebugMsg::msg(3, eventmsg.c_str());
          break;
        }
      }
    }
    if(bytesReceived >= size) keepGoing = false;
  }
  while((0.0 < timeout || -1.0 == timeout) && keepGoing);

  data = (uchar*)NormDataDetachData(theEvent.object);
  return bytesReceived;
#else
  (void)size;
  (void)data;
  (void)timeout;
  return -1;
#endif
}

// vim: sw=2:expandtab:softtabstop=2:ts=2:cino=\:0g0t0
<commit_msg>remove debug-code<commit_after>// Virvo - Virtual Reality Volume Rendering
// Copyright (C) 1999-2003 University of Stuttgart, 2004-2005 Brown University
// Contact: Jurgen P. Schulze, jschulze@ucsd.edu
//
// This file is part of Virvo.
//
// Virvo is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library (see license.txt); if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#ifdef HAVE_CONFIG_H
#include "vvconfig.h"
#endif

#include "vvdebugmsg.h"
#include "vvinttypes.h"
#include "vvmulticast.h"
#include "vvsocketmonitor.h"

#ifdef HAVE_NORM
#include <normApi.h>
#include <stdlib.h>
#include <sys/select.h>
#endif

vvMulticast::vvMulticast(const char* addr, const ushort port, const MulticastType type)
: _type(type)
{
#ifdef HAVE_NORM
  _instance = NormCreateInstance();
  _session = NormCreateSession(_instance, addr, port, NORM_NODE_ANY);

  NormSetCongestionControl(_session, true);
  if(VV_SENDER == type)
  {
    NormSessionId sessionId = (NormSessionId)rand();
    // TODO: Adjust these numbers depending on the used network topology
    NormStartSender(_session, sessionId, 1024*1024, 1400, 64, 16);
    NormSetTxSocketBuffer(_session, 512000);
  }
  else if(VV_RECEIVER == type)
  {
    NormStartReceiver(_session, 1024*1024);
    NormDescriptor normDesc = NormGetDescriptor(_instance);
    _normSocket = new vvSocket(normDesc, vvSocket::VV_UDP);
  }
#else
  (void)addr;
  (void)port;
#endif
}

vvMulticast::~vvMulticast()
{
#ifdef HAVE_NORM
  if(VV_SENDER == _type)
  {
    NormStopSender(_session);
  }
  else if(VV_RECEIVER == _type)
  {
    NormStopReceiver(_session);
    delete _normSocket;
  }
  NormDestroySession(_session);
  NormDestroyInstance(_instance);
#endif
}

ssize_t vvMulticast::write(const uchar* bytes, const uint size, double timeout)
{
  vvDebugMsg::msg(3, "vvMulticast::write()");
#ifdef HAVE_NORM
  _object = NormDataEnqueue(_session, (char*)bytes, size);

  if(NORM_OBJECT_INVALID ==_object)
  {
    vvDebugMsg::msg(2, "vvMulticast::write(): Norm Object is invalid!");
    return false;
  }

  NormDescriptor normDesc = NormGetDescriptor(_instance);

  vvSocketMonitor* monitor = new vvSocketMonitor;

  std::vector<vvSocket*> sock;
  sock.push_back(new vvSocket(normDesc, vvSocket::VV_UDP));
  monitor->setReadFds(sock);

  vvSocket* ready;
  NormEvent theEvent;
  while(true)
  {
    ready = monitor->wait(&timeout);
    if(NULL == ready)
    {
      vvDebugMsg::msg(2, "vvMulticast::write() error or timeout reached!");
      return 0;
    }
    else
    {
      NormGetNextEvent(_instance, &theEvent);
      switch(theEvent.type)
      {
      case NORM_CC_ACTIVE:
        vvDebugMsg::msg(3, "vvMulticast::write() NORM_CC_ACTIVE: transmission still active");
        break;
      case NORM_TX_FLUSH_COMPLETED:
      case NORM_LOCAL_SENDER_CLOSED:
      case NORM_TX_OBJECT_SENT:
        vvDebugMsg::msg(3, "vvMulticast::write() NORM_TX_FLUSH_COMPLETED: transfer completed.");
        return NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        break;
      default:
        {
          std::string eventmsg = std::string("vvMulticast::write() Norm-Event: ");
          eventmsg += theEvent.type;
          vvDebugMsg::msg(3, eventmsg.c_str());
          break;
        }
      }
    }
  }
#else
  (void)bytes;
  (void)size;
  (void)timeout;
  return -1;
#endif
}

ssize_t vvMulticast::read(const uint size, uchar*& data, double timeout)
{
  vvDebugMsg::msg(3, "vvMulticast::read()");
#ifdef HAVE_NORM
  vvSocketMonitor monitor;

  std::vector<vvSocket*> sock;
  sock.push_back(_normSocket);
  monitor.setReadFds(sock);

  NormEvent theEvent;
  uint bytesReceived = 0;
  bool keepGoing = true;
  do
  {
    vvSocket* ready = monitor.wait(&timeout);
    if(NULL == ready)
    {
      vvDebugMsg::msg(2, "vvMulticast::read() error or timeout reached!");
      return 0;
    }
    else
    {
      NormGetNextEvent(_instance, &theEvent);
      switch(theEvent.type)
      {
      case NORM_RX_OBJECT_UPDATED:
        vvDebugMsg::msg(3, "vvMulticast::read() NORM_RX_OBJECT_UPDATED: the identified receive object has newly received data content.");
        bytesReceived = NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        break;
      case NORM_RX_OBJECT_COMPLETED:
        vvDebugMsg::msg(3, "vvMulticast::read() NORM_RX_OBJECT_COMPLETED: transfer completed.");
        bytesReceived = NormObjectGetSize(theEvent.object) - NormObjectGetBytesPending(theEvent.object);
        keepGoing = false;
        break;
      case NORM_RX_OBJECT_ABORTED:
        vvDebugMsg::msg(2, "vvMulticast::read() NORM_RX_OBJECT_ABORTED: transfer incomplete!");
        return -1;
        break;
      default:
        {
          std::string eventmsg = std::string("vvMulticast::read() Norm-Event: ");
          eventmsg += theEvent.type;
          vvDebugMsg::msg(3, eventmsg.c_str());
          break;
        }
      }
    }
    if(bytesReceived >= size) keepGoing = false;
  }
  while((0.0 < timeout || -1.0 == timeout) && keepGoing);

  data = (uchar*)NormDataDetachData(theEvent.object);
  return bytesReceived;
#else
  (void)size;
  (void)data;
  (void)timeout;
  return -1;
#endif
}

// vim: sw=2:expandtab:softtabstop=2:ts=2:cino=\:0g0t0
<|endoftext|>


<commit_before>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3226
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<commit_msg>SWDEV-2 - Change OpenCL version number from  3226 to 3227<commit_after>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3227
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<|endoftext|>


<commit_before>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3303
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<commit_msg>SWDEV-2 - Change OpenCL version number from  3303 to 3304<commit_after>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3304
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<|endoftext|>


<commit_before>/* Copyright (c) 2010 - 2021 Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3389
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<commit_msg>SWDEV-2 - Change OpenCL version number from  3389 to 3390<commit_after>/* Copyright (c) 2010 - 2021 Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3390
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<|endoftext|>


<commit_before>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3186
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<commit_msg>SWDEV-2 - Change OpenCL version number from  3186 to 3187<commit_after>/* Copyright (c) 2010-present Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef VERSIONS_HPP_
#define VERSIONS_HPP_

#include "utils/macros.hpp"

#ifndef AMD_PLATFORM_NAME
#define AMD_PLATFORM_NAME "AMD Accelerated Parallel Processing"
#endif  // AMD_PLATFORM_NAME

#ifndef AMD_PLATFORM_BUILD_NUMBER
#define AMD_PLATFORM_BUILD_NUMBER 3187
#endif  // AMD_PLATFORM_BUILD_NUMBER

#ifndef AMD_PLATFORM_REVISION_NUMBER
#define AMD_PLATFORM_REVISION_NUMBER 0
#endif  // AMD_PLATFORM_REVISION_NUMBER

#ifndef AMD_PLATFORM_RELEASE_INFO
#define AMD_PLATFORM_RELEASE_INFO
#endif  // AMD_PLATFORM_RELEASE_INFO

#define AMD_BUILD_STRING                                                                           \
  XSTR(AMD_PLATFORM_BUILD_NUMBER)                                                                  \
  "." XSTR(AMD_PLATFORM_REVISION_NUMBER)

#ifndef AMD_PLATFORM_INFO
#define AMD_PLATFORM_INFO                                                                          \
  "AMD-APP" AMD_PLATFORM_RELEASE_INFO DEBUG_ONLY(                                                  \
      "." IF(IS_OPTIMIZED, "opt", "dbg")) " (" AMD_BUILD_STRING ")"
#endif  // ATI_PLATFORM_INFO

#endif  // VERSIONS_HPP_
<|endoftext|>