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
73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "hip/hip_runtime.h"
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <vector>
|
|
#include "hip_helper.h"
|
|
|
|
#define LEN 64
|
|
#define SIZE LEN << 2
|
|
|
|
#define fileName "vcpy_kernel.code"
|
|
#define kernel_name "hello_world"
|
|
|
|
int main() {
|
|
float *A, *B;
|
|
hipDeviceptr_t Ad, Bd;
|
|
A = new float[LEN];
|
|
B = new float[LEN];
|
|
|
|
for (uint32_t i = 0; i < LEN; i++) {
|
|
A[i] = i * 1.0f;
|
|
B[i] = 0.0f;
|
|
}
|
|
|
|
hipInit(0);
|
|
hipDevice_t device;
|
|
hipCtx_t context;
|
|
checkHipErrors(hipDeviceGet(&device, 0));
|
|
checkHipErrors(hipCtxCreate(&context, 0, device));
|
|
|
|
checkHipErrors(hipMalloc((void**)&Ad, SIZE));
|
|
checkHipErrors(hipMalloc((void**)&Bd, SIZE));
|
|
|
|
checkHipErrors(hipMemcpyHtoD(Ad, A, SIZE));
|
|
checkHipErrors(hipMemcpyHtoD(Bd, B, SIZE));
|
|
|
|
hipModule_t Module;
|
|
hipFunction_t Function;
|
|
checkHipErrors(hipModuleLoad(&Module, fileName));
|
|
checkHipErrors(hipModuleGetFunction(&Function, Module, kernel_name));
|
|
|
|
void* args[2] = {&Ad, &Bd};
|
|
|
|
checkHipErrors(hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, args, nullptr));
|
|
|
|
checkHipErrors(hipMemcpyDtoH(B, Bd, SIZE));
|
|
int mismatchCount = 0;
|
|
for (uint32_t i = 0; i < LEN; i++) {
|
|
if (A[i] != B[i]) {
|
|
mismatchCount++;
|
|
std::cout << "error: mismatch " << A[i] << " != " << B[i] << std::endl;
|
|
}
|
|
}
|
|
|
|
if (mismatchCount == 0) {
|
|
std::cout << "PASSED!\n";
|
|
} else {
|
|
std::cout << "FAILED!\n";
|
|
};
|
|
|
|
checkHipErrors(hipFree(Ad));
|
|
checkHipErrors(hipFree(Bd));
|
|
delete[] A;
|
|
delete[] B;
|
|
checkHipErrors(hipCtxDestroy(context));
|
|
return 0;
|
|
}
|