Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions tools/clang/unittests/HLSLExec/LinAlgTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ class DxilConf_SM610_LinAlg {
// Load/Store/Accumulate Descriptor
TEST_METHOD(LoadStoreDescriptor_Wave_16x16_F16);
TEST_METHOD(SplatStore_Wave_16x16_F16);
TEST_METHOD(SplatStorePublicAPI_Wave_16x16_F16);
TEST_METHOD(AccumulateDescriptor_Wave_16x16_F16);

// Load/Store/Accumulate Memory
Expand Down Expand Up @@ -505,10 +506,31 @@ static const char SplatStoreShader[] = R"(
}
)";

static const char SplatStorePublicAPIShader[] = R"(
#include <dx/linalg.h>
using namespace dx::linalg;

RWByteAddressBuffer Output : register(u0);

using MatrixTy =
Matrix<ComponentType::F16, M_DIM, N_DIM, MatrixUse::Accumulator,
MatrixScope::Wave>;

[WaveSize(4, 64)]
[numthreads(NUMTHREADS, 1, 1)]
void main() {
if (GetGroupWaveIndex() != 0)
return;

MatrixTy Mat = MatrixTy::Splat(FILL_VALUE);
Mat.Store(Output, 0, STRIDE, MatrixLayoutEnum::RowMajor, 128);
}
)";

static void runSplatStore(ID3D12Device *Device,
dxc::SpecificDllLoader &DxcSupport,
const MatrixParams &Params, float FillValue,
bool Verbose) {
bool Verbose, LPCSTR Shader = SplatStoreShader) {
const size_t NumElements = Params.totalElements();
const size_t BufferSize = Params.totalBytes();

Expand All @@ -517,13 +539,12 @@ static void runSplatStore(ID3D12Device *Device,

std::string Args = buildCompilerArgs(Params, ExtraDefs.str().c_str());

compileShader(DxcSupport, SplatStoreShader, "cs_6_10", Args, Verbose);
compileShader(DxcSupport, Shader, "cs_6_10", Args, Verbose);

auto Expected =
makeExpectedMat(Params.CompType, Params.M, Params.N, FillValue, false);

auto Op =
createComputeOp(SplatStoreShader, "cs_6_10", "UAV(u0)", Args.c_str());
auto Op = createComputeOp(Shader, "cs_6_10", "UAV(u0)", Args.c_str());
addUAVBuffer(Op.get(), "Output", BufferSize, true);
addRootView(Op.get(), 0, "Output");

Expand All @@ -549,6 +570,20 @@ void DxilConf_SM610_LinAlg::SplatStore_Wave_16x16_F16() {
runSplatStore(D3DDevice, DxcSupport, Params, 42.0f, VerboseLogging);
}

void DxilConf_SM610_LinAlg::SplatStorePublicAPI_Wave_16x16_F16() {
MatrixParams Params = {};
Params.CompType = ComponentType::F16;
Params.M = 16;
Params.N = 16;
Params.Use = MatrixUse::Accumulator;
Params.Scope = MatrixScope::Wave;
Params.Layout = LinalgMatrixLayout::RowMajor;
Params.NumThreads = 64;
Params.Enable16Bit = true;
runSplatStore(D3DDevice, DxcSupport, Params, 42.0f, VerboseLogging,
SplatStorePublicAPIShader);
}

static const char AccumulateDescriptorShader[] = R"(
#define USE_ACC 2

Expand Down
Loading