CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
153 lines
5.3 KiB
C++
153 lines
5.3 KiB
C++
//===- AtomicOps.cpp - MLIR SPIR-V Atomic Ops ----------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Defines the atomic operations in the SPIR-V dialect.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
|
|
|
|
#include "SPIRVOpUtils.h"
|
|
#include "SPIRVParsingUtils.h"
|
|
|
|
using namespace mlir::spirv::AttrNames;
|
|
|
|
namespace mlir::spirv {
|
|
|
|
template <typename T>
|
|
static StringRef stringifyTypeName();
|
|
|
|
template <>
|
|
StringRef stringifyTypeName<IntegerType>() {
|
|
return "integer";
|
|
}
|
|
|
|
template <>
|
|
StringRef stringifyTypeName<FloatType>() {
|
|
return "float";
|
|
}
|
|
|
|
// Verifies an atomic update op.
|
|
template <typename AtomicOpTy, typename ExpectedElementType>
|
|
static LogicalResult verifyAtomicUpdateOp(Operation *op) {
|
|
auto ptrType = cast<spirv::PointerType>(op->getOperand(0).getType());
|
|
auto elementType = ptrType.getPointeeType();
|
|
if (!isa<ExpectedElementType>(elementType))
|
|
return op->emitOpError() << "pointer operand must point to an "
|
|
<< stringifyTypeName<ExpectedElementType>()
|
|
<< " value, found " << elementType;
|
|
|
|
StringAttr semanticsAttrName =
|
|
AtomicOpTy::getSemanticsAttrName(op->getName());
|
|
auto memorySemantics =
|
|
op->getAttrOfType<spirv::MemorySemanticsAttr>(semanticsAttrName)
|
|
.getValue();
|
|
if (failed(verifyMemorySemantics(op, memorySemantics))) {
|
|
return failure();
|
|
}
|
|
return success();
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicAndOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicAndOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicAndOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicIAddOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicIAddOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicIAddOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.EXT.AtomicFAddOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult EXTAtomicFAddOp::verify() {
|
|
return verifyAtomicUpdateOp<EXTAtomicFAddOp, FloatType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicIDecrementOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicIDecrementOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicIDecrementOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicIIncrementOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicIIncrementOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicIIncrementOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicISubOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicISubOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicISubOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicOrOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicOrOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicOrOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicSMaxOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicSMaxOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicSMaxOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicSMinOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicSMinOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicSMinOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicUMaxOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicUMaxOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicUMaxOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicUMinOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicUMinOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicUMinOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// spirv.AtomicXorOp
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
LogicalResult AtomicXorOp::verify() {
|
|
return verifyAtomicUpdateOp<AtomicXorOp, IntegerType>(getOperation());
|
|
}
|
|
|
|
} // namespace mlir::spirv
|