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
84 lines
2.6 KiB
Plaintext
84 lines
2.6 KiB
Plaintext
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
|
|
|
// CHECK: #include <hip/hip_runtime.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
// CHECK: #include "hipblas.h"
|
|
#include "cublas.h"
|
|
#define M 6
|
|
#define N 5
|
|
#define IDX2C(i,j,ld) (((j)*(ld))+(i))
|
|
static __inline__ void modify(float* m, int ldm, int n, int p, int q, float
|
|
alpha, float beta) {
|
|
// CHECK-NOT: hipblasSscal(n - p, alpha, &m[IDX2C(p, q, ldm)], ldm);
|
|
// CHECK-NOT: hipblasSscal(ldm - p, beta, &m[IDX2C(p, q, ldm)], 1);
|
|
// CHECK: cublasSscal(n - p, alpha, &m[IDX2C(p, q, ldm)], ldm);
|
|
// CHECK: cublasSscal(ldm - p, beta, &m[IDX2C(p, q, ldm)], 1);
|
|
cublasSscal(n - p, alpha, &m[IDX2C(p, q, ldm)], ldm);
|
|
cublasSscal(ldm - p, beta, &m[IDX2C(p, q, ldm)], 1);
|
|
}
|
|
int main(void) {
|
|
int i, j;
|
|
// CHECK: hipblasStatus_t stat;
|
|
cublasStatus stat;
|
|
float* devPtrA;
|
|
float* a = 0;
|
|
a = (float*)malloc(M * N * sizeof(*a));
|
|
if (!a) {
|
|
printf("host memory allocation failed");
|
|
return EXIT_FAILURE;
|
|
}
|
|
for (j = 0; j < N; j++) {
|
|
for (i = 0; i < M; i++) {
|
|
a[IDX2C(i, j, M)] = (float)(i * M + j + 1);
|
|
}
|
|
}
|
|
// cublasInit is not supported yet
|
|
cublasInit();
|
|
// cublasAlloc is not supported yet
|
|
stat = cublasAlloc(M * N, sizeof(*a), (void**)&devPtrA);
|
|
// CHECK: if (stat != HIPBLAS_STATUS_SUCCESS) {
|
|
if (stat != CUBLAS_STATUS_SUCCESS) {
|
|
printf("device memory allocation failed");
|
|
// cublasShutdown is not supported yet
|
|
cublasShutdown();
|
|
return EXIT_FAILURE;
|
|
}
|
|
// CHECK: stat = hipblasSetMatrix(M, N, sizeof(*a), a, M, devPtrA, M);
|
|
stat = cublasSetMatrix(M, N, sizeof(*a), a, M, devPtrA, M);
|
|
// CHECK: if (stat != HIPBLAS_STATUS_SUCCESS) {
|
|
if (stat != CUBLAS_STATUS_SUCCESS) {
|
|
printf("data download failed");
|
|
// cublasFree is not supported yet
|
|
cublasFree(devPtrA);
|
|
// cublasShutdown is not supported yet
|
|
cublasShutdown();
|
|
return EXIT_FAILURE;
|
|
}
|
|
modify(devPtrA, M, N, 1, 2, 16.0f, 12.0f);
|
|
// CHECK: stat = hipblasGetMatrix(M, N, sizeof(*a), devPtrA, M, a, M);
|
|
stat = cublasGetMatrix(M, N, sizeof(*a), devPtrA, M, a, M);
|
|
// CHECK: if (stat != HIPBLAS_STATUS_SUCCESS) {
|
|
if (stat != CUBLAS_STATUS_SUCCESS) {
|
|
printf("data upload failed");
|
|
// cublasFree is not supported yet
|
|
cublasFree(devPtrA);
|
|
// cublasShutdown is not supported yet
|
|
cublasShutdown();
|
|
return EXIT_FAILURE;
|
|
}
|
|
// cublasFree is not supported yet
|
|
cublasFree(devPtrA);
|
|
// cublasShutdown is not supported yet
|
|
cublasShutdown();
|
|
for (j = 0; j < N; j++) {
|
|
for (i = 0; i < M; i++) {
|
|
printf("%7.0f", a[IDX2C(i, j, M)]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
free(a);
|
|
return EXIT_SUCCESS;
|
|
}
|