Leandro Lacerda 2abd58cb7e
[Offload] Add framework for math conformance tests (#149242)
This PR introduces the initial version of a C++ framework for the
conformance testing of GPU math library functions, building upon the
skeleton provided in #146391.

The main goal of this framework is to systematically measure the
accuracy of math functions in the GPU libc, verifying correctness or at
least conformance to standards like OpenCL via exhaustive or random
accuracy tests.
2025-07-29 11:08:27 -05:00

66 lines
1.9 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the implementation of helpers and non-template member
/// functions for the device resource classes.
///
//===----------------------------------------------------------------------===//
#include "mathtest/DeviceResources.hpp"
#include "mathtest/ErrorHandling.hpp"
#include <OffloadAPI.h>
using namespace mathtest;
//===----------------------------------------------------------------------===//
// Helpers
//===----------------------------------------------------------------------===//
void detail::freeDeviceMemory(void *Address) noexcept {
if (Address)
OL_CHECK(olMemFree(Address));
}
//===----------------------------------------------------------------------===//
// DeviceImage
//===----------------------------------------------------------------------===//
DeviceImage::~DeviceImage() noexcept {
if (Handle)
OL_CHECK(olDestroyProgram(Handle));
}
DeviceImage &DeviceImage::operator=(DeviceImage &&Other) noexcept {
if (this == &Other)
return *this;
if (Handle)
OL_CHECK(olDestroyProgram(Handle));
DeviceHandle = Other.DeviceHandle;
Handle = Other.Handle;
Other.DeviceHandle = nullptr;
Other.Handle = nullptr;
return *this;
}
DeviceImage::DeviceImage(DeviceImage &&Other) noexcept
: DeviceHandle(Other.DeviceHandle), Handle(Other.Handle) {
Other.DeviceHandle = nullptr;
Other.Handle = nullptr;
}
DeviceImage::DeviceImage(ol_device_handle_t DeviceHandle,
ol_program_handle_t Handle) noexcept
: DeviceHandle(DeviceHandle), Handle(Handle) {}