2021-07-02 14:41:38 -07:00
|
|
|
/* Copyright (c) 2009 - 2021 Advanced Micro Devices, Inc.
|
2020-02-04 09:26:14 -08:00
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE. */
|
|
|
|
|
|
2016-07-21 12:41:26 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include "rocprogram.hpp"
|
|
|
|
|
#include "top.hpp"
|
|
|
|
|
#include "rocprintf.hpp"
|
|
|
|
|
|
2024-06-06 18:40:49 +01:00
|
|
|
namespace amd::roc {
|
2016-07-21 12:41:26 -04:00
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
class Kernel : public device::Kernel {
|
2025-01-22 14:47:02 -05:00
|
|
|
public:
|
|
|
|
|
Kernel(std::string name, Program* prog) : device::Kernel(prog->device(), name, *prog) {}
|
2025-01-17 22:22:05 +00:00
|
|
|
|
2025-01-22 14:47:02 -05:00
|
|
|
virtual ~Kernel() {
|
|
|
|
|
if (program() != nullptr) {
|
|
|
|
|
// Add kernel to the map of all kernels on the device
|
|
|
|
|
program()->rocDevice().RemoveKernel(*this);
|
2025-01-17 22:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
//! Initializes the metadata required for this kernel
|
2025-01-22 14:47:02 -05:00
|
|
|
virtual bool init() final;
|
|
|
|
|
|
|
|
|
|
//! Setup after code object loading
|
|
|
|
|
bool postLoad();
|
2017-04-13 13:56:38 -04:00
|
|
|
|
2019-04-09 23:24:10 -04:00
|
|
|
const Program* program() const { return static_cast<const Program*>(&prog_); }
|
2025-01-17 22:22:05 +00:00
|
|
|
|
2025-01-22 14:47:02 -05:00
|
|
|
//! Pull demangled name, used only for logging
|
2025-01-17 22:22:05 +00:00
|
|
|
const std::string& getDemangledName() {
|
2025-11-23 08:45:45 +00:00
|
|
|
std::call_once(demangle_once_, [this] {
|
2025-08-17 02:33:31 -04:00
|
|
|
amd::Os::CxaDemangle(name(), &demangled_name_);
|
2025-11-23 08:45:45 +00:00
|
|
|
});
|
|
|
|
|
return demangled_name_;
|
2017-11-10 16:21:49 -05:00
|
|
|
}
|
2019-04-09 23:24:10 -04:00
|
|
|
|
2025-01-22 14:47:02 -05:00
|
|
|
std::string demangled_name_; //!< Cache demangled name
|
2025-11-23 08:45:45 +00:00
|
|
|
std::once_flag demangle_once_;
|
2017-11-10 16:21:49 -05:00
|
|
|
};
|
|
|
|
|
|
2024-06-06 18:40:49 +01:00
|
|
|
} // namespace amd::roc
|
2016-07-21 12:41:26 -04:00
|
|
|
|