Skip to content

Commit

Permalink
Merge pull request #744 from aleksmesh/cover_gaps_sub_group_mask_ext
Browse files Browse the repository at this point in the history
Cover gaps in oneapi_sub_group_mask extension
  • Loading branch information
bader authored Jul 9, 2023
2 parents 4684945 + afcb8f0 commit faa2495
Show file tree
Hide file tree
Showing 23 changed files with 881 additions and 556 deletions.
59 changes: 54 additions & 5 deletions tests/common/type_coverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct type_name_string<sycl::vec<T, nElements>> {
}
};

// FIXME: re-enable when marrray is implemented in hipsycl
// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Specialization of type name retrieve for sycl::marray class
Expand Down Expand Up @@ -457,7 +457,7 @@ void for_all_types_and_vectors(const named_type_pack<types...> &typeList,
assert((typeNameIndex == sizeof...(types)) && "Pack expansion failed");
}

// FIXME: re-enable when marrray is implemented in hipsycl
// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for type, vectors and marrays of this type
Expand Down Expand Up @@ -542,7 +542,7 @@ void for_type_vectors_marray_reduced(argsT&&... args) {
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL

// FIXME: re-enable when marrray is implemented in hipsycl
// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for each of types, vectors and marrays of types given by
Expand Down Expand Up @@ -573,7 +573,7 @@ void for_all_types_vectors_marray(const named_type_pack<types...> &typeList,
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL

// FIXME: re-enable when marrray is implemented in hipsycl
// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for type and marrays of this type
Expand All @@ -594,7 +594,28 @@ void for_type_and_marrays(argsT &&...args) {
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL

// FIXME: re-enable when marrray is implemented in hipsycl
// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for marrays of type T
* @tparam action Functor template for action to run
* @tparam T Type to instantiate functor template with
* @tparam actionArgsT Parameter pack to use for functor template instantiation
* @tparam argsT Deduced parameter pack for arguments to forward into the call
* @param args Arguments to forward into the call
*/
template <template <typename, typename...> class action, typename T,
typename... actionArgsT, typename... argsT>
void for_marrays_of_type(argsT&&... args) {
for_all_types<action, actionArgsT...>(
type_pack<typename sycl::template marray<T, 2>,
typename sycl::template marray<T, 5>,
typename sycl::template marray<T, 10>>{},
std::forward<argsT>(args)...);
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL

// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for each of types and marrays of types given by
Expand All @@ -621,4 +642,32 @@ void for_all_types_and_marrays(const named_type_pack<types...> &typeList,
...);
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL

// FIXME: re-enable when marray is implemented in hipsycl
#if !SYCL_CTS_COMPILING_WITH_HIPSYCL
/**
* @brief Run action for marrays of each type of types given by
* named_type_pack instance
* @tparam action Functor template for action to run
* @tparam actionArgsT Parameter pack to use for functor template instantiation
* @tparam types Deduced from type_pack parameter pack for list of types to use
* @tparam argsT Deduced parameter pack for arguments to forward into the call
* @param typeList Named type pack instance with underlying type names stored
* @param args Arguments to forward into the call
*/
template <template <typename, typename...> class action,
typename... actionArgsT, typename... types, typename... argsT>
void for_marrays_of_all_types(const named_type_pack<types...>& typeList,
argsT&&... args) {
// run action for each type from types... parameter pack
// Using fold expression to iterate over all types within type pack

size_t typeNameIndex = 0;

((for_marrays_of_type<action, types, actionArgsT...>(
std::forward<argsT>(args)..., typeList.names[typeNameIndex]),
++typeNameIndex),
...);
}
#endif // !SYCL_CTS_COMPILING_WITH_HIPSYCL
#endif // __SYCLCTS_TESTS_COMMON_TYPE_COVERAGE_H
60 changes: 32 additions & 28 deletions tests/extension/oneapi_sub_group_mask/sub_group_mask_all.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
/*******************************************************************************
//
// SYCL 2020 Extension Conformance Test
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2023 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Provides tests to check sub_group_mask all()
//
*******************************************************************************/

#include "sub_group_mask_common.h"
#include "catch2/catch_test_macros.hpp"

#define TEST_NAME sub_group_mask_all
#include "sub_group_mask_common.h"

namespace TEST_NAMESPACE {
namespace sub_group_mask_all_test {

using namespace sycl_cts;
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
Expand Down Expand Up @@ -45,32 +59,22 @@ using verification_func_for_true_predicate =
true_predicate, const sycl::ext::oneapi::sub_group_mask>;
#endif // SYCL_EXT_ONEAPI_SUB_GROUP_MASK

/** test sycl::oneapi::sub_group_mask interface
*/
class TEST_NAME : public util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(util::logger &log) override {
TEST_CASE("Check all() for mask with even predicate",
"[oneapi_sub_group_mask]") {
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
log.note("Check all() for mask with even predicate");
check_diff_sub_group_sizes<verification_func_for_even_predicate>(log);

log.note("Check all() for mask with true predicate");
check_diff_sub_group_sizes<verification_func_for_true_predicate>(log);
check_diff_sub_group_sizes<verification_func_for_even_predicate>();
#else
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif // SYCL_EXT_ONEAPI_SUB_GROUP_MASK
}
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif
};

// register this test with the test_collection.
util::test_proxy<TEST_NAME> proxy;
TEST_CASE("Check all() for mask with true predicate",
"[oneapi_sub_group_mask]") {
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
check_diff_sub_group_sizes<verification_func_for_true_predicate>();
#else
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif
};

} /* namespace TEST_NAMESPACE */
} // namespace sub_group_mask_all_test
63 changes: 33 additions & 30 deletions tests/extension/oneapi_sub_group_mask/sub_group_mask_any.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
/*******************************************************************************
//
// SYCL 2020 Extension Conformance Test
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2023 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Provides tests to check sub_group_mask any()
//
*******************************************************************************/

#include "sub_group_mask_common.h"
#include "catch2/catch_test_macros.hpp"

#define TEST_NAME sub_group_mask_any
#include "sub_group_mask_common.h"

namespace TEST_NAMESPACE {
namespace sub_group_mask_any_test {

using namespace sycl_cts;
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
Expand Down Expand Up @@ -45,33 +59,22 @@ using verification_func_for_false_predicate =
false_predicate, const sycl::ext::oneapi::sub_group_mask>;
#endif // SYCL_EXT_ONEAPI_SUB_GROUP_MASK

/** test sycl::oneapi::sub_group_mask interface
*/
class TEST_NAME : public util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(util::logger &log) override {
TEST_CASE("Check any() for mask with even predicate",
"[oneapi_sub_group_mask]") {
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
log.note("Check any() for mask with even predicate");
check_diff_sub_group_sizes<verification_func_for_even_predicate>(log);

log.note("Check any() for mask with false predicate");
check_diff_sub_group_sizes<verification_func_for_false_predicate>(log);

check_diff_sub_group_sizes<verification_func_for_even_predicate>();
#else
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif // SYCL_EXT_ONEAPI_SUB_GROUP_MASK
}
};
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif
}

// register this test with the test_collection.
util::test_proxy<TEST_NAME> proxy;
TEST_CASE("Check any() for mask with false predicate",
"[oneapi_sub_group_mask]") {
#ifdef SYCL_EXT_ONEAPI_SUB_GROUP_MASK
check_diff_sub_group_sizes<verification_func_for_false_predicate>();
#else
SKIP("SYCL_EXT_ONEAPI_SUB_GROUP_MASK is not defined");
#endif
}

} /* namespace TEST_NAMESPACE */
} // namespace sub_group_mask_any_test
Loading

0 comments on commit faa2495

Please sign in to comment.