Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lld filter=lfs diff=lfs merge=lfs -text
Binary file added bin/iga64
Binary file not shown.
3 changes: 3 additions & 0 deletions bin/lld
Git LFS file not shown
1 change: 1 addition & 0 deletions include/iga/iga.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static_assert(sizeof(iga_disassemble_options_t) == 6 * 4,
/* just the default decoding opts */
#define IGA_DECODING_OPTS_DEFAULT (0u)


/*
* Disassembles kernel bits into a string.
*
Expand Down
1 change: 1 addition & 0 deletions include/iga/igaEncoderWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class KernelEncoder {
// enable IGA swsb set. When enabled, the original swsb in the input
// instructions will be obsoleted
void enableIGAAutoDeps(bool enable = true) { m_enableAutoDeps = enable; }

};

#endif // _IGA_ENCODER_WRAPPER_HPP
10 changes: 9 additions & 1 deletion include/iga/igad.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,19 @@ typedef iga_status_t(CDECLATTRIBUTE *pIGAOpspecOp)(iga_opspec_t op,
typedef kv_t *(CDECLATTRIBUTE *pIGAKVCreate)(
iga_gen_t plat, const void *bytes, size_t bytes_len, iga_status_t *status,
char *errbuf, size_t errbuf_cap,
/* iga::SWSB_ENCODE_MODE */ uint32_t swsb_mode);
/* iga::SWSB_ENCODE_MODE */ uint32_t swsb_mode
);
#define IGA_KV_DELETE_STR "kv_delete"
typedef void(CDECLATTRIBUTE *pIGAKVDelete)(kv_t *);

#define IGA_KV_GET_INST_SIZE_STR "kv_get_inst_size"
typedef int32_t(CDECLATTRIBUTE *pIGAKVGetInstSize)(const kv_t *kv, int32_t pc);
#define IGA_KV_GET_INST_MSG_INFO_STR "kv_get_inst_msg_info"
typedef int32_t(CDECLATTRIBUTE *pIGAKVGetInstMsgInfo)(const kv_t *kv,
int32_t pc,
bool *isAtomic,
bool *isSlm,
bool *isScratch);
#define IGA_KV_GET_INST_TARGETS_STR "kv_get_inst_targets"
typedef uint32_t(CDECLATTRIBUTE *pIGAKVGetInstTargets)(const kv_t *kv,
int32_t pc,
Expand Down Expand Up @@ -379,6 +386,7 @@ typedef struct {
pIGAKVCreate kv_create;
pIGAKVDelete kv_delete;
pIGAKVGetInstSize kv_get_inst_size;
pIGAKVGetInstMsgInfo kv_get_inst_msg_info;
pIGAKVGetInstTargets kv_get_inst_targets;
pIGAKVIsInstTarget kv_is_inst_target;
pIGAKVGetDefaultLabelName kv_get_default_label_name;
Expand Down
20 changes: 19 additions & 1 deletion include/iga/kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ typedef enum {
*/
IGA_API struct kv_t *kv_create(iga_gen_t plat, const void *bytes, size_t bytes_len,
iga_status_t *status, char *errbuf, size_t errbuf_cap,
uint32_t swsb_enc_mode /* iga::SWSB_ENCODE_MODE */);
uint32_t swsb_enc_mode /* iga::SWSB_ENCODE_MODE */
);

/*
* Destroys a kernel view deallocating all resources sequestered by the kv_t
Expand All @@ -112,6 +113,18 @@ IGA_API void kv_delete(struct kv_t *);
*/
IGA_API int32_t kv_get_inst_size(const struct kv_t *kv, int32_t pc);

/*
* Returns some attributes of a message: if it is atomic, slm, scratch
* operation.
* Returns:
* KV_SUCCESS on success; output is stored to isAtomic and isSlm
* KV_ERROR if kv is invalid
* KV_INVALID_PC if instruction cannot be found
* KV_DECODE_ERROR if an instruction cannot be docoded
*/
IGA_API kv_status_t kv_get_inst_msg_info(const kv_t* kv, int32_t pc,
bool* isAtomic, bool* isSlm, bool* isScratch);

/*
* Returns true if the instruction has the opt
*/
Expand Down Expand Up @@ -307,6 +320,11 @@ IGA_API kv_status_t kv_get_sendg_ind_desc1(const kv_t *kv, int32_t pc,
*/
#define KV_INVALID_SEND_DESC ((uint32_t)0xFFFFFFFFF)

/*
* A symbol to indicate an invalid sendg descriptor value.
*/
#define KV_INVALID_SEND_DESC64B ((uint64_t)0xFFFFFFFFFFFFFFFFL)

/* TODO: review necessity of this macro.
* A symbol to indicate an invalid message length value.
*/
Expand Down
6 changes: 4 additions & 2 deletions include/iga/kv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ class KernelView {
KernelView(
iga_gen_t platf, const void *bytes, size_t bytesLength,
iga::SWSB_ENCODE_MODE swsb_mode = iga::SWSB_ENCODE_MODE::SWSBInvalidMode,
char *decodeLog = nullptr, size_t decodeLogLen = 0)
char *decodeLog = nullptr, size_t decodeLogLen = 0
)
: m_kv(nullptr), m_disasm_status(IGA_SUCCESS), m_gen(platf) {
m_kv = kv_create(platf, bytes, bytesLength, &m_disasm_status, decodeLog,
decodeLogLen, static_cast<uint32_t>(swsb_mode));
decodeLogLen, static_cast<uint32_t>(swsb_mode)
);
}

// The destructor automatically deallocates the underlying kernel view
Expand Down
4 changes: 2 additions & 2 deletions include/igc/OCLAPI/oclapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ SPDX-License-Identifier: MIT
#define OCL_API_CALLS_H

#if defined(_WIN32)
#define OCL_API_CALL
#define OCL_API_CALL
#else
#define OCL_API_CALL __attribute__ ((visibility("default")))
#define OCL_API_CALL __attribute__((visibility("default")))
#endif

#endif // OCL_API_CALLS_H
25 changes: 13 additions & 12 deletions include/igc/cif/cif/builtins/builtins_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ namespace CIF {
namespace Builtins {

// List of all supported builtins
using AllBuiltinsListT = InterfacesList<CIF::Builtins::Buffer>;
using AllBuiltinsListT = InterfacesList<CIF::Builtins::Buffer>;

bool IsBuiltin(InterfaceId_t intId){
return AllBuiltinsListT::ContainsInterface(intId);
}
bool IsBuiltin(InterfaceId_t intId) { return AllBuiltinsListT::ContainsInterface(intId); }

ICIF *Create(InterfaceId_t entryPointInterface, Version_t version, ICIF *parentInterface){
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardCreateInterfaceImpl, ICIF *, ICIF *>(entryPointInterface, nullptr, version, version, parentInterface);
ICIF *Create(InterfaceId_t entryPointInterface, Version_t version, ICIF *parentInterface) {
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardCreateInterfaceImpl, ICIF *, ICIF *>(
entryPointInterface, nullptr, version, version, parentInterface);
}

bool GetSupportedVersions(InterfaceId_t entryPointInterface, Version_t &verMin, Version_t &verMax){
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardGetSupportedVersions, bool>(entryPointInterface, false, verMin, verMax);
bool GetSupportedVersions(InterfaceId_t entryPointInterface, Version_t &verMin, Version_t &verMax) {
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardGetSupportedVersions, bool>(entryPointInterface, false,
verMin, verMax);
}

InterfaceId_t FindIncompatible(InterfaceId_t entryPointInterface, CIF::CompatibilityDataHandle handle){
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardGetFirstIncompatible, InterfaceId_t>(entryPointInterface, entryPointInterface, handle);
InterfaceId_t FindIncompatible(InterfaceId_t entryPointInterface, CIF::CompatibilityDataHandle handle) {
return AllBuiltinsListT::template forwardToOne<Helpers::ForwardGetFirstIncompatible, InterfaceId_t>(
entryPointInterface, entryPointInterface, handle);
}

}
} // namespace Builtins

}
} // namespace CIF
4 changes: 2 additions & 2 deletions include/igc/cif/cif/builtins/builtins_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ bool GetSupportedVersions(InterfaceId_t entryPointInterface, Version_t &verMin,

InterfaceId_t FindIncompatible(InterfaceId_t entryPointInterface, CIF::CompatibilityDataHandle handle);

}
} // namespace Builtins

}
} // namespace CIF
119 changes: 60 additions & 59 deletions include/igc/cif/cif/builtins/memory/buffer/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,53 @@ using AllocatorT = void *(CIF_CALLING_CONV *)(size_t size);
using ReallocatorT = void *(CIF_CALLING_CONV *)(void *oldMemory, size_t oldSize, size_t newSize);

/// Custom deallocator function
using DeallocatorT = void (CIF_CALLING_CONV *)(void *memory);
using DeallocatorT = void(CIF_CALLING_CONV *)(void *memory);

/// Builtin interface that can be used as generic buffer
CIF_DECLARE_COMMON_INTERFACE(Buffer, "CIF_BUFFER");

/// v #1
CIF_DEFINE_INTERFACE_VER(Buffer, 1){
CIF_DEFINE_INTERFACE_VER(Buffer, 1) {
CIF_INHERIT_CONSTRUCTOR();

/// Get address to underlying buffer with ElementT as pointer element type
template<typename ElementT>
ElementT *GetMemoryWriteable(){
return reinterpret_cast<ElementT*>(GetMemoryRawWriteable());
template <typename ElementT> ElementT *GetMemoryWriteable() {
return reinterpret_cast<ElementT *>(GetMemoryRawWriteable());
}

/// Get address to underlying const buffer with ElementT as pointer element type
template<typename ElementT>
const ElementT *GetMemory() const{
return reinterpret_cast<const ElementT*>(GetMemoryRaw());
template <typename ElementT> const ElementT *GetMemory() const {
return reinterpret_cast<const ElementT *>(GetMemoryRaw());
}

/// Get size in units of ElementT (ElementT == void version)
template<typename ElementT>
const typename std::enable_if<std::is_void<ElementT>::value, size_t>::type GetSize() const{
return GetSizeRaw();
template <typename ElementT>
const typename std::enable_if<std::is_void<ElementT>::value, size_t>::type GetSize() const {
return GetSizeRaw();
}

/// Get size in units of ElementT (ElementT != void version)
template<typename ElementT>
const typename std::enable_if<false == std::is_void<ElementT>::value, size_t>::type GetSize() const{
return GetSizeRaw() / sizeof(ElementT);
template <typename ElementT>
const typename std::enable_if<false == std::is_void<ElementT>::value, size_t>::type GetSize() const {
return GetSizeRaw() / sizeof(ElementT);
}

/// Copies given element to the end of the buffer
/// Note : If (packed == false), then this function will automatically align current underlying buffer
/// pointer to alignof(ElementT)
template<typename ElementT>
bool PushBackRawCopy(const ElementT &newEl, bool packed = true){
static_assert(std::is_standard_layout_v<ElementT> && std::is_trivial_v<ElementT> && std::is_trivially_copyable_v<ElementT>, "Supporting only POD types");
if(packed == false){
size_t alignment = alignof(ElementT);
bool success = AlignUp(static_cast<uint32_t>(alignment));
if(success == false){
return false;
}
template <typename ElementT> bool PushBackRawCopy(const ElementT &newEl, bool packed = true) {
static_assert(std::is_standard_layout_v<ElementT> && std::is_trivial_v<ElementT> &&
std::is_trivially_copyable_v<ElementT>,
"Supporting only POD types");
if (packed == false) {
size_t alignment = alignof(ElementT);
bool success = AlignUp(static_cast<uint32_t>(alignment));
if (success == false) {
return false;
}
}

return PushBackRawBytes(&newEl, sizeof(ElementT));
return PushBackRawBytes(&newEl, sizeof(ElementT));
}

/// Sets custom allocator and deallocator functions to be used by this buffer interface
Expand Down Expand Up @@ -135,49 +134,51 @@ CIF_GENERATE_VERSIONS_LIST(Buffer);
CIF_MARK_LATEST_VERSION(BufferLatest, Buffer);
using BufferSimple = Buffer<1>; /// tag the most common version

template<typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateConstBuffer(CIF::CIFMain *provider, const void *data, size_t size){
if(provider == nullptr){
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
auto buff = provider->CreateBuiltin<BufferInterface>();
if(buff == nullptr){
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
if((data != nullptr) && (size != 0)){
buff->SetUnderlyingStorage(data, size);
}
return buff;
template <typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateConstBuffer(CIF::CIFMain *provider, const void *data, size_t size) {
if (provider == nullptr) {
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
auto buff = provider->CreateBuiltin<BufferInterface>();
if (buff == nullptr) {
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
if ((data != nullptr) && (size != 0)) {
buff->SetUnderlyingStorage(data, size);
}
return buff;
}

template<typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateWriteableBuffer(CIF::CIFMain *provider, const void *initialData, size_t initialSize){
auto buff = CreateConstBuffer<BufferInterface>(provider, initialData, initialSize);
if(buff == nullptr){
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
auto writeableMem = buff->GetMemoryRawWriteable();
if(writeableMem == nullptr && (initialData != nullptr && initialSize != 0)){
// failed to allocate new memory in writeable memory
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
return buff;
template <typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateWriteableBuffer(CIF::CIFMain *provider, const void *initialData,
size_t initialSize) {
auto buff = CreateConstBuffer<BufferInterface>(provider, initialData, initialSize);
if (buff == nullptr) {
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
auto writeableMem = buff->GetMemoryRawWriteable();
if (writeableMem == nullptr && (initialData != nullptr && initialSize != 0)) {
// failed to allocate new memory in writeable memory
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
return buff;
}

template<typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateBufferFromPtr(CIF::CIFMain *provider, void *ptr, size_t size, DeallocatorT ptrDeallocator){
auto buff = CreateConstBuffer<BufferInterface>(provider, nullptr, 0);
if(buff == nullptr){
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}
template <typename BufferInterface = BufferLatest>
CIF::RAII::UPtr_t<BufferInterface> CreateBufferFromPtr(CIF::CIFMain *provider, void *ptr, size_t size,
DeallocatorT ptrDeallocator) {
auto buff = CreateConstBuffer<BufferInterface>(provider, nullptr, 0);
if (buff == nullptr) {
return CIF::RAII::UPtr<BufferInterface>(nullptr);
}

buff->SetUnderlyingStorage(ptr, size, ptrDeallocator);
buff->SetUnderlyingStorage(ptr, size, ptrDeallocator);

return buff;
return buff;
}

}
} // namespace Builtins

}
} // namespace CIF

#include "cif/macros/disable.h"
Loading