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
90 lines
2.3 KiB
Plaintext
90 lines
2.3 KiB
Plaintext
// Copyright (c) Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
A instruction mix exerciser example, written by Gina Sitaraman and Nicholas Curtis [AMD].
|
|
Although inline assembly is inherently unportable, this is expected to work on all CDNA accelerators.
|
|
*/
|
|
|
|
#include "common.h"
|
|
|
|
__global__ void kernelasm() {
|
|
// int32
|
|
int i, j;
|
|
asm volatile("v_add_u32_e32 %0, %1, %0\n" : "=v"(j) : "v"(i));
|
|
|
|
// int 64
|
|
long int l1, l2;
|
|
asm volatile("v_cmp_eq_i64 %0, %1\n" : "=v"(l2) : "v"(l1), "v"(i));
|
|
|
|
// fp32: add, mul, transcendental and fma
|
|
float f1, f2;
|
|
asm volatile(
|
|
"v_add_f32_e32 %0, %1, %0\n"
|
|
"v_mul_f32_e32 %0, %1, %0\n"
|
|
"v_sqrt_f32 %0, %1\n"
|
|
"v_fma_f32 %0, %1, %0, %1\n"
|
|
: "=v"(f1)
|
|
: "v"(f2));
|
|
|
|
// fp64: add, mul, transcendental and fma
|
|
double d1, d2, d3, d4;
|
|
asm volatile(
|
|
"v_add_f64 %0, %1, %0\n"
|
|
"v_mul_f64 %0, %1, %0\n"
|
|
"v_fma_f64 %0, %1, %0, %1\n"
|
|
"v_sqrt_f64 %0, %1\n"
|
|
"v_min_f64 %0, %1, %0\n"
|
|
: "+v"(d1)
|
|
: "v"(d2));
|
|
|
|
// fp16: add, mul, transcendental and fma
|
|
_Float16 h1, h2;
|
|
asm volatile(
|
|
"v_add_f16_e32 %0, %1, %0\n"
|
|
"v_mul_f16_e32 %0, %1, %0\n"
|
|
"v_sqrt_f16 %0, %1\n"
|
|
"v_cvt_f16_f32 %0 %2\n"
|
|
"v_fma_f16 %0, %1, %0, %0\n"
|
|
: "=v"(h2)
|
|
: "v"(h1), "v"(f1));
|
|
|
|
// MFMA ops
|
|
double2 dd;
|
|
unsigned short us;
|
|
long2 ll;
|
|
#if defined(__gfx90a__)
|
|
asm volatile("v_mfma_f64_4x4x4f64 %0 %1 %2 %3\n"
|
|
: "=v"(d4)
|
|
: "v"(d1), "v"(d2), "v"(d3));
|
|
asm volatile("v_mfma_f32_16x16x4f32 %0 %1 %2 1\n"
|
|
: "=v"(dd)
|
|
: "v"(f1), "v"(f2));
|
|
asm volatile("v_mfma_f32_16x16x16f16 %0 %1 %2 1\n"
|
|
: "=v"(dd)
|
|
: "v"(d1), "v"(d2));
|
|
asm volatile("v_mfma_f32_16x16x8bf16 %0 %1 %2 1\n"
|
|
: "=v"(dd)
|
|
: "v"(f1), "v"(f2));
|
|
asm volatile("v_mfma_i32_16x16x16i8 %0 %1 %2 1\n"
|
|
: "=v"(ll)
|
|
: "v"(i), "v"(j));
|
|
#endif
|
|
|
|
// Scalar op
|
|
asm volatile("s_add_i32 %0 %1 %0\n" : "=s"(j) : "s"(i));
|
|
|
|
// LDS
|
|
asm volatile("ds_read_b32 %0 %0\n" : "=v"(i) : "v"(j));
|
|
|
|
// Branch
|
|
asm volatile(
|
|
"s_branch .LDUMMY\n"
|
|
".LDUMMY:\n"
|
|
"s_endpgm\n");
|
|
}
|
|
int main() {
|
|
kernelasm<<<1, 64>>>();
|
|
hipCheck(hipDeviceSynchronize());
|
|
}
|