Open3D (C++ API)  0.20.0
Loading...
Searching...
No Matches
GemmCUDA.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2026 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8// Column-major GEMM shim for the CUDA conv ops, matching the calling
9// convention of GemmSYCL.h's GemmColumnMajorSYCL<LA,LB>():
10// D = alpha * A * B + beta * C
11// with A(MxK), B(KxN), C/D(MxN) all column-major (C and D are the same buffer
12// — accumulate in place — matching existing Open3D CUDA conv usage).
13//
14// Backend: CUTLASS v4.2.1 device::Gemm (v2-compatibility shim, kept in v4).
15// - OperatorClass: OpClassSimt (SIMT FP32; no Tensor Cores, no alignment req).
16// - ArchTag: Sm86. This is NOT an Ampere-specific optimization — CUTLASS's
17// OpClassSimt tile defaults (128x128x8, 2 stages) are the same for every
18// ArchTag, so any tag from the SIMT-supporting range would compile to
19// identical device code. Sm86 is used purely as an arbitrary-but-safe
20// placeholder satisfying CUTLASS's template requirement for *some* ArchTag;
21// the actual PTX target arch is set separately via nvcc's -arch flag, which
22// is what determines which GPUs the kernel can run on.
23// The calling .cuh files previously instantiated this Gemm type inline; this
24// shim moves it here so the call sites mirror the GemmColumnMajorSYCL pattern.
25
26#pragma once
27
28#include <cuda_runtime_api.h>
29#include <cutlass/arch/arch.h>
30#include <cutlass/gemm/device/gemm.h>
31#include <cutlass/layout/matrix.h>
32
33#include <stdexcept>
34
35namespace open3d {
36namespace ml {
37namespace impl {
38
42template <class LayoutA = cutlass::layout::ColumnMajor,
43 class LayoutB = cutlass::layout::ColumnMajor>
44void GemmColumnMajorCUDA(const cudaStream_t& stream,
45 int m,
46 int n,
47 int k,
48 float alpha,
49 const float* A,
50 int lda,
51 const float* B,
52 int ldb,
53 float beta,
54 float* C,
55 int ldc) {
56 // OpClassSimt: SIMT FP32 — no alignment requirement (lda/ldb need not be
57 // multiples of 4), so it works with arbitrary channel/kernel counts.
58 // Sm86 is an arbitrary-but-safe ArchTag; OpClassSimt's tile defaults
59 // (128x128x8, 2 stages) don't vary by ArchTag (see file header).
60 using Gemm = cutlass::gemm::device::Gemm<
61 float, LayoutA, float, LayoutB, float, cutlass::layout::ColumnMajor,
62 float, // accumulator
63 cutlass::arch::OpClassSimt, cutlass::arch::Sm86>;
64 Gemm gemm_op;
65 cutlass::Status status = gemm_op(
66 {{m, n, k}, {A, lda}, {B, ldb}, {C, ldc}, {C, ldc}, {alpha, beta}},
67 nullptr, stream);
68 if (status != cutlass::Status::kSuccess) {
69 throw std::runtime_error("CUTLASS GEMM failed.");
70 }
71}
72
73} // namespace impl
74} // namespace ml
75} // namespace open3d
Eigen::Matrix3d B
Definition PointCloudPlanarPatchDetection.cpp:523
void GemmColumnMajorCUDA(const cudaStream_t &stream, int m, int n, int k, float alpha, const float *A, int lda, const float *B, int ldb, float beta, float *C, int ldc)
Definition GemmCUDA.h:44
Definition PinholeCameraIntrinsic.cpp:16