brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · e64a62f Raw
36 lines · plain
1//===----------------------------------------------------------------------===//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/// \file10/// This file contains the definition of the runKernelBody, a template helper11/// that executes the per-thread logic of a math function's kernel wrapper.12///13//===----------------------------------------------------------------------===//14 15#ifndef CONFORMANCE_DEVICE_CODE_KERNELRUNNER_HPP16#define CONFORMANCE_DEVICE_CODE_KERNELRUNNER_HPP17 18#include <gpuintrin.h>19#include <stddef.h>20#include <stdint.h>21 22namespace kernels {23 24template <auto Func, typename OutType, typename... InTypes>25void runKernelBody(size_t NumElements, OutType *Out, const InTypes *...Ins) {26  uint32_t Index =27      __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x();28 29  if (Index < NumElements) {30    Out[Index] = Func(Ins[Index]...);31  }32}33} // namespace kernels34 35#endif // CONFORMANCE_DEVICE_CODE_KERNELRUNNER_HPP36