P4 to Git Change 1720088 by gandryey@gera-w8 on 2018/12/13 14:29:40

SWDEV-162389 - Switch to dynamic COMGR load

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#181 edit
... //depot/stg/opencl/drivers/opencl/opencldefs#240 edit
... //depot/stg/opencl/drivers/opencl/runtime/build/Makefile.runtime#78 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/comgrctx.cpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/comgrctx.hpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#239 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#328 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#21 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#13 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#119 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#104 edit


[ROCm/clr commit: f33100cf45]
Bu işleme şunda yer alıyor:
foreman
2018-12-13 15:22:06 -05:00
ebeveyn eaea62656e
işleme 22892fad58
10 değiştirilmiş dosya ile 476 ekleme ve 108 silme
+70
Dosyayı Görüntüle
@@ -0,0 +1,70 @@
//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#if defined(USE_COMGR_LIBRARY)
#include "os/os.hpp"
#include "comgrctx.hpp"
namespace amd {
std::once_flag Comgr::initialized;
ComgrEntryPoints Comgr::cep_;
bool Comgr::is_ready_ = false;
bool Comgr::LoadLib() {
#if defined(COMGR_DYN_DLL)
static const char* ComgrLibName = LP64_SWITCH(WINDOWS_SWITCH("amdcomgr", "amdcomgr32"), "amdcomgr64");
cep_.handle = Os::loadLibrary(ComgrLibName);
if (nullptr == cep_.handle) {
return false;
}
#endif
GET_COMGR_SYMBOL(amd_comgr_get_version)
GET_COMGR_SYMBOL(amd_comgr_status_string)
GET_COMGR_SYMBOL(amd_comgr_get_isa_count)
GET_COMGR_SYMBOL(amd_comgr_get_isa_name)
GET_COMGR_SYMBOL(amd_comgr_get_isa_metadata)
GET_COMGR_SYMBOL(amd_comgr_create_data)
GET_COMGR_SYMBOL(amd_comgr_release_data)
GET_COMGR_SYMBOL(amd_comgr_get_data_kind)
GET_COMGR_SYMBOL(amd_comgr_set_data)
GET_COMGR_SYMBOL(amd_comgr_set_data_name)
GET_COMGR_SYMBOL(amd_comgr_get_data)
GET_COMGR_SYMBOL(amd_comgr_get_data_name)
GET_COMGR_SYMBOL(amd_comgr_get_data_isa_name)
GET_COMGR_SYMBOL(amd_comgr_get_data_metadata)
GET_COMGR_SYMBOL(amd_comgr_destroy_metadata)
GET_COMGR_SYMBOL(amd_comgr_create_data_set)
GET_COMGR_SYMBOL(amd_comgr_destroy_data_set)
GET_COMGR_SYMBOL(amd_comgr_data_set_add)
GET_COMGR_SYMBOL(amd_comgr_data_set_remove)
GET_COMGR_SYMBOL(amd_comgr_action_data_count)
GET_COMGR_SYMBOL(amd_comgr_action_data_get_data)
GET_COMGR_SYMBOL(amd_comgr_create_action_info)
GET_COMGR_SYMBOL(amd_comgr_destroy_action_info)
GET_COMGR_SYMBOL(amd_comgr_action_info_set_isa_name)
GET_COMGR_SYMBOL(amd_comgr_action_info_get_isa_name)
GET_COMGR_SYMBOL(amd_comgr_action_info_set_language)
GET_COMGR_SYMBOL(amd_comgr_action_info_get_language)
GET_COMGR_SYMBOL(amd_comgr_action_info_set_options)
GET_COMGR_SYMBOL(amd_comgr_action_info_get_options)
GET_COMGR_SYMBOL(amd_comgr_action_info_set_working_directory_path)
GET_COMGR_SYMBOL(amd_comgr_action_info_get_working_directory_path)
GET_COMGR_SYMBOL(amd_comgr_action_info_set_logging)
GET_COMGR_SYMBOL(amd_comgr_action_info_get_logging)
GET_COMGR_SYMBOL(amd_comgr_do_action)
GET_COMGR_SYMBOL(amd_comgr_get_metadata_kind)
GET_COMGR_SYMBOL(amd_comgr_get_metadata_string)
GET_COMGR_SYMBOL(amd_comgr_get_metadata_map_size)
GET_COMGR_SYMBOL(amd_comgr_iterate_map_metadata)
GET_COMGR_SYMBOL(amd_comgr_metadata_lookup)
GET_COMGR_SYMBOL(amd_comgr_get_metadata_list_size)
GET_COMGR_SYMBOL(amd_comgr_index_list_metadata)
GET_COMGR_SYMBOL(amd_comgr_iterate_symbols)
GET_COMGR_SYMBOL(amd_comgr_symbol_lookup)
GET_COMGR_SYMBOL(amd_comgr_symbol_get_info)
is_ready_ = true;
return true;
}
}
#endif
+262
Dosyayı Görüntüle
@@ -0,0 +1,262 @@
//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#pragma once
#include <mutex>
#if defined(USE_COMGR_LIBRARY)
#include "top.hpp"
#include "amd_comgr.h"
namespace amd {
typedef void (*t_amd_comgr_get_version)(size_t *major, size_t *minor);
typedef amd_comgr_status_t (*t_amd_comgr_status_string)(amd_comgr_status_t status, const char ** status_string);
typedef amd_comgr_status_t (*t_amd_comgr_get_isa_count)(size_t *count);
typedef amd_comgr_status_t (*t_amd_comgr_get_isa_name)(size_t index, const char **isa_name);
typedef amd_comgr_status_t (*t_amd_comgr_get_isa_metadata)(const char *isa_name, amd_comgr_metadata_node_t *metadata);
typedef amd_comgr_status_t (*t_amd_comgr_create_data)(amd_comgr_data_kind_t kind, amd_comgr_data_t *data);
typedef amd_comgr_status_t (*t_amd_comgr_release_data)(amd_comgr_data_t data);
typedef amd_comgr_status_t (*t_amd_comgr_get_data_kind)(amd_comgr_data_t data, amd_comgr_data_kind_t *kind);
typedef amd_comgr_status_t (*t_amd_comgr_set_data)(amd_comgr_data_t data, size_t size, const char* bytes);
typedef amd_comgr_status_t (*t_amd_comgr_set_data_name)(amd_comgr_data_t data, const char* name);
typedef amd_comgr_status_t (*t_amd_comgr_get_data)(amd_comgr_data_t data, size_t *size, char *bytes);
typedef amd_comgr_status_t (*t_amd_comgr_get_data_name)(amd_comgr_data_t data, size_t *size, char *name);
typedef amd_comgr_status_t (*t_amd_comgr_get_data_isa_name)(amd_comgr_data_t data, size_t *size, char *isa_name);
typedef amd_comgr_status_t (*t_amd_comgr_get_data_metadata)(amd_comgr_data_t data, amd_comgr_metadata_node_t *metadata);
typedef amd_comgr_status_t (*t_amd_comgr_destroy_metadata)(amd_comgr_metadata_node_t metadata);
typedef amd_comgr_status_t (*t_amd_comgr_create_data_set)(amd_comgr_data_set_t *data_set);
typedef amd_comgr_status_t (*t_amd_comgr_destroy_data_set)(amd_comgr_data_set_t data_set);
typedef amd_comgr_status_t (*t_amd_comgr_data_set_add)(amd_comgr_data_set_t data_set, amd_comgr_data_t data);
typedef amd_comgr_status_t (*t_amd_comgr_data_set_remove)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind);
typedef amd_comgr_status_t (*t_amd_comgr_action_data_count)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t *count);
typedef amd_comgr_status_t (*t_amd_comgr_action_data_get_data)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t index, amd_comgr_data_t *data);
typedef amd_comgr_status_t (*t_amd_comgr_create_action_info)(amd_comgr_action_info_t *action_info);
typedef amd_comgr_status_t (*t_amd_comgr_destroy_action_info)(amd_comgr_action_info_t action_info);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_isa_name)(amd_comgr_action_info_t action_info, const char *isa_name);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_isa_name)(amd_comgr_action_info_t action_info, size_t *size, char *isa_name);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_language)(amd_comgr_action_info_t action_info, amd_comgr_language_t language);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_language)(amd_comgr_action_info_t action_info, amd_comgr_language_t *language);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_options)(amd_comgr_action_info_t action_info, const char *options);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_options)(amd_comgr_action_info_t action_info, size_t *size, char *options);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_working_directory_path)(amd_comgr_action_info_t action_info, const char *path);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_working_directory_path)(amd_comgr_action_info_t action_info, size_t *size, char *path);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_logging)(amd_comgr_action_info_t action_info, bool logging);
typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_logging)(amd_comgr_action_info_t action_info, bool *logging);
typedef amd_comgr_status_t (*t_amd_comgr_do_action)(amd_comgr_action_kind_t kind, amd_comgr_action_info_t info, amd_comgr_data_set_t input, amd_comgr_data_set_t result);
typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_kind)(amd_comgr_metadata_node_t metadata, amd_comgr_metadata_kind_t *kind);
typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_string)(amd_comgr_metadata_node_t metadata, size_t *size, char *string);
typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_map_size)(amd_comgr_metadata_node_t metadata, size_t *size);
typedef amd_comgr_status_t (*t_amd_comgr_iterate_map_metadata)(amd_comgr_metadata_node_t metadata, amd_comgr_status_t(*callback)(amd_comgr_metadata_node_t key, amd_comgr_metadata_node_t value, void *user_data), void *user_data);
typedef amd_comgr_status_t (*t_amd_comgr_metadata_lookup)(amd_comgr_metadata_node_t metadata, const char *key, amd_comgr_metadata_node_t *value);
typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_list_size)(amd_comgr_metadata_node_t metadata, size_t *size);
typedef amd_comgr_status_t (*t_amd_comgr_index_list_metadata)(amd_comgr_metadata_node_t metadata, size_t index, amd_comgr_metadata_node_t *value);
typedef amd_comgr_status_t (*t_amd_comgr_iterate_symbols)(amd_comgr_data_t data, amd_comgr_status_t(*callback)(amd_comgr_symbol_t symbol, void *user_data), void *user_data);
typedef amd_comgr_status_t (*t_amd_comgr_symbol_lookup)(amd_comgr_data_t data, const char *name, amd_comgr_symbol_t *symbol);
typedef amd_comgr_status_t (*t_amd_comgr_symbol_get_info)(amd_comgr_symbol_t symbol, amd_comgr_symbol_info_t attribute, void *value);
struct ComgrEntryPoints {
void* handle;
t_amd_comgr_get_version amd_comgr_get_version;
t_amd_comgr_status_string amd_comgr_status_string;
t_amd_comgr_get_isa_count amd_comgr_get_isa_count;
t_amd_comgr_get_isa_name amd_comgr_get_isa_name;
t_amd_comgr_get_isa_metadata amd_comgr_get_isa_metadata;
t_amd_comgr_create_data amd_comgr_create_data;
t_amd_comgr_release_data amd_comgr_release_data;
t_amd_comgr_get_data_kind amd_comgr_get_data_kind;
t_amd_comgr_set_data amd_comgr_set_data;
t_amd_comgr_set_data_name amd_comgr_set_data_name;
t_amd_comgr_get_data amd_comgr_get_data;
t_amd_comgr_get_data_name amd_comgr_get_data_name;
t_amd_comgr_get_data_isa_name amd_comgr_get_data_isa_name;
t_amd_comgr_get_data_metadata amd_comgr_get_data_metadata;
t_amd_comgr_destroy_metadata amd_comgr_destroy_metadata;
t_amd_comgr_create_data_set amd_comgr_create_data_set;
t_amd_comgr_destroy_data_set amd_comgr_destroy_data_set;
t_amd_comgr_data_set_add amd_comgr_data_set_add;
t_amd_comgr_data_set_remove amd_comgr_data_set_remove;
t_amd_comgr_action_data_count amd_comgr_action_data_count;
t_amd_comgr_action_data_get_data amd_comgr_action_data_get_data;
t_amd_comgr_create_action_info amd_comgr_create_action_info;
t_amd_comgr_destroy_action_info amd_comgr_destroy_action_info;
t_amd_comgr_action_info_set_isa_name amd_comgr_action_info_set_isa_name;
t_amd_comgr_action_info_get_isa_name amd_comgr_action_info_get_isa_name;
t_amd_comgr_action_info_set_language amd_comgr_action_info_set_language;
t_amd_comgr_action_info_get_language amd_comgr_action_info_get_language;
t_amd_comgr_action_info_set_options amd_comgr_action_info_set_options;
t_amd_comgr_action_info_get_options amd_comgr_action_info_get_options;
t_amd_comgr_action_info_set_working_directory_path amd_comgr_action_info_set_working_directory_path;
t_amd_comgr_action_info_get_working_directory_path amd_comgr_action_info_get_working_directory_path;
t_amd_comgr_action_info_set_logging amd_comgr_action_info_set_logging;
t_amd_comgr_action_info_get_logging amd_comgr_action_info_get_logging;
t_amd_comgr_do_action amd_comgr_do_action;
t_amd_comgr_get_metadata_kind amd_comgr_get_metadata_kind;
t_amd_comgr_get_metadata_string amd_comgr_get_metadata_string;
t_amd_comgr_get_metadata_map_size amd_comgr_get_metadata_map_size;
t_amd_comgr_iterate_map_metadata amd_comgr_iterate_map_metadata;
t_amd_comgr_metadata_lookup amd_comgr_metadata_lookup;
t_amd_comgr_get_metadata_list_size amd_comgr_get_metadata_list_size;
t_amd_comgr_index_list_metadata amd_comgr_index_list_metadata;
t_amd_comgr_iterate_symbols amd_comgr_iterate_symbols;
t_amd_comgr_symbol_lookup amd_comgr_symbol_lookup;
t_amd_comgr_symbol_get_info amd_comgr_symbol_get_info;
};
#ifdef COMGR_DYN_DLL
#define DYN(NAME) cep_.NAME
#define GET_COMGR_SYMBOL(NAME) cep_.NAME = \
reinterpret_cast<t_##NAME>(Os::getSymbol(cep_.handle, #NAME)); \
if (nullptr == cep_.NAME) { return false; }
#else
#define DYN(NAME) NAME
#define GET_COMGR_SYMBOL(NAME)
#endif
class Comgr : public amd::AllStatic {
public:
static std::once_flag initialized;
static bool LoadLib();
static bool IsReady() { return is_ready_; }
static void get_version(size_t *major, size_t *minor) {
DYN(amd_comgr_get_version)(major, minor);
}
static amd_comgr_status_t status_string(amd_comgr_status_t status, const char ** status_string) {
return DYN(amd_comgr_status_string)(status, status_string);
}
static amd_comgr_status_t get_isa_count(size_t *count) {
return DYN(amd_comgr_get_isa_count)(count);
}
static amd_comgr_status_t get_isa_name(size_t index, const char **isa_name) {
return DYN(amd_comgr_get_isa_name)(index, isa_name);
}
static amd_comgr_status_t get_isa_metadata(const char *isa_name, amd_comgr_metadata_node_t *metadata) {
return DYN(amd_comgr_get_isa_metadata)(isa_name, metadata);
}
static amd_comgr_status_t create_data(amd_comgr_data_kind_t kind, amd_comgr_data_t *data) {
return DYN(amd_comgr_create_data)(kind, data);
}
static amd_comgr_status_t release_data(amd_comgr_data_t data) {
return DYN(amd_comgr_release_data)(data);
}
static amd_comgr_status_t get_data_kind(amd_comgr_data_t data, amd_comgr_data_kind_t *kind) {
return DYN(amd_comgr_get_data_kind)(data, kind);
}
static amd_comgr_status_t set_data(amd_comgr_data_t data, size_t size, const char* bytes) {
return DYN(amd_comgr_set_data)(data, size, bytes);
}
static amd_comgr_status_t set_data_name(amd_comgr_data_t data, const char* name) {
return DYN(amd_comgr_set_data_name)(data, name);
}
static amd_comgr_status_t get_data(amd_comgr_data_t data, size_t *size, char *bytes) {
return DYN(amd_comgr_get_data)(data, size, bytes);
}
static amd_comgr_status_t get_data_name(amd_comgr_data_t data, size_t *size, char *name) {
return DYN(amd_comgr_get_data_name)(data, size, name);
}
static amd_comgr_status_t get_data_isa_name(amd_comgr_data_t data, size_t *size, char *isa_name) {
return DYN(amd_comgr_get_data_isa_name)(data, size, isa_name);
}
static amd_comgr_status_t get_data_metadata(amd_comgr_data_t data, amd_comgr_metadata_node_t *metadata) {
return DYN(amd_comgr_get_data_metadata)(data, metadata);
}
static amd_comgr_status_t destroy_metadata(amd_comgr_metadata_node_t metadata) {
return DYN(amd_comgr_destroy_metadata)(metadata);
}
static amd_comgr_status_t create_data_set(amd_comgr_data_set_t *data_set) {
return DYN(amd_comgr_create_data_set)(data_set);
}
static amd_comgr_status_t destroy_data_set(amd_comgr_data_set_t data_set) {
return DYN(amd_comgr_destroy_data_set)(data_set);
}
static amd_comgr_status_t data_set_add(amd_comgr_data_set_t data_set, amd_comgr_data_t data) {
return DYN(amd_comgr_data_set_add)(data_set, data);
}
static amd_comgr_status_t data_set_remove(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind) {
return DYN(amd_comgr_data_set_remove)(data_set, data_kind);
}
static amd_comgr_status_t action_data_count(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t *count) {
return DYN(amd_comgr_action_data_count)(data_set, data_kind, count);
}
static amd_comgr_status_t action_data_get_data(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t index, amd_comgr_data_t *data) {
return DYN(amd_comgr_action_data_get_data)(data_set, data_kind, index, data);
}
static amd_comgr_status_t create_action_info(amd_comgr_action_info_t *action_info) {
return DYN(amd_comgr_create_action_info)(action_info);
}
static amd_comgr_status_t destroy_action_info(amd_comgr_action_info_t action_info) {
return DYN(amd_comgr_destroy_action_info)(action_info);
}
static amd_comgr_status_t action_info_set_isa_name(amd_comgr_action_info_t action_info, const char *isa_name) {
return DYN(amd_comgr_action_info_set_isa_name)(action_info, isa_name);
}
static amd_comgr_status_t action_info_get_isa_name(amd_comgr_action_info_t action_info, size_t *size, char *isa_name) {
return DYN(amd_comgr_action_info_get_isa_name)(action_info, size, isa_name);
}
static amd_comgr_status_t action_info_set_language(amd_comgr_action_info_t action_info, amd_comgr_language_t language) {
return DYN(amd_comgr_action_info_set_language)(action_info, language);
}
static amd_comgr_status_t action_info_get_language(amd_comgr_action_info_t action_info, amd_comgr_language_t *language) {
return DYN(amd_comgr_action_info_get_language)(action_info, language);
}
static amd_comgr_status_t action_info_set_options(amd_comgr_action_info_t action_info, const char *options) {
return DYN(amd_comgr_action_info_set_options)(action_info, options);
}
static amd_comgr_status_t action_info_get_options(amd_comgr_action_info_t action_info, size_t *size, char *options) {
return DYN(amd_comgr_action_info_get_options)(action_info, size, options);
}
static amd_comgr_status_t action_info_set_working_directory_path(amd_comgr_action_info_t action_info, const char *path) {
return DYN(amd_comgr_action_info_set_working_directory_path)(action_info, path);
}
static amd_comgr_status_t action_info_get_working_directory_path(amd_comgr_action_info_t action_info, size_t *size, char *path) {
return DYN(amd_comgr_action_info_get_working_directory_path)(action_info, size, path);
}
static amd_comgr_status_t action_info_set_logging(amd_comgr_action_info_t action_info, bool logging) {
return DYN(amd_comgr_action_info_set_logging)(action_info, logging);
}
static amd_comgr_status_t action_info_get_logging(amd_comgr_action_info_t action_info, bool *logging) {
return DYN(amd_comgr_action_info_get_logging)(action_info, logging);
}
static amd_comgr_status_t do_action(amd_comgr_action_kind_t kind, amd_comgr_action_info_t info, amd_comgr_data_set_t input, amd_comgr_data_set_t result) {
return DYN(amd_comgr_do_action)(kind, info, input, result);
}
static amd_comgr_status_t get_metadata_kind(amd_comgr_metadata_node_t metadata, amd_comgr_metadata_kind_t *kind) {
return DYN(amd_comgr_get_metadata_kind)(metadata, kind);
}
static amd_comgr_status_t get_metadata_string(amd_comgr_metadata_node_t metadata, size_t *size, char *string) {
return DYN(amd_comgr_get_metadata_string)(metadata, size, string);
}
static amd_comgr_status_t get_metadata_map_size(amd_comgr_metadata_node_t metadata, size_t *size) {
return DYN(amd_comgr_get_metadata_map_size)(metadata, size);
}
static amd_comgr_status_t iterate_map_metadata(amd_comgr_metadata_node_t metadata, amd_comgr_status_t(*callback)(amd_comgr_metadata_node_t key, amd_comgr_metadata_node_t value, void *user_data), void *user_data) {
return DYN(amd_comgr_iterate_map_metadata)(metadata, callback, user_data);
}
static amd_comgr_status_t metadata_lookup(amd_comgr_metadata_node_t metadata, const char *key, amd_comgr_metadata_node_t *value) {
return DYN(amd_comgr_metadata_lookup)(metadata, key, value);
}
static amd_comgr_status_t get_metadata_list_size(amd_comgr_metadata_node_t metadata, size_t *size) {
return DYN(amd_comgr_get_metadata_list_size)(metadata, size);
}
static amd_comgr_status_t index_list_metadata(amd_comgr_metadata_node_t metadata, size_t index, amd_comgr_metadata_node_t *value) {
return DYN(amd_comgr_index_list_metadata)(metadata, index, value);
}
static amd_comgr_status_t iterate_symbols(amd_comgr_data_t data, amd_comgr_status_t(*callback)(amd_comgr_symbol_t symbol, void *user_data), void *user_data) {
return DYN(amd_comgr_iterate_symbols)(data, callback, user_data);
}
static amd_comgr_status_t symbol_lookup(amd_comgr_data_t data, const char *name, amd_comgr_symbol_t *symbol) {
return DYN(amd_comgr_symbol_lookup)(data, name, symbol);
}
static amd_comgr_status_t symbol_get_info(amd_comgr_symbol_t symbol, amd_comgr_symbol_info_t attribute, void *value) {
return DYN(amd_comgr_symbol_get_info)(symbol, attribute, value);
}
private:
static ComgrEntryPoints cep_;
static bool is_ready_;
};
}
#endif
+13
Dosyayı Görüntüle
@@ -222,6 +222,19 @@ Device::~Device() {
}
}
bool Device::ValidateComgr() {
#if defined(USE_COMGR_LIBRARY)
// Check if Lightning compiler was requested
if (settings_->useLightning_) {
std::call_once(amd::Comgr::initialized, amd::Comgr::LoadLib);
// Use Lightning only if it's available
settings_->useLightning_ = amd::Comgr::IsReady();
return settings_->useLightning_;
}
#endif
return true;
}
bool Device::create() {
vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true);
if (nullptr == vaCacheAccess_) {
+3
Dosyayı Görüntüle
@@ -1312,6 +1312,9 @@ class Device : public RuntimeObject {
amd::CacheCompilation* cacheCompilation() const { return cacheCompilation_.get(); }
#endif
//! Checks if OCL runtime can use code object manager for compilation
bool ValidateComgr();
protected:
//! Enable the specified extension
char* getExtensionString();
+34 -34
Dosyayı Görüntüle
@@ -779,7 +779,7 @@ bool Kernel::GetAttrCodePropMetadata(const amd_comgr_metadata_node_t programMD,
if (!GetKernelMetadata(programMD, name(), &kernelMeta)) {
if (kernelMeta.handle != 0) {
amd_comgr_destroy_metadata(kernelMeta);
amd::Comgr::destroy_metadata(kernelMeta);
}
return false;
}
@@ -795,25 +795,25 @@ bool Kernel::GetAttrCodePropMetadata(const amd_comgr_metadata_node_t programMD,
// extract the attribute metadata if there is any
amd_comgr_metadata_node_t attrMeta;
amd_comgr_status_t status = AMD_COMGR_STATUS_SUCCESS;
if (amd_comgr_metadata_lookup(kernelMeta, "Attrs", &attrMeta) == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_iterate_map_metadata(attrMeta, device::populateAttrs,
if (amd::Comgr::metadata_lookup(kernelMeta, "Attrs", &attrMeta) == AMD_COMGR_STATUS_SUCCESS) {
status = amd::Comgr::iterate_map_metadata(attrMeta, device::populateAttrs,
static_cast<void*>(kernelMD));
amd_comgr_destroy_metadata(attrMeta);
amd::Comgr::destroy_metadata(attrMeta);
}
// extract the code properties metadata
amd_comgr_metadata_node_t codePropsMeta;
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_metadata_lookup(kernelMeta, "CodeProps", &codePropsMeta);
status = amd::Comgr::metadata_lookup(kernelMeta, "CodeProps", &codePropsMeta);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_iterate_map_metadata(codePropsMeta, device::populateCodeProps,
status = amd::Comgr::iterate_map_metadata(codePropsMeta, device::populateCodeProps,
static_cast<void*>(kernelMD));
amd_comgr_destroy_metadata(codePropsMeta);
amd::Comgr::destroy_metadata(codePropsMeta);
}
amd_comgr_destroy_metadata(kernelMeta);
amd::Comgr::destroy_metadata(kernelMeta);
if (status != AMD_COMGR_STATUS_SUCCESS) {
return false;
@@ -848,9 +848,9 @@ bool Kernel::GetKernelMetadata(const amd_comgr_metadata_node_t programMD,
amd_comgr_metadata_node_t kernelsMD;
size_t size = 0;
status = amd_comgr_metadata_lookup(programMD, "Kernels", &kernelsMD);
status = amd::Comgr::metadata_lookup(programMD, "Kernels", &kernelsMD);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_get_metadata_list_size(kernelsMD, &size);
status = amd::Comgr::get_metadata_list_size(kernelsMD, &size);
}
bool kernelFound = false;
@@ -858,9 +858,9 @@ bool Kernel::GetKernelMetadata(const amd_comgr_metadata_node_t programMD,
std::string kernelName;
amd_comgr_metadata_node_t nameMeta;
status = amd_comgr_index_list_metadata(kernelsMD, i, kernelNode);
status = amd::Comgr::index_list_metadata(kernelsMD, i, kernelNode);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_metadata_lookup(*kernelNode, "Name", &nameMeta);
status = amd::Comgr::metadata_lookup(*kernelNode, "Name", &nameMeta);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
@@ -871,12 +871,12 @@ bool Kernel::GetKernelMetadata(const amd_comgr_metadata_node_t programMD,
kernelFound = true;
}
else {
amd_comgr_destroy_metadata(*kernelNode);
amd::Comgr::destroy_metadata(*kernelNode);
}
amd_comgr_destroy_metadata(nameMeta);
amd::Comgr::destroy_metadata(nameMeta);
}
amd_comgr_destroy_metadata(kernelsMD);
amd::Comgr::destroy_metadata(kernelsMD);
return kernelFound;
}
@@ -888,10 +888,10 @@ bool Kernel::SetAvailableSgprVgpr(const std::string& targetIdent) {
amd_comgr_metadata_node_t sgprMeta;
amd_comgr_metadata_node_t vgprMeta;
amd_comgr_status_t status = amd_comgr_get_isa_metadata(targetIdent.c_str(), &isaMeta);
amd_comgr_status_t status = amd::Comgr::get_isa_metadata(targetIdent.c_str(), &isaMeta);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_metadata_lookup(isaMeta, "AddressableNumSGPRs", &sgprMeta);
status = amd::Comgr::metadata_lookup(isaMeta, "AddressableNumSGPRs", &sgprMeta);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
@@ -901,7 +901,7 @@ bool Kernel::SetAvailableSgprVgpr(const std::string& targetIdent) {
workGroupInfo_.availableSGPRs_ = (status == AMD_COMGR_STATUS_SUCCESS) ? atoi(buf.c_str()) : 0;
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_metadata_lookup(isaMeta, "AddressableNumVGPRs", &vgprMeta);
status = amd::Comgr::metadata_lookup(isaMeta, "AddressableNumVGPRs", &vgprMeta);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
@@ -909,9 +909,9 @@ bool Kernel::SetAvailableSgprVgpr(const std::string& targetIdent) {
}
workGroupInfo_.availableVGPRs_ = (status == AMD_COMGR_STATUS_SUCCESS) ? atoi(buf.c_str()) : 0;
amd_comgr_destroy_metadata(vgprMeta);
amd_comgr_destroy_metadata(sgprMeta);
amd_comgr_destroy_metadata(isaMeta);
amd::Comgr::destroy_metadata(vgprMeta);
amd::Comgr::destroy_metadata(sgprMeta);
amd::Comgr::destroy_metadata(isaMeta);
return (status == AMD_COMGR_STATUS_SUCCESS);
}
@@ -920,24 +920,24 @@ bool Kernel::GetPrintfStr(const amd_comgr_metadata_node_t programMD,
std::vector<std::string>* printfStr) {
amd_comgr_metadata_node_t printfMeta;
amd_comgr_status_t status = amd_comgr_metadata_lookup(programMD, "Printf", &printfMeta);
amd_comgr_status_t status = amd::Comgr::metadata_lookup(programMD, "Printf", &printfMeta);
if (status != AMD_COMGR_STATUS_SUCCESS) {
return true; // printf string metadata is not provided so just exit
}
// handle the printf string
size_t printfSize = 0;
status = amd_comgr_get_metadata_list_size(printfMeta, &printfSize);
status = amd::Comgr::get_metadata_list_size(printfMeta, &printfSize);
if (status == AMD_COMGR_STATUS_SUCCESS) {
std::string buf;
for (size_t i = 0; i < printfSize; ++i) {
amd_comgr_metadata_node_t str;
status = amd_comgr_index_list_metadata(printfMeta, i, &str);
status = amd::Comgr::index_list_metadata(printfMeta, i, &str);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = getMetaBuf(str, &buf);
amd_comgr_destroy_metadata(str);
amd::Comgr::destroy_metadata(str);
}
if (status != AMD_COMGR_STATUS_SUCCESS) {
@@ -948,7 +948,7 @@ bool Kernel::GetPrintfStr(const amd_comgr_metadata_node_t programMD,
}
}
amd_comgr_destroy_metadata(printfMeta);
amd::Comgr::destroy_metadata(printfMeta);
return (status == AMD_COMGR_STATUS_SUCCESS);
}
@@ -963,9 +963,9 @@ void Kernel::InitParameters(const amd_comgr_metadata_node_t kernelMD, uint32_t a
amd_comgr_metadata_node_t argsMeta;
size_t argsSize;
amd_comgr_status_t status = amd_comgr_metadata_lookup(kernelMD, "Args", &argsMeta);
amd_comgr_status_t status = amd::Comgr::metadata_lookup(kernelMD, "Args", &argsMeta);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_get_metadata_list_size(argsMeta, &argsSize);
status = amd::Comgr::get_metadata_list_size(argsMeta, &argsSize);
}
if (status != AMD_COMGR_STATUS_SUCCESS) {
@@ -978,22 +978,22 @@ void Kernel::InitParameters(const amd_comgr_metadata_node_t kernelMD, uint32_t a
amd_comgr_metadata_node_t argsNode;
amd_comgr_metadata_kind_t kind;
status = amd_comgr_index_list_metadata(argsMeta, i, &argsNode);
status = amd::Comgr::index_list_metadata(argsMeta, i, &argsNode);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_get_metadata_kind(argsNode, &kind);
status = amd::Comgr::get_metadata_kind(argsNode, &kind);
}
if (kind != AMD_COMGR_METADATA_KIND_MAP) {
status = AMD_COMGR_STATUS_ERROR;
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_iterate_map_metadata(argsNode, populateArgs, static_cast<void*>(&lcArg));
status = amd::Comgr::iterate_map_metadata(argsNode, populateArgs, static_cast<void*>(&lcArg));
}
amd_comgr_destroy_metadata(argsNode);
amd::Comgr::destroy_metadata(argsNode);
if (status != AMD_COMGR_STATUS_SUCCESS) {
amd_comgr_destroy_metadata(argsMeta);
amd::Comgr::destroy_metadata(argsMeta);
return;
}
@@ -1052,7 +1052,7 @@ void Kernel::InitParameters(const amd_comgr_metadata_node_t kernelMD, uint32_t a
}
}
amd_comgr_destroy_metadata(argsMeta);
amd::Comgr::destroy_metadata(argsMeta);
// Save the number of OCL arguments
uint32_t numParams = params.size();
+11 -11
Dosyayı Görüntüle
@@ -438,11 +438,11 @@ class Kernel : public amd::HeapObject {
static amd_comgr_status_t getMetaBuf(const amd_comgr_metadata_node_t meta,
std::string* str) {
size_t size = 0;
amd_comgr_status_t status = amd_comgr_get_metadata_string(meta, &size, NULL);
amd_comgr_status_t status = amd::Comgr::get_metadata_string(meta, &size, NULL);
if (status == AMD_COMGR_STATUS_SUCCESS) {
str->resize(size-1); // minus one to discount the null character
status = amd_comgr_get_metadata_string(meta, &size, &((*str)[0]));
status = amd::Comgr::get_metadata_string(meta, &size, &((*str)[0]));
}
return status;
@@ -457,7 +457,7 @@ static amd_comgr_status_t populateArgs(const amd_comgr_metadata_node_t key,
// get the key of the argument field
size_t size = 0;
status = amd_comgr_get_metadata_kind(key, &kind);
status = amd::Comgr::get_metadata_kind(key, &kind);
if (kind == AMD_COMGR_METADATA_KIND_STRING && status == AMD_COMGR_STATUS_SUCCESS) {
status = getMetaBuf(key, &buf);
}
@@ -564,7 +564,7 @@ static amd_comgr_status_t populateAttrs(const amd_comgr_metadata_node_t key,
std::string buf;
// get the key of the argument field
status = amd_comgr_get_metadata_kind(key, &kind);
status = amd::Comgr::get_metadata_kind(key, &kind);
if (kind == AMD_COMGR_METADATA_KIND_STRING && status == AMD_COMGR_STATUS_SUCCESS) {
status = getMetaBuf(key, &buf);
}
@@ -582,34 +582,34 @@ static amd_comgr_status_t populateAttrs(const amd_comgr_metadata_node_t key,
switch (itAttrField->second) {
case AttrField::ReqWorkGroupSize:
{
status = amd_comgr_get_metadata_list_size(value, &size);
status = amd::Comgr::get_metadata_list_size(value, &size);
if (size == 3 && status == AMD_COMGR_STATUS_SUCCESS) {
for (size_t i = 0; i < size && status == AMD_COMGR_STATUS_SUCCESS; i++) {
amd_comgr_metadata_node_t workgroupSize;
status = amd_comgr_index_list_metadata(value, i, &workgroupSize);
status = amd::Comgr::index_list_metadata(value, i, &workgroupSize);
if (status == AMD_COMGR_STATUS_SUCCESS &&
getMetaBuf(workgroupSize, &buf) == AMD_COMGR_STATUS_SUCCESS) {
kernelMD->mAttrs.mReqdWorkGroupSize.push_back(atoi(buf.c_str()));
}
amd_comgr_destroy_metadata(workgroupSize);
amd::Comgr::destroy_metadata(workgroupSize);
}
}
}
break;
case AttrField::WorkGroupSizeHint:
{
status = amd_comgr_get_metadata_list_size(value, &size);
status = amd::Comgr::get_metadata_list_size(value, &size);
if (status == AMD_COMGR_STATUS_SUCCESS && size == 3) {
for (size_t i = 0; i < size && status == AMD_COMGR_STATUS_SUCCESS; i++) {
amd_comgr_metadata_node_t workgroupSizeHint;
status = amd_comgr_index_list_metadata(value, i, &workgroupSizeHint);
status = amd::Comgr::index_list_metadata(value, i, &workgroupSizeHint);
if (status == AMD_COMGR_STATUS_SUCCESS &&
getMetaBuf(workgroupSizeHint, &buf) == AMD_COMGR_STATUS_SUCCESS) {
kernelMD->mAttrs.mWorkGroupSizeHint.push_back(atoi(buf.c_str()));
}
amd_comgr_destroy_metadata(workgroupSizeHint);
amd::Comgr::destroy_metadata(workgroupSizeHint);
}
}
}
@@ -643,7 +643,7 @@ static amd_comgr_status_t populateCodeProps(const amd_comgr_metadata_node_t key,
std::string buf;
// get the key of the argument field
status = amd_comgr_get_metadata_kind(key, &kind);
status = amd::Comgr::get_metadata_kind(key, &kind);
if (kind == AMD_COMGR_METADATA_KIND_STRING && status == AMD_COMGR_STATUS_SUCCESS) {
status = getMetaBuf(key, &buf);
}
+60 -60
Dosyayı Görüntüle
@@ -195,28 +195,28 @@ void Program::extractByteCodeBinary(const amd_comgr_data_set_t inDataSet,
char* outBinary[], size_t* outSize) {
amd_comgr_data_t binaryData;
amd_comgr_status_t status = amd_comgr_create_data(dataKind, &binaryData);
amd_comgr_status_t status = amd::Comgr::create_data(dataKind, &binaryData);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_action_data_get_data(inDataSet, dataKind, 0, &binaryData);
status = amd::Comgr::action_data_get_data(inDataSet, dataKind, 0, &binaryData);
}
size_t binarySize = 0;
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_get_data(binaryData, &binarySize, NULL);
status = amd::Comgr::get_data(binaryData, &binarySize, NULL);
}
char* binary = static_cast<char *>(malloc(binarySize));
if (binary == nullptr) {
amd_comgr_release_data(binaryData);
amd::Comgr::release_data(binaryData);
return;
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_get_data(binaryData, &binarySize, binary);
status = amd::Comgr::get_data(binaryData, &binarySize, binary);
}
amd_comgr_release_data(binaryData);
amd::Comgr::release_data(binaryData);
if (status != AMD_COMGR_STATUS_SUCCESS) {
free(binary);
@@ -253,22 +253,22 @@ amd_comgr_status_t Program::addCodeObjData(const char *source,
amd_comgr_data_t data;
amd_comgr_status_t status;
status = amd_comgr_create_data(type, &data);
status = amd::Comgr::create_data(type, &data);
if (status != AMD_COMGR_STATUS_SUCCESS) {
return status;
}
status = amd_comgr_set_data(data, size, source);
status = amd::Comgr::set_data(data, size, source);
if ((name != nullptr) && (status == AMD_COMGR_STATUS_SUCCESS)) {
status = amd_comgr_set_data_name(data, name);
status = amd::Comgr::set_data_name(data, name);
}
if ((dataSet != nullptr) && (status == AMD_COMGR_STATUS_SUCCESS)) {
status = amd_comgr_data_set_add(*dataSet, data);
status = amd::Comgr::data_set_add(*dataSet, data);
}
amd_comgr_release_data(data);
amd::Comgr::release_data(data);
return status;
}
@@ -309,18 +309,18 @@ amd_comgr_status_t Program::createAction(const amd_comgr_language_t oclver,
const std::string& options,
amd_comgr_action_info_t* action) {
amd_comgr_status_t status = amd_comgr_create_action_info(action);
amd_comgr_status_t status = amd::Comgr::create_action_info(action);
if ((oclver != AMD_COMGR_LANGUAGE_NONE) && (status == AMD_COMGR_STATUS_SUCCESS)) {
status = amd_comgr_action_info_set_language(*action, oclver);
status = amd::Comgr::action_info_set_language(*action, oclver);
}
if (!targetIdent.empty() && (status == AMD_COMGR_STATUS_SUCCESS)) {
status = amd_comgr_action_info_set_isa_name(*action, targetIdent.c_str());
status = amd::Comgr::action_info_set_isa_name(*action, targetIdent.c_str());
}
if (!options.empty() && (status == AMD_COMGR_STATUS_SUCCESS)) {
status = amd_comgr_action_info_set_options(*action, options.c_str());
status = amd::Comgr::action_info_set_options(*action, options.c_str());
}
return status;
@@ -346,16 +346,16 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
amd_comgr_status_t status = createAction(oclver, targetIdent, options, &action);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&dataSetDevLibs);
status = amd::Comgr::create_data_set(&dataSetDevLibs);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES, action, inputs,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES, action, inputs,
dataSetDevLibs);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, dataSetDevLibs, *output);
status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, dataSetDevLibs, *output);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
@@ -367,8 +367,8 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
extractByteCodeBinary(*output, AMD_COMGR_DATA_KIND_BC, dumpFileName, binaryData, binarySize);
}
amd_comgr_destroy_action_info(action);
amd_comgr_destroy_data_set(dataSetDevLibs);
amd::Comgr::destroy_action_info(action);
amd::Comgr::destroy_data_set(dataSetDevLibs);
return (status == AMD_COMGR_STATUS_SUCCESS);
}
@@ -393,22 +393,22 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs,
amd_comgr_status_t status = createAction(oclver, targetIdent, options, &action);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&output);
status = amd::Comgr::create_data_set(&output);
}
// Adding Precompiled Headers
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&dataSetPCH);
status = amd::Comgr::create_data_set(&dataSetPCH);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS,
action, inputs, dataSetPCH);
}
// Compiling the source codes with precompiled headers
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC,
action, dataSetPCH, output);
}
@@ -420,9 +420,9 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs,
extractByteCodeBinary(output, AMD_COMGR_DATA_KIND_BC, outFileName, binaryData, binarySize);
}
amd_comgr_destroy_action_info(action);
amd_comgr_destroy_data_set(dataSetPCH);
amd_comgr_destroy_data_set(output);
amd::Comgr::destroy_action_info(action);
amd::Comgr::destroy_data_set(dataSetPCH);
amd::Comgr::destroy_data_set(output);
return (status == AMD_COMGR_STATUS_SUCCESS);
}
@@ -446,15 +446,15 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
amd_comgr_status_t status = createAction(AMD_COMGR_LANGUAGE_NONE, targetIdent, options, &action);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&output);
status = amd::Comgr::create_data_set(&output);
}
if ((amdOptions->isDumpFlagSet(amd::option::DUMP_ISA)) && (status == AMD_COMGR_STATUS_SUCCESS)) {
// create the assembly data set
amd_comgr_data_set_t assemblyData;
status = amd_comgr_create_data_set(&assemblyData);
status = amd::Comgr::create_data_set(&assemblyData);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY,
action, inputs, assemblyData);
}
@@ -463,23 +463,23 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
std::string dumpIsaName = amdOptions->getDumpFileName(".s");
extractByteCodeBinary(assemblyData, AMD_COMGR_DATA_KIND_SOURCE, dumpIsaName);
}
amd_comgr_destroy_data_set(assemblyData);
amd::Comgr::destroy_data_set(assemblyData);
}
// Create the relocatiable data set
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&relocatableData);
status = amd::Comgr::create_data_set(&relocatableData);
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE,
action, inputs, relocatableData);
}
// Create executable from the relocatable data set
amd_comgr_action_info_set_options(action, "");
amd::Comgr::action_info_set_options(action, "");
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_do_action(AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE,
status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE,
action, relocatableData, output);
}
@@ -493,9 +493,9 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
executableSize);
}
amd_comgr_destroy_action_info(action);
amd_comgr_destroy_data_set(relocatableData);
amd_comgr_destroy_data_set(output);
amd::Comgr::destroy_action_info(action);
amd::Comgr::destroy_data_set(relocatableData);
amd::Comgr::destroy_data_set(output);
return (status == AMD_COMGR_STATUS_SUCCESS);
}
@@ -517,7 +517,7 @@ bool Program::compileImplLC(const std::string& sourceCode,
// add CL source to input data set
amd_comgr_data_set_t inputs;
if (amd_comgr_create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
if (amd::Comgr::create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create output buffer for LLVM bitcode.\n";
return false;
}
@@ -525,7 +525,7 @@ bool Program::compileImplLC(const std::string& sourceCode,
if (addCodeObjData(sourceCode.c_str(), sourceCode.length(), AMD_COMGR_DATA_KIND_SOURCE,
"CompileCLSource", &inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create data from CL source.\n";
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return false;
}
@@ -561,7 +561,7 @@ bool Program::compileImplLC(const std::string& sourceCode,
if (addCodeObjData(headers[i]->c_str(), headers[i]->length(), AMD_COMGR_DATA_KIND_INCLUDE,
headerName.c_str(), &inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to add headers into inputs.\n";
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return false;
}
}
@@ -603,7 +603,7 @@ bool Program::compileImplLC(const std::string& sourceCode,
buildLog_ += "Error: Failed to compile opencl source (from CL to LLVM IR).\n";
}
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return ret;
}
#else // not using COMgr
@@ -932,7 +932,7 @@ bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
amd_comgr_data_set_t inputs;
if (amd_comgr_create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
if (amd::Comgr::create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create data set.\n";
return false;
}
@@ -966,7 +966,7 @@ bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
}
if (!result) {
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
buildLog_ += "Error: Linking bitcode failed: failing to generate LLVM binary.\n";
return false;
}
@@ -979,9 +979,9 @@ bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
// create the linked output
amd_comgr_data_set_t output;
if (amd_comgr_create_data_set(&output) != AMD_COMGR_STATUS_SUCCESS) {
if (amd::Comgr::create_data_set(&output) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create output buffer for LLVM bitcode.\n";
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return false;
}
@@ -993,8 +993,8 @@ bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
bool ret = linkLLVMBitcode(inputs, linkOptions, false, options, &output, &binaryData,
&binarySize);
amd_comgr_destroy_data_set(output);
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(output);
amd::Comgr::destroy_data_set(inputs);
if (!ret) {
buildLog_ += "Error: Linking bitcode failed: linking source & IR libraries.\n";
@@ -1233,7 +1233,7 @@ bool Program::linkImplLC(amd::option::Options* options) {
true : false;
amd_comgr_data_set_t inputs;
if (amd_comgr_create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
if (amd::Comgr::create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create data set for linking.\n";
return false;
}
@@ -1256,7 +1256,7 @@ bool Program::linkImplLC(amd::option::Options* options) {
if (addCodeObjData(section, sz, AMD_COMGR_DATA_KIND_BC, "Assembly Text",
&inputs) != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to create assembly input.\n";
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return false;
}
@@ -1264,14 +1264,14 @@ bool Program::linkImplLC(amd::option::Options* options) {
break;
}
case ACL_TYPE_ISA: {
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
binary_t isaBinary = binary();
return setKernels(options, const_cast<void *>(isaBinary.first), isaBinary.second);
break;
}
default:
buildLog_ += "Error while Codegen phase: the binary is incomplete \n";
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
return false;
}
@@ -1303,7 +1303,7 @@ bool Program::linkImplLC(amd::option::Options* options) {
amd_comgr_data_set_t linked_bc;
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_create_data_set(&linked_bc);
status = amd::Comgr::create_data_set(&linked_bc);
}
bool ret = (status == AMD_COMGR_STATUS_SUCCESS);
@@ -1311,10 +1311,10 @@ bool Program::linkImplLC(amd::option::Options* options) {
ret = linkLLVMBitcode(inputs, linkOptions, true, options, &linked_bc);
}
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
if (!ret) {
amd_comgr_destroy_data_set(linked_bc);
amd::Comgr::destroy_data_set(linked_bc);
buildLog_ += "Error: Linking bitcode failed: linking source & IR libraries.\n";
return false;
}
@@ -1346,7 +1346,7 @@ bool Program::linkImplLC(amd::option::Options* options) {
size_t executableSize = 0;
bool ret = compileAndLinkExecutable(inputs, codegenOptions, options, &executable,
&executableSize);
amd_comgr_destroy_data_set(inputs);
amd::Comgr::destroy_data_set(inputs);
if (!ret) {
if (continueCompileFrom == ACL_TYPE_ASM_TEXT) {
@@ -2686,18 +2686,18 @@ bool Program::FindGlobalVarSize(void* binary, size_t binSize) {
amd_comgr_status_t status;
amd_comgr_data_t binaryData;
status = amd_comgr_create_data(AMD_COMGR_DATA_KIND_EXECUTABLE, &binaryData);
status = amd::Comgr::create_data(AMD_COMGR_DATA_KIND_EXECUTABLE, &binaryData);
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd_comgr_set_data(binaryData, binSize,
status = amd::Comgr::set_data(binaryData, binSize,
reinterpret_cast<const char*>(binary));
}
if (status == AMD_COMGR_STATUS_SUCCESS) {
metadata_ = new amd_comgr_metadata_node_t;
status = amd_comgr_get_data_metadata(binaryData, metadata_);
status = amd::Comgr::get_data_metadata(binaryData, metadata_);
}
amd_comgr_release_data(binaryData);
amd::Comgr::release_data(binaryData);
if (status != AMD_COMGR_STATUS_SUCCESS) {
buildLog_ += "Error: COMGR fails to get the metadata.\n";
+1 -3
Dosyayı Görüntüle
@@ -8,9 +8,7 @@
#include "platform/object.hpp"
#include "platform/memory.hpp"
#include "devwavelimiter.hpp"
#if defined(USE_COMGR_LIBRARY)
#include "amd_comgr.h"
#endif
#include "comgrctx.hpp"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#include "driver/AmdCompiler.h"
+11
Dosyayı Görüntüle
@@ -266,6 +266,11 @@ bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel,
return false;
}
if (!ValidateComgr()) {
LogError("Code object manager initialization failed!");
return false;
}
// Fill the device info structure
fillDeviceInfo(properties, heaps, 4096, 1, 0);
@@ -891,6 +896,12 @@ bool Device::create(Pal::IDevice* device) {
!gpuSettings->create(properties(), heaps_, wscaps, appProfile_.reportAsOCL12Device())) {
return false;
}
if (!ValidateComgr()) {
LogError("Code object manager initialization failed!");
return false;
}
numComputeEngines_ = std::min(numComputeEngines_, settings().numComputeRings_);
amd::Context::Info info = {0};
+11
Dosyayı Görüntüle
@@ -118,6 +118,12 @@ bool NullDevice::create(const AMDDeviceInfo& deviceInfo) {
LogError("Error creating settings for nullptr HSA device");
return false;
}
if (!ValidateComgr()) {
LogError("Code object manager initialization failed!");
return false;
}
// Report the device name
::strcpy(info_.name_, "AMD HSA Device");
info_.extensions_ = getExtensionString();
@@ -599,6 +605,11 @@ bool Device::create() {
return false;
}
if (!ValidateComgr()) {
LogError("Code object manager initialization failed!");
return false;
}
if (!amd::Device::create()) {
return false;
}