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
87 lines
2.7 KiB
C++
87 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <hip/hip_runtime.h>
|
|
|
|
static constexpr int N = 2 * 1024 * 1024;
|
|
static constexpr size_t NBYTES = N * sizeof(int);
|
|
|
|
#define HIP_CHECK(error) \
|
|
{ \
|
|
hipError_t localError = error; \
|
|
if ((localError != hipSuccess) && (localError != hipErrorPeerAccessAlreadyEnabled)) { \
|
|
printf("error: '%s'(%d) from %s at %s:%d\n", hipGetErrorString(localError), localError, \
|
|
#error, __FUNCTION__, __LINE__); \
|
|
return -1; \
|
|
} \
|
|
}
|
|
|
|
/**
|
|
* Used hipStreamLegacy in child process and copies H2H, H2D, D2D, D2H
|
|
*/
|
|
int main() {
|
|
constexpr int elementVal = 3456;
|
|
|
|
int* hostArr1 = new int[N];
|
|
if (hostArr1 == nullptr) {
|
|
std::cout << "Invalid hostArr1" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
hostArr1[i] = elementVal;
|
|
}
|
|
|
|
int* hostArr2 = new int[N];
|
|
if (hostArr2 == nullptr) {
|
|
std::cout << "Invalid hostArr2" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
int* devArr1 = nullptr;
|
|
HIP_CHECK(hipMalloc(&devArr1, NBYTES));
|
|
if (devArr1 == nullptr) {
|
|
std::cout << "Invalid devArr1" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
int* devArr2 = nullptr;
|
|
HIP_CHECK(hipMalloc(&devArr2, NBYTES));
|
|
if (devArr2 == nullptr) {
|
|
std::cout << "Invalid devArr2" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
int* hostArr3 = new int[N];
|
|
if (hostArr3 == nullptr) {
|
|
std::cout << "Invalid hostArr3" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
HIP_CHECK(hipMemcpyAsync(hostArr2, hostArr1, NBYTES, hipMemcpyHostToHost, hipStreamLegacy));
|
|
HIP_CHECK(hipMemcpyAsync(devArr1, hostArr2, NBYTES, hipMemcpyHostToDevice, hipStreamLegacy));
|
|
HIP_CHECK(hipMemcpyAsync(devArr2, devArr1, NBYTES, hipMemcpyDeviceToDevice, hipStreamLegacy));
|
|
HIP_CHECK(hipMemcpyAsync(hostArr3, devArr2, NBYTES, hipMemcpyDeviceToHost, hipStreamLegacy));
|
|
HIP_CHECK(hipStreamSynchronize(hipStreamLegacy));
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
if (hostArr3[i] != elementVal) {
|
|
std::cout << "At index : = " << i << " Got value : " << hostArr3[i]
|
|
<< " Expected value : " << elementVal << std::endl;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
delete[] hostArr1;
|
|
delete[] hostArr2;
|
|
HIP_CHECK(hipFree(devArr1));
|
|
HIP_CHECK(hipFree(devArr2));
|
|
delete[] hostArr3;
|
|
|
|
return 0;
|
|
}
|