SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committad av
GitHub
förälder
5840940caa
incheckning
f7338717ae
@@ -35,67 +35,67 @@ THE SOFTWARE.
|
||||
#define kernel_name "hello_world"
|
||||
|
||||
int main() {
|
||||
float *A, *B;
|
||||
hipDeviceptr_t Ad, Bd;
|
||||
A = new float[LEN];
|
||||
B = new float[LEN];
|
||||
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;
|
||||
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));
|
||||
|
||||
struct {
|
||||
void* _Ad;
|
||||
void* _Bd;
|
||||
} args;
|
||||
|
||||
args._Ad = (void*)Ad;
|
||||
args._Bd = (void*)Bd;
|
||||
|
||||
size_t size = sizeof(args);
|
||||
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
|
||||
checkHipErrors(hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
hipInit(0);
|
||||
hipDevice_t device;
|
||||
hipCtx_t context;
|
||||
checkHipErrors(hipDeviceGet(&device, 0));
|
||||
checkHipErrors(hipCtxCreate(&context, 0, device));
|
||||
if (mismatchCount == 0) {
|
||||
std::cout << "PASSED!\n";
|
||||
} else {
|
||||
std::cout << "FAILED!\n";
|
||||
};
|
||||
|
||||
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));
|
||||
|
||||
struct {
|
||||
void* _Ad;
|
||||
void* _Bd;
|
||||
} args;
|
||||
|
||||
args._Ad = (void*) Ad;
|
||||
args._Bd = (void*) Bd;
|
||||
|
||||
size_t size = sizeof(args);
|
||||
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
|
||||
checkHipErrors(hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config));
|
||||
|
||||
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));
|
||||
hipFree(Bd);
|
||||
delete[] A;
|
||||
delete[] B;
|
||||
checkHipErrors(hipCtxDestroy(context));
|
||||
return 0;
|
||||
checkHipErrors(hipFree(Ad));
|
||||
hipFree(Bd);
|
||||
delete[] A;
|
||||
delete[] B;
|
||||
checkHipErrors(hipCtxDestroy(context));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Referens i nytt ärende
Block a user