Skip to content

Feature/oro 0 precomp zstd#121

Merged
KaoCC merged 3 commits intomainfrom
feature/ORO-0-precomp-zstd
Apr 25, 2025
Merged

Feature/oro 0 precomp zstd#121
KaoCC merged 3 commits intomainfrom
feature/ORO-0-precomp-zstd

Conversation

@RichardGe
Copy link
Copy Markdown
Collaborator

@RichardGe RichardGe commented Apr 22, 2025

This allows us to compress the precompiled kernels that are embedded inside the HIPRT DLL.

Comment thread Orochi/OrochiUtils.cpp Outdated
OROASSERT( e == oroSuccess, 0 );
}

void OrochiUtils::DecompressPrecompiled(std::vector<unsigned char>& out, const unsigned char* compressedInput, size_t compressedInput_sizeByte, size_t uncompressed_sizeByte)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API relies on the special value (uncompressed_sizeByte > 0) to decide which action to take, which would be error-prone and not very user-friendly.

I suggest to change it to one of the followings:

Create another function to handle the "NOT compressed" case, and let this function to solely handle the data that are "compressed". Or you can rename the function and utilize function overloading.

  1. Rename the function (Maybe call it "HandlePrecompiled" ), and use std::optional ( e.g., std::optional<size_t> uncompressed_sizeByte = std::nullopt)

and then you can check it like this:

if (uncompressed_sizeByte.has_value()) {
    // handle decompression
} else {
    // treat as raw input
}

Wrap the input into different structures:

struct CompressedBuffer {
    const unsigned char* data;
    size_t size;
    size_t uncompressedSize;
};

struct RawBuffer {
    const unsigned char* data;
    size_t size;
};

And then you use function overloading such as:

static void HandlePrecompiled(std::vector<unsigned char>& out, const CompressedBuffer& buffer);
static void HandlePrecompiled(std::vector<unsigned char>& out, const RawBuffer& buffer);

@KaoCC KaoCC merged commit 4c9d8c6 into main Apr 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants