Files
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

137 lines
5.0 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <rocRoller/Context_fwd.hpp>
#include <rocRoller/GPUArchitecture/GPUArchitectureTarget.hpp>
#include <rocRoller/KernelArguments.hpp>
#include <rocRoller/Utilities/HIPTimer.hpp>
namespace rocRoller
{
// KernelInvocation contains the information needed to launch a kernel with
// the ExecutableKernel class.
struct KernelInvocation
{
std::array<unsigned int, 3> workitemCount = {1, 1, 1};
std::array<unsigned int, 3> workgroupSize = {1, 1, 1};
unsigned int sharedMemBytes = 0;
std::optional<std::array<unsigned int, 3>> workgroupClusterSize;
};
// The executer class can load a kernel from a string of machine code and
// then launch the kernel on a GPU.
class ExecutableKernel
{
public:
explicit ExecutableKernel(GPUArchitectureTarget target);
~ExecutableKernel() = default;
/**
* kernelLoaded returns true if a kernel has already been loaded.
*
* @return bool
*/
bool kernelLoaded() const;
/**
* @brief Loads a kernel from a string of machine code.
*
* @param instructions A string containing an entire assembly file
* @param target The target architecture
* @param kernelName The name of the kernel
*/
void loadKernel(std::string const& instructions,
const GPUArchitectureTarget& target,
std::string const& kernelName);
/**
* @brief Loads a kernel from a file.
*
* @param fileName Assembly file name
* @param kernelName The name of the kernel
* @param target The target architecture
*/
void loadKernelFromFile(std::string const& fileName,
std::string const& kernelName,
const GPUArchitectureTarget& target);
/**
* @brief Loads a kernel from a file.
*
* @param fileName Code-object file name
* @param kernelName The name of the kernel
* @param target The target architecture
*/
void loadKernelFromCodeObjectFile(std::string const& fileName,
std::string const& kernelName,
const GPUArchitectureTarget& target);
/**
* @brief Loads a kernel from a string of machine code.
*
* @param instructions A string containing an entire assembly file
* @param target The target architecture
* @param kernelName The name of the kernel
*/
void loadKernel(std::string const& instructions, ContextPtr context);
/**
* @brief Execute a kernel on a GPU.
*
* @param args The arguments to the Kernel
* @param invocation Other information needed to launch the kernel.
* @param timer HIPTimer that will record how long the kernel took to execute
* @param iteration Iteration number within the timer
*/
void executeKernel(const KernelArguments& args,
const KernelInvocation& invocation,
std::shared_ptr<HIPTimer> timer,
int iteration);
/**
* @brief Execute a kernel on a GPU with stream specified
*
* @param args The arguments to the Kernel
* @param invocation Other information needed to launch the kernel.
* @param stream The stream the kernel is executed on
*/
void executeKernel(const KernelArguments& args,
const KernelInvocation& invocation,
hipStream_t stream = 0);
/**
* @brief Returns the hipFunction for the kernel
*/
hipFunction_t getHipFunction() const;
private:
struct HIPData;
std::string m_kernelName;
bool m_kernelLoaded;
std::shared_ptr<HIPData> m_hipData;
GPUArchitectureTarget m_target;
/**
* @brief Execute a kernel on a GPU with optional timer and stream
*
* @param args The arguments to the Kernel
* @param invocation Other information needed to launch the kernel.
* @param timer HIPTimer that will record how long the kernel took to execute
* @param iteration Iteration number within the timer
* @param stream The stream the kernel is executed on
*/
void executeKernel(const KernelArguments& args,
const KernelInvocation& invocation,
std::shared_ptr<HIPTimer> timer,
int iteration,
hipStream_t stream);
};
}
#include <rocRoller/ExecutableKernel_impl.hpp>