Skip to content

Commit

Permalink
Merge pull request #815 from jiezzhang/group_functions_split_by_type
Browse files Browse the repository at this point in the history
Split group_scan and group_reduce tests by data types
  • Loading branch information
bader authored Nov 21, 2023
2 parents 57cc89d + 8e91479 commit 3ace7fc
Show file tree
Hide file tree
Showing 19 changed files with 261 additions and 971 deletions.
35 changes: 35 additions & 0 deletions tests/group_functions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
function(configure_test_case)
cmake_parse_arguments(CTS
"" "TYPE;IN_FILENAME;OUT_FILENAME;TEST_LIST" "" ${ARGN})
set(CTS_TYPE_NAME ${CTS_TYPE})
configure_file(${CTS_IN_FILENAME} ${CTS_OUT_FILENAME})
list(APPEND ${CTS_TEST_LIST} "${CMAKE_CURRENT_BINARY_DIR}/${CTS_OUT_FILENAME}")
set(${CTS_TEST_LIST} ${${CTS_TEST_LIST}} PARENT_SCOPE)
endfunction()

list(APPEND TEMPLATE_LIST
"group_joint_scan"
"group_scan_over_group"
"group_joint_reduce"
"group_reduce_over_group"
)
set(TYPE_LIST "")
get_std_type(TYPE_LIST)
half_double_filter(TYPE_LIST)

file(GLOB test_cases_list *.cpp)

foreach(TEMP IN LISTS TEMPLATE_LIST)
foreach(TY IN LISTS TYPE_LIST)
if(TY STREQUAL "bool")
continue()
endif()
set(OUT_FILE "${TEMP}_${TY}.cpp")
STRING(REGEX REPLACE ":" "_" OUT_FILE ${OUT_FILE})
STRING(REGEX REPLACE " " "_" OUT_FILE ${OUT_FILE})
configure_test_case(
TYPE "${TY}"
IN_FILENAME "${TEMP}.cpp.in"
OUT_FILENAME ${OUT_FILE}
TEST_LIST test_cases_list)
endforeach()
endforeach()

add_cts_test(${test_cases_list})
52 changes: 0 additions & 52 deletions tests/group_functions/group_joint_reduce.cpp

This file was deleted.

75 changes: 75 additions & 0 deletions tests/group_functions/group_joint_reduce.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*******************************************************************************
//
// 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.
//
*******************************************************************************/

#include "group_reduce.h"

// clang-format off
#cmakedefine CTS_TYPE @CTS_TYPE@
#cmakedefine CTS_TYPE_NAME std::string("@CTS_TYPE_NAME@")
// clang-format on
using ReduceTypes = Types;

TEST_CASE(CTS_TYPE_NAME + " group and sub-group joint reduce functions",
"[group_func][type_list][dim]") {
auto queue = once_per_unit::get_queue();
const auto Operators = get_op_types<CTS_TYPE>();
const auto RetType = unnamed_type_pack<CTS_TYPE>();

if constexpr (std::is_same_v<std::remove_cv_t<CTS_TYPE>, sycl::half>) {
if (!queue.get_device().has(sycl::aspect::fp16))
SKIP(
"Device does not support half precision floating point "
"operations.");
} else if (std::is_same_v<std::remove_cv_t<CTS_TYPE>, double>) {
if (!queue.get_device().has(sycl::aspect::fp64))
SKIP(
"Device does not support double precision floating point "
"operations.");
}

for_all_combinations<invoke_joint_reduce_group>(Dims, RetType, Operators,
queue);
}

TEMPLATE_LIST_TEST_CASE(
CTS_TYPE_NAME + " group and sub-group joint reduce functions with init",
"[group_func][type_list][dim]", ReduceTypes) {
auto queue = once_per_unit::get_queue();

const auto Operators = get_op_types<CTS_TYPE>();
const auto RetType = unnamed_type_pack<CTS_TYPE>();
const auto ReducedType = unnamed_type_pack<TestType>();

if constexpr (std::is_same_v<std::remove_cv_t<CTS_TYPE>, sycl::half>) {
if (!queue.get_device().has(sycl::aspect::fp16))
SKIP(
"Device does not support half precision floating point "
"operations.");
} else if (std::is_same_v<std::remove_cv_t<CTS_TYPE>, double>) {
if (!queue.get_device().has(sycl::aspect::fp64))
SKIP(
"Device does not support double precision floating point "
"operations.");
}

// check all work group dimensions
for_all_combinations<invoke_init_joint_reduce_group>(
Dims, RetType, ReducedType, Operators, queue);
}
84 changes: 0 additions & 84 deletions tests/group_functions/group_joint_reduce_fp16.cpp

This file was deleted.

86 changes: 0 additions & 86 deletions tests/group_functions/group_joint_reduce_fp64.cpp

This file was deleted.

53 changes: 0 additions & 53 deletions tests/group_functions/group_joint_reduce_fp64_fp16.cpp

This file was deleted.

Loading

0 comments on commit 3ace7fc

Please sign in to comment.