SWDEV-326382 - Determine gpu architecture during hipRTC compilation
hipRTC should be able to fetch the arch name even if
the app doesnt specify the architecture in the options
Change-Id: I464dbb3357a6f7e010f10b03a45051f23bdadb28
[ROCm/clr commit: db003b65d0]
This commit is contained in:
committed by
Maneesh Gupta
orang tua
c586965e36
melakukan
57bb2544ff
@@ -127,6 +127,58 @@ bool RTCProgram::addBuiltinHeader() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTCProgram::findIsa() {
|
||||
const char* libName;
|
||||
#ifdef _WIN32
|
||||
libName = "libamdhip64.dll";
|
||||
#else
|
||||
libName = "libamdhip64.so";
|
||||
#endif
|
||||
|
||||
void* handle = amd::Os::loadLibrary(libName);
|
||||
|
||||
if (!handle) {
|
||||
LogInfo("hip runtime failed to load using dlopen");
|
||||
buildLog +=
|
||||
"Error: Please provide architecture for which code is to be "
|
||||
"generated.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
void* sym_hipGetDevice = amd::Os::getSymbol(handle, "hipGetDevice");
|
||||
void* sym_hipGetDeviceProperties = amd::Os::getSymbol(handle, "hipGetDeviceProperties");
|
||||
|
||||
if (sym_hipGetDevice == nullptr || sym_hipGetDeviceProperties == nullptr) {
|
||||
LogInfo("ISA cannot be found to dlsym failure");
|
||||
buildLog +=
|
||||
"Error: Please provide architecture for which code is to be "
|
||||
"generated.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
hipError_t (*dyn_hipGetDevice)(int*) = reinterpret_cast
|
||||
<hipError_t (*)(int*)>(sym_hipGetDevice);
|
||||
|
||||
hipError_t (*dyn_hipGetDeviceProperties)(hipDeviceProp_t*, int) = reinterpret_cast
|
||||
<hipError_t (*)(hipDeviceProp_t*, int)>(sym_hipGetDeviceProperties);
|
||||
|
||||
int device;
|
||||
hipError_t status = dyn_hipGetDevice(&device);
|
||||
if (status != hipSuccess) {
|
||||
return false;
|
||||
}
|
||||
hipDeviceProp_t props;
|
||||
status = dyn_hipGetDeviceProperties(&props, device);
|
||||
if (status != hipSuccess) {
|
||||
return false;
|
||||
}
|
||||
isa = "amdgcn-amd-amdhsa--";
|
||||
isa.append(props.gcnArchName);
|
||||
|
||||
amd::Os::unloadLibrary(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTCProgram::transformOptions() {
|
||||
auto getValueOf = [](const std::string& option) {
|
||||
std::string res;
|
||||
@@ -165,10 +217,8 @@ bool RTCProgram::transformOptions() {
|
||||
settings.offloadArchProvided = true;
|
||||
return true;
|
||||
}
|
||||
buildLog +=
|
||||
"Error: Please provide architecture for which code is to be "
|
||||
"generated.\n";
|
||||
return false;
|
||||
// App has not provided the gpu archiecture, need to find it
|
||||
return findIsa();
|
||||
}
|
||||
|
||||
amd::Monitor RTCProgram::lock_("HIPRTC Program", true);
|
||||
|
||||
@@ -19,7 +19,7 @@ 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.
|
||||
*/
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include <hip/hiprtc.h>
|
||||
#include <hip/hip_version.h>
|
||||
|
||||
@@ -115,6 +115,7 @@ class RTCProgram {
|
||||
amd_comgr_data_set_t execInput;
|
||||
|
||||
bool dumpIsa();
|
||||
bool findIsa();
|
||||
|
||||
bool addSource_impl();
|
||||
bool addBuiltinHeader();
|
||||
|
||||
Reference in New Issue
Block a user