File: amx_api.c

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-16
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,368 kB
  • sloc: cpp: 5,593,980; ansic: 986,873; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,547; xml: 953; cs: 573; fortran: 567
file content (97 lines) | stat: -rw-r--r-- 3,249 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// RUN: %clang_cc1 %s -flax-vector-conversions=none -ffreestanding -triple=x86_64-unknown-unknown  -target-feature +avx512f  -target-feature +amx-int8  \
// RUN: -target-feature +amx-bf16 -emit-llvm -o - -Werror -pedantic | FileCheck %s --check-prefixes=CHECK

#include <immintrin.h>

char buf[1024];
#define STRIDE 32

char buf2[1024];

// This is an example code and integration test.
void test_api(int cond, short row, short col) {
  //CHECK-LABEL: @test_api
  //CHECK: call x86_amx @llvm.x86.tileloadd64.internal
  //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
  //CHECK: call void @llvm.x86.tilestored64.internal
  __tile1024i a = {row, 8};
  __tile1024i b = {8, col};
  __tile1024i c = {row, col};

  if (cond) {
    __tile_loadd(&a, buf, STRIDE);
    __tile_loadd(&b, buf, STRIDE);
    __tile_loadd(&c, buf, STRIDE);
  } else {
    __tile_loadd(&a, buf2, STRIDE);
    __tile_loadd(&b, buf2, STRIDE);
    __tile_loadd(&c, buf2, STRIDE);
  }
  __tile_dpbssd(&c, a, b);
  __tile_stored(buf, STRIDE, c);
}

void test_tile_loadd(short row, short col) {
  //CHECK-LABEL: @test_tile_loadd
  //CHECK: call x86_amx @llvm.x86.tileloadd64.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile1024i a = {row, col};
  __tile_loadd(&a, buf, STRIDE);
}

void test_tile_stream_loadd(short row, short col) {
  //CHECK-LABEL: @test_tile_stream_loadd
  //CHECK: call x86_amx @llvm.x86.tileloaddt164.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile1024i a = {row, col};
  __tile_stream_loadd(&a, buf, STRIDE);
}

void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
  //CHECK-LABEL: @test_tile_dpbssd
  //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_dpbssd(&c, a, b);
}

void test_tile_dpbsud(__tile1024i a, __tile1024i b, __tile1024i c) {
  //CHECK-LABEL: @test_tile_dpbsud
  //CHECK: call x86_amx @llvm.x86.tdpbsud.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_dpbsud(&c, a, b);
}

void test_tile_dpbusd(__tile1024i a, __tile1024i b, __tile1024i c) {
  //CHECK-LABEL: @test_tile_dpbusd
  //CHECK: call x86_amx @llvm.x86.tdpbusd.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_dpbusd(&c, a, b);
}

void test_tile_dpbuud(__tile1024i a, __tile1024i b, __tile1024i c) {
  //CHECK-LABEL: @test_tile_dpbuud
  //CHECK: call x86_amx @llvm.x86.tdpbuud.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_dpbuud(&c, a, b);
}

void test_tile_stored(__tile1024i c) {
  //CHECK-LABEL: @test_tile_stored
  //CHECK: {{%.*}} = bitcast <256 x i32> {{%.*}} to x86_amx
  //CHECK-NEXT: call void @llvm.x86.tilestored64.internal
  __tile_stored(buf, STRIDE, c);
}

void test_tile_zero(__tile1024i c) {
  //CHECK-LABEL: @test_tile_zero
  //CHECK: call x86_amx @llvm.x86.tilezero.internal
  //CHECK-NEXT bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_zero(&c);
}

void test_tile_dpbf16ps(__tile1024i a, __tile1024i b, __tile1024i c) {
  //CHECK-LABEL: @test_tile_dpbf16ps
  //CHECK: call x86_amx @llvm.x86.tdpbf16ps.internal
  //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
  __tile_dpbf16ps(&a, b, c);
}