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
114 lines
2.5 KiB
C++
114 lines
2.5 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include <hip_test_common.hh>
|
|
#include <hip_test_kernels.hh>
|
|
#include <hip_test_checkers.hh>
|
|
#include <cfloat>
|
|
#include <atomic>
|
|
#include "./defs.h"
|
|
|
|
static __device__ int* deviceAlloc(int test_type);
|
|
static __device__ void deviceWrite(int myId, int* devmem);
|
|
static __device__ void deviceFree(int* outputBuf, int* devmem, int test_type, int myId);
|
|
|
|
/**
|
|
* Allocation base and derived class to test dynamic allocation.
|
|
*/
|
|
class baseAlloc {
|
|
public:
|
|
virtual __device__ int* alloc(size_t size) = 0;
|
|
virtual __device__ void free(int* ptr) = 0;
|
|
};
|
|
|
|
class derivedAlloc : public baseAlloc {
|
|
public:
|
|
virtual __device__ int* alloc(size_t size) { return new int[size]; }
|
|
virtual __device__ void free(int* ptr) { delete ptr; }
|
|
};
|
|
|
|
/**
|
|
* Allocation Structure to test dynamic allocation.
|
|
*/
|
|
struct deviceAllocFunc {
|
|
int* (*alloc)(int);
|
|
void (*write)(int, int*);
|
|
void (*free)(int*, int*, int, int);
|
|
};
|
|
|
|
/**
|
|
* Simple Structure to test dynamic allocation.
|
|
*/
|
|
struct simpleStruct {
|
|
int32_t i;
|
|
double d;
|
|
float f;
|
|
int16_t s;
|
|
char c;
|
|
int32_t iarr[INTERNAL_BUFFER_SIZE];
|
|
bool operator!=(const struct simpleStruct& inpStr) {
|
|
if ((i != inpStr.i) || (d != inpStr.d) || (f != inpStr.f) || (s != inpStr.s) ||
|
|
(c != inpStr.c)) {
|
|
return true;
|
|
}
|
|
for (int32_t idx = 0; idx < INTERNAL_BUFFER_SIZE; idx++) {
|
|
if (iarr[idx] != inpStr.iarr[idx]) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Simple Structure containing thread information
|
|
*/
|
|
struct threadInfo {
|
|
int threadid;
|
|
int blockid;
|
|
int32_t ival;
|
|
double dval;
|
|
float fval;
|
|
int16_t sval;
|
|
char cval;
|
|
};
|
|
|
|
/**
|
|
* C/C++ Union
|
|
*/
|
|
union testInfoUnion {
|
|
int32_t ival;
|
|
double dval;
|
|
float fval;
|
|
int16_t sval;
|
|
char cval;
|
|
};
|
|
|
|
/**
|
|
* Complex (nested) Structure to test dynamic allocation using malloc.
|
|
*/
|
|
struct complexStructure {
|
|
struct threadInfo* sthreadInfo;
|
|
__device__ void alloc_internal_members(int test_type, size_t size) {
|
|
sthreadInfo = nullptr;
|
|
if (test_type == TEST_MALLOC_FREE) {
|
|
sthreadInfo = reinterpret_cast<struct threadInfo*>(malloc(size * sizeof(struct threadInfo)));
|
|
} else {
|
|
sthreadInfo = new struct threadInfo[size];
|
|
}
|
|
}
|
|
|
|
__device__ void free_internal_members(int test_type) {
|
|
if (test_type == TEST_MALLOC_FREE) {
|
|
free(sthreadInfo);
|
|
} else {
|
|
delete[] sthreadInfo;
|
|
}
|
|
sthreadInfo = nullptr;
|
|
}
|
|
};
|