Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/rtc/bitcodebundle/bitcodebundle.cc
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

60 lines
1.7 KiB
C++

#include <hip/hiprtc.h>
#include <hip/hip_runtime.h>
#include <hip_test_common.hh>
#include <hip_test_filesystem.hh>
#include <cassert>
#include <cstddef>
#include <fstream>
#include <memory>
#include <iostream>
#include <iterator>
#include <vector>
#pragma clang diagnostic ignored "-Wuninitialized"
// Load pre-generated bundled bitcode file
std::vector<char> loadBundledBitcodeFile(const std::string& filepath) {
std::ifstream in(filepath, std::ios::binary);
if (!in) {
throw std::runtime_error("Failed to open bundled bitcode file: " + filepath);
}
std::vector<char> bundled_bc((std::istreambuf_iterator<char>(in)),
std::istreambuf_iterator<char>());
in.close();
if (bundled_bc.empty()) {
throw std::runtime_error("Bundled bitcode file is empty: " + filepath);
}
return bundled_bc;
}
TEST_CASE("Unit_RTC_BUNDLE_FROM_FILE") {
// Load pre-generated offload_bundle.hipfb from the build directory
std::string bundle_path = "offload_bundle.hipfb";
std::vector<char> bundled_bc = loadBundledBitcodeFile(bundle_path);
hiprtcLinkState linkstate;
HIPRTC_CHECK(hiprtcLinkCreate(0, nullptr, nullptr, &linkstate));
HIPRTC_CHECK(hiprtcLinkAddData(linkstate, HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE,
bundled_bc.data(), bundled_bc.size(),
"offload_bundle", 0, nullptr, nullptr));
void* finaldata;
size_t finalsize = 0;
HIPRTC_CHECK(hiprtcLinkComplete(linkstate, &finaldata, &finalsize));
hipModule_t module;
hipFunction_t kernel;
HIP_CHECK(hipModuleLoadData(&module, finaldata));
HIP_CHECK(hipModuleGetFunction(&kernel, module, "saxpy"));
HIPRTC_CHECK(hiprtcLinkDestroy(linkstate));
HIP_CHECK(hipModuleUnload(module));
}