brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 70c22b7 Raw
41 lines · cpp
1//===-- Test for the shuffle operations on the GPU ------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/__support/CPP/bit.h"10#include "src/__support/GPU/utils.h"11#include "test/IntegrationTest/test.h"12 13using namespace LIBC_NAMESPACE;14 15// Test to ensure that match any / match all work.16static void test_match() {17  // FIXME: Disable on older SMs as they hang for some reason.18#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 70019  uint64_t mask = gpu::get_lane_mask();20  EXPECT_EQ(1ull << gpu::get_lane_id(),21            gpu::match_any(mask, gpu::get_lane_id()));22  EXPECT_EQ(mask, gpu::match_any(mask, 1));23 24  uint64_t full_mask =25      gpu::get_lane_size() > 32 ? 0xffffffffffffffff : 0xffffffff;26  uint64_t expected = gpu::get_lane_id() < 16 ? 0xffff : full_mask & ~0xffff;27  EXPECT_EQ(expected, gpu::match_any(mask, gpu::get_lane_id() < 16));28  EXPECT_EQ(mask, gpu::match_all(mask, 1));29  EXPECT_EQ(0ull, gpu::match_all(mask, gpu::get_lane_id()));30#endif31}32 33TEST_MAIN(int argc, char **argv, char **envp) {34  if (gpu::get_thread_id() >= gpu::get_lane_size())35    return 0;36 37  test_match();38 39  return 0;40}41