2016-07-21 12:41:26 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
//
|
2017-04-13 13:56:38 -04:00
|
|
|
// This file hsa the code for explicity loading amdoclcl.dll.
|
2016-07-21 12:41:26 -04:00
|
|
|
// Exported functions from amdoclcl.dll can be added for usage as need-basis.
|
|
|
|
|
// With explicit/dynamic loading roc will not have any linkage to amdoclcl.lib.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "thread/thread.hpp"
|
|
|
|
|
#include "acl.h"
|
|
|
|
|
#include "utils/debug.hpp"
|
|
|
|
|
|
2016-08-04 14:24:34 -04:00
|
|
|
#if defined(WITH_LIGHTNING_COMPILER)
|
|
|
|
|
#error Should not include this file
|
2017-04-13 13:56:38 -04:00
|
|
|
#endif // defined(WITH_LIGHTNING_COMPILER)
|
2016-08-04 14:24:34 -04:00
|
|
|
|
2016-07-21 12:41:26 -04:00
|
|
|
using namespace amd;
|
|
|
|
|
|
|
|
|
|
namespace roc {
|
|
|
|
|
|
|
|
|
|
//
|
2017-04-13 13:56:38 -04:00
|
|
|
// To use any new exported function from amdhsacl.dll please add/make that function specific changes
|
2016-07-21 12:41:26 -04:00
|
|
|
// in typedef below, struct CompLibApi and in hsacompilerLib.cpp::LoadCompLib() function.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Convention: The typedefed function name must be prefixed with pfn_
|
|
|
|
|
//
|
2017-04-13 13:56:38 -04:00
|
|
|
typedef aclCompiler*(ACL_API_ENTRY* pfn_aclCompilerInit)(aclCompilerOptions* opts,
|
|
|
|
|
acl_error* error_code);
|
|
|
|
|
typedef aclTargetInfo(ACL_API_ENTRY* pfn_aclGetTargetInfo)(const char*, const char*, acl_error*);
|
|
|
|
|
typedef aclBinary*(ACL_API_ENTRY* pfn_aclBinaryInit)(size_t, const aclTargetInfo*,
|
|
|
|
|
const aclBinaryOptions*, acl_error*);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclInsertSection)(aclCompiler* cl, aclBinary* binary,
|
|
|
|
|
const void* data, size_t data_size,
|
|
|
|
|
aclSections id);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclCompile)(aclCompiler* cl, aclBinary* bin,
|
|
|
|
|
const char* options, aclType from, aclType to,
|
|
|
|
|
aclLogFunction compile_callback);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclCompilerFini)(aclCompiler* cl);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclBinaryFini)(aclBinary* bin);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclWriteToMem)(aclBinary* bin, void** mem, size_t* size);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclQueryInfo)(aclCompiler* cl, const aclBinary* binary,
|
|
|
|
|
aclQueryType query, const char* kernel,
|
|
|
|
|
void* data_ptr, size_t* ptr_size);
|
|
|
|
|
typedef const void*(ACL_API_ENTRY* pfn_aclExtractSymbol)(aclCompiler* cl, const aclBinary* binary,
|
|
|
|
|
size_t* size, aclSections id,
|
|
|
|
|
const char* symbol, acl_error* error_code);
|
|
|
|
|
typedef aclBinary*(ACL_API_ENTRY* pfn_aclReadFromMem)(void* mem, size_t size,
|
|
|
|
|
acl_error* error_code);
|
|
|
|
|
typedef char*(ACL_API_ENTRY* pfn_aclGetCompilerLog)(aclCompiler* cl);
|
|
|
|
|
typedef aclBinary*(ACL_API_ENTRY* pfn_aclCreateFromBinary)(const aclBinary* binary,
|
|
|
|
|
aclBIFVersion version);
|
|
|
|
|
typedef aclBIFVersion(ACL_API_ENTRY* pfn_aclBinaryVersion)(const aclBinary* binary);
|
|
|
|
|
typedef acl_error(ACL_API_ENTRY* pfn_aclLink)(aclCompiler* cl, aclBinary* src_bin,
|
|
|
|
|
unsigned int num_libs, aclBinary** libs,
|
|
|
|
|
aclType link_mode, const char* options,
|
|
|
|
|
aclLogFunction link_callback);
|
2016-07-21 12:41:26 -04:00
|
|
|
//
|
|
|
|
|
// Convention: prefix struct member variable with with underscore '_'
|
|
|
|
|
// would be nice if there was no underscore prfix, but on Linux the token
|
|
|
|
|
// pasting in the macro is srtict and his is the workaround.
|
|
|
|
|
//
|
2017-04-13 13:56:38 -04:00
|
|
|
struct CompLibApi {
|
|
|
|
|
pfn_aclCompilerInit _aclCompilerInit;
|
|
|
|
|
pfn_aclGetTargetInfo _aclGetTargetInfo;
|
|
|
|
|
pfn_aclBinaryInit _aclBinaryInit;
|
|
|
|
|
pfn_aclInsertSection _aclInsertSection;
|
|
|
|
|
pfn_aclCompile _aclCompile;
|
|
|
|
|
pfn_aclCompilerFini _aclCompilerFini;
|
|
|
|
|
pfn_aclBinaryFini _aclBinaryFini;
|
|
|
|
|
pfn_aclWriteToMem _aclWriteToMem;
|
|
|
|
|
pfn_aclQueryInfo _aclQueryInfo;
|
|
|
|
|
pfn_aclExtractSymbol _aclExtractSymbol;
|
|
|
|
|
pfn_aclReadFromMem _aclReadFromMem;
|
|
|
|
|
pfn_aclGetCompilerLog _aclGetCompilerLog;
|
|
|
|
|
pfn_aclCreateFromBinary _aclCreateFromBinary;
|
|
|
|
|
pfn_aclBinaryVersion _aclBinaryVersion;
|
|
|
|
|
pfn_aclLink _aclLink;
|
2016-07-21 12:41:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Use g_ prefix for all global variables.
|
|
|
|
|
//
|
|
|
|
|
extern void* g_complibModule;
|
|
|
|
|
extern CompLibApi g_complibApi;
|
|
|
|
|
|
|
|
|
|
// Note: initializes global variable g_complibApi.
|
|
|
|
|
// Not sure what error values we have, for now returning false on failure.
|
2017-04-13 13:56:38 -04:00
|
|
|
bool LoadCompLib(bool isOfflineDevice = false);
|
2016-07-21 12:41:26 -04:00
|
|
|
void UnloadCompLib();
|
|
|
|
|
|
2017-04-13 13:56:38 -04:00
|
|
|
} // namespace roc
|