Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Conversion/GPUToNVVM/CommonTypes.h
- This file was added.
//===----- CommonTypes.h - Contains LLVM Types common to all Lowerings. ---===// | |||||
// | |||||
ftynse: Headers need to have `-*- C++ -*-` at the end of the first line | |||||
Looks like this comment wasn't addressed.. ftynse: Looks like this comment wasn't addressed.. | |||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |||||
// See https://llvm.org/LICENSE.txt for license information. | |||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||||
// | |||||
//===----------------------------------------------------------------------===// | |||||
// | |||||
// This file contains the common LLVM types that are used by the lowerings of | |||||
// GPU MMA Ops to NVVM ops. | |||||
// | |||||
//===----------------------------------------------------------------------===// | |||||
#ifndef MLIR_LIB_CONVERSION_GPUTONVVM_COMMONTYPES_H | |||||
Lint: Pre-merge checks clang-tidy: warning: header guard does not follow preferred style [llvm-header-guard] Lint: Pre-merge checks: clang-tidy: warning: header guard does not follow preferred style [llvm-header-guard]
[[https… | |||||
#define MLIR_LIB_CONVERSION_GPUTONVVM_COMMONTYPES_H | |||||
clang-tidy warning if this is a meaningful one. bondhugula: clang-tidy warning if this is a meaningful one. | |||||
The style given here already followed. https://llvm.org/docs/CodingStandards.html#header-guard navdeepkk: The style given here already followed. https://llvm.org/docs/CodingStandards.html#header-guard | |||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" | |||||
#include "mlir/IR/Builders.h" | |||||
#include "llvm/IR/DerivedTypes.h" | |||||
namespace mlir { | |||||
/// Contains all the common LLVM types which are used across the lowerings of | |||||
/// GPU subgroup ops to NVVM dialect. | |||||
struct CommonLLVMAndBuiltInMLIRTypes { | |||||
public: | |||||
Many of these are now built-in MLIR types. common LLVM -> 'common LLVM and builtin MLIR` bondhugula: Many of these are now built-in MLIR types. `common LLVM` -> 'common LLVM and builtin MLIR` | |||||
CommonLLVMAndBuiltInMLIRTypes(MLIRContext *context) { | |||||
numHalfsInOpFrags.resize(4); | |||||
numHalfsInOpFrags[A] = 8; | |||||
numHalfsInOpFrags[B] = 8; | |||||
numHalfsInOpFrags[C] = 4; | |||||
numHalfsInOpFrags[D] = 4; | |||||
i32Ty = IntegerType::get(context, 32); | |||||
f16Ty = FloatType::getF16(context); | |||||
f32Ty = FloatType::getF32(context); | |||||
f16x2Ty = VectorType::get(2, f16Ty); | |||||
fragArrayABTy = LLVM::LLVMStructType::getLiteral( | |||||
context, SmallVector<Type>(8, f16x2Ty)); | |||||
fragArrayCDTy = LLVM::LLVMStructType::getLiteral( | |||||
context, SmallVector<Type>(4, f16x2Ty)); | |||||
fragArrayCDF32Ty = | |||||
LLVM::LLVMStructType::getLiteral(context, SmallVector<Type>(8, f32Ty)); | |||||
}; | |||||
Type i32Ty; | |||||
Type f16Ty; | |||||
Type f32Ty; | |||||
Type f16x2Ty; | |||||
/// Type for the fragment of A and B operands that a single thread holds for | |||||
/// fp16 data type in a WMMA operation of the form D = (alpha*(A*B)) + | |||||
/// (beta*C). | |||||
Type fragArrayABTy; | |||||
/// Type for the fragment of C and D operands that a single thread holds for | |||||
/// fp16 data type in a WMMA operation of the form D = (alpha*(A*B)) + | |||||
/// (beta*C). | |||||
Type fragArrayCDTy; | |||||
/// Type for the fragment of C and D operands that a single thread holds for | |||||
/// fp32 data type in a WMMA operation of the form D = (alpha*(A*B)) + | |||||
/// (beta*C). | |||||
Type fragArrayCDF32Ty; | |||||
/// Represents the number of f16 elements a single thread holds in a WMMA | |||||
/// operation of the form D = (alpha*(A*B)) + (beta*C) . | |||||
SmallVector<unsigned, 4> numHalfsInOpFrags; | |||||
/// Represents the operands of a MMA operation of the form D = (alpha*(A*B)) + | |||||
The context here isn't clear as to operands to which op. Mention about mma/wmma when referring to fragments? bondhugula: The context here isn't clear as to operands to which op. Mention about mma/wmma when referring… | |||||
/// (beta*C). | |||||
enum OperandMap { A, B, C, D }; | |||||
}; | |||||
} // namespace mlir | |||||
#endif | |||||
Doc comments for these two. bondhugula: Doc comments for these two. |
Headers need to have -*- C++ -*- at the end of the first line