Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion .github/workflows/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
CMAKE_VERSION: "3.19.2"
ARROW_VERSION: "7.0.0"
ARROW_VERSION: "17.0.0"

jobs:
archive:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
container: quay.io/pypa/manylinux2014_x86_64:latest
env:
CMAKE_VERSION: "3.17.3"
ARROW_VERSION: "7.0.0"
ARROW_VERSION: "17.0.0"
CPYTHON_VERSION: "cp37-cp37m"
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

env:
ARROW_VERSION: "7.0.0"
ARROW_VERSION: "17.0.0"

jobs:
cpp:
Expand Down
2 changes: 1 addition & 1 deletion codegen/cpp/fletchgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(
HOMEPAGE_URL "https://github.com/abs-tudelft/fletcher"
LANGUAGES CXX)

find_package(Arrow 7.0.0 CONFIG REQUIRED)
find_package(Arrow 17.0.0 CONFIG REQUIRED)

include(FindThreads)
include(FetchContent)
Expand Down
2 changes: 1 addition & 1 deletion codegen/cpp/fletchgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It currently supports only two top-level platforms.
# Prerequisites

- [C++17 compliant compiler](https://clang.llvm.org/)
- [Apache Arrow 7.0+](https://github.com/apache/arrow)
- [Apache Arrow 17.0+](https://github.com/apache/arrow)
- [CMake 3.14+](https://cmake.org/)

# Build & install
Expand Down
4 changes: 2 additions & 2 deletions codegen/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def initialize_options(self):
install_requires=[
'numpy >= 1.14',
'pandas',
'pyarrow == 7.0',
'pyarrow == 17.0',
],
setup_requires=[
'cython',
'numpy',
'pyarrow == 7.0.0',
'pyarrow == 17.0.0',
'plumbum'
],
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion common/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(
VERSION 0.0.0
LANGUAGES CXX)

find_package(Arrow 7.0.0 CONFIG REQUIRED)
find_package(Arrow 17.0.0 CONFIG REQUIRED)

include(FetchContent)

Expand Down
4 changes: 2 additions & 2 deletions examples/stringwrite/hardware/generate-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Set field metadata
field_meta = {b'fletcher_epc': b'64'}
string_field = string_field.add_metadata(field_meta)
string_field = string_field.with_metadata(field_meta)

# Create the schema
schema_fields = [string_field]
Expand All @@ -14,7 +14,7 @@
# Set schema metadata
schema_meta = {b'fletcher_mode': b'write',
b'fletcher_name': b'StringWrite'}
schema = schema.add_metadata(schema_meta)
schema = schema.with_metadata(schema_meta)

# Serialize schema to file for fletchgen input
serialized_schema = schema.serialize()
Expand Down
4 changes: 2 additions & 2 deletions examples/stringwrite/hardware/vhdl/SimTop_tc.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ architecture Behavioral of SimTop_tc is
-----------------------------------------------------------------------------
-- Default wrapper component.
-----------------------------------------------------------------------------
component Kernel_Mantle is
component Stringwrite_Mantle is
generic (
INDEX_WIDTH : integer := 32;
TAG_WIDTH : integer := 1;
Expand Down Expand Up @@ -420,7 +420,7 @@ begin
-----------------------------------------------------------------------------
-- Fletcher generated wrapper
-----------------------------------------------------------------------------
Kernel_Mantle_inst : Kernel_Mantle
Kernel_Mantle_inst : Stringwrite_Mantle
generic map (
BUS_ADDR_WIDTH => BUS_ADDR_WIDTH
)
Expand Down
2 changes: 1 addition & 1 deletion examples/stringwrite/software/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ project(
VERSION 0.0.0
LANGUAGES CXX)

find_package(Arrow 7.0.0 CONFIG REQUIRED)
find_package(Arrow 17.0.0 CONFIG REQUIRED)
find_package(fletcher CONFIG)

if(NOT fletcher)
Expand Down
20 changes: 16 additions & 4 deletions examples/stringwrite/software/cpp/src/stringwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,23 @@ std::shared_ptr<arrow::StringArray> DeserializeToArrow(const std::shared_ptr<std

// Allocate space for values buffer
std::shared_ptr<arrow::Buffer> val_buffer;
if (!arrow::AllocateBuffer(values->size(), &val_buffer).ok()) {
auto val_res = arrow::AllocateBuffer(values->size());
if (!val_res.ok()) {
throw std::runtime_error("Could not allocate values buffer.");
} else {
val_buffer = val_res.MoveValueUnsafe();
}

// Copy the values buffer
memcpy(val_buffer->mutable_data(), values->data(), values->size());

// Allocate space for offsets buffer
std::shared_ptr<arrow::Buffer> off_buffer;
if (!arrow::AllocateBuffer((lengths->size() + 1) * sizeof(int32_t), &off_buffer).ok()) {
auto off_res = arrow::AllocateBuffer((lengths->size() + 1) * sizeof(int32_t));
if (!off_res.ok()) {
throw std::runtime_error("Could not allocate offsets buffer.");
} else {
off_buffer = off_res.MoveValueUnsafe();
}

// Lengths need to be converted into offsets
Expand All @@ -140,11 +146,17 @@ std::shared_ptr<arrow::RecordBatch> PrepareRecordBatch(const std::shared_ptr<arr
std::shared_ptr<arrow::Buffer> offsets;
std::shared_ptr<arrow::Buffer> values;

if (!arrow::AllocateBuffer(arrow::default_memory_pool(), sizeof(int32_t) * (num_strings + 1), &offsets).ok()) {
auto off_res = arrow::AllocateBuffer(sizeof(int32_t) * (num_strings + 1));
if (!off_res.ok()) {
throw std::runtime_error("Could not allocate offsets buffer.");
} else {
offsets = off_res.MoveValueUnsafe();
}
if (!arrow::AllocateBuffer(arrow::default_memory_pool(), num_chars, &values).ok()) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've removed the arrow::default_memory_pool() here, assuming it will default to the default (although it doesn't explicitly state in the Arrow doc)

auto val_res = arrow::AllocateBuffer(num_chars);
if (!val_res.ok()) {
throw std::runtime_error("Could not allocate values buffer.");
} else {
values = val_res.MoveValueUnsafe();
}

auto array = std::make_shared<arrow::StringArray>(num_strings, offsets, values);
Expand Down
2 changes: 1 addition & 1 deletion examples/sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open-source tools.
The examples in this part of the tutorial are written in Python, so you'll need

- Install [Python 3.7+](https://www.python.org/).
- Install [PyArrow 7.0+](https://arrow.apache.org/docs/python/).
- Install [PyArrow 17.0+](https://arrow.apache.org/docs/python/).

Furthermore you'll need to build and install Fletchgen - the Fletcher design
generator tool.
Expand Down
2 changes: 1 addition & 1 deletion examples/sum/hardware/generate-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
b'fletcher_name': b'ExampleBatch'}

# Add the metadata to the schema
schema = schema.add_metadata(metadata)
schema = schema.with_metadata(metadata)

# Create a list of PyArrow Arrays. Every Array can be seen
# as a 'Column' of the RecordBatch we will create.
Expand Down
2 changes: 1 addition & 1 deletion examples/sum/hardware/generate-schema.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
" b'fletcher_name': b'ExampleBatch'}\n",
"\n",
"# Add the metadata to the schema\n",
"schema = schema.add_metadata(metadata)\n",
"schema = schema.with_metadata(metadata)\n",
"\n",
"# Show the schema\n",
"print(schema)"
Expand Down
2 changes: 1 addition & 1 deletion examples/sum/software/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ project(
VERSION 0.0.0
LANGUAGES CXX)

find_package(Arrow 7.0 CONFIG REQUIRED)
find_package(Arrow 17.0 CONFIG REQUIRED)
find_package(fletcher CONFIG)

if(NOT fletcher)
Expand Down
6 changes: 5 additions & 1 deletion examples/sum/software/cpp/src/sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ int main(int argc, char **argv) {
std::cerr << "Could not obtain the return value." << std::endl;
return -1;
}
// combine the 2 32-bit values into the 64-bit endresult
int64_t result = return_value_0;
result |= static_cast<int64_t>(return_value_1) << 32;


// Print the return value.
std::cout << *reinterpret_cast<int32_t*>(&return_value_0) << std::endl;
std::cout << result << std::endl;

return 0;
}
28 changes: 25 additions & 3 deletions runtime/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(
HOMEPAGE_URL "https://github.com/abs-tudelft/fletcher"
LANGUAGES CXX)

find_package(Arrow 7.0.0 CONFIG REQUIRED)
find_package(Arrow 17.0.0 CONFIG REQUIRED)

include(FetchContent)

Expand Down Expand Up @@ -77,6 +77,28 @@ add_compile_unit(

compile_units()

install(TARGETS fletcher fletcher_c fletcher_common

@joosthooz joosthooz Aug 4, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These new install cmds are added to add a CMake config file that projects look for when trying to use fletcher. I'm honestly not fully sure how these are supposed to look like, so I followed a minimal example and it seems to work.

EXPORT fletcherTargets
FILE_SET HEADERS
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)

install(EXPORT fletcherTargets
FILE fletcherTargets.cmake
NAMESPACE fletcher::
DESTINATION lib/cmake/fletcher)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"fletcherConfigVersion.cmake"
VERSION ${fletcher_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES "fletcherConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/fletcherConfigVersion.cmake"
DESTINATION lib/cmake/fletcher)

execute_process(
COMMAND bash -c
"awk -F= '/^ID=/{print $2}' /etc/os-release |tr -d '\n' | tr -d '\"'"
Expand Down Expand Up @@ -109,14 +131,14 @@ set(CPACK_PACKAGE_RELOCATABLE ON)

set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"libarrow-dev (>= 7.0.0), libarrow-dev (<< 8.0.0)")
"libarrow-dev (>= 17.0.0), libarrow-dev (<< 18.0.0)")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")

set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
# fletcher-devel
set(CPACK_RPM_PACKAGE_REQUIRES "arrow-devel >= 7.0.0, arrow-devel < 8.0.0")
set(CPACK_RPM_PACKAGE_REQUIRES "arrow-devel >= 17.0.0, arrow-devel < 18.0.0")

set(CPACK_ARCHIVE_LIBRARY_FILE_NAME
"${CMAKE_PROJECT_NAME}-${fletcher_VERSION}-${CMAKE_SYSTEM_NAME}")
Expand Down
2 changes: 1 addition & 1 deletion runtime/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ applications.

## Requirements

- [Apache Arrow 7.0+ C++ run-time and development headers.](https://arrow.apache.org/install)
- [Apache Arrow 17.0+ C++ run-time and development headers.](https://arrow.apache.org/install)
- A C++17 compliant compiler
- CMake 3.14

Expand Down
3 changes: 3 additions & 0 deletions runtime/cpp/fletcherConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
find_dependency(Arrow)
include(${CMAKE_CURRENT_LIST_DIR}/fletcherTargets.cmake)
20 changes: 10 additions & 10 deletions runtime/cpp/include/fletcher/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ class Platform {
Status MmioToString(std::string *str, uint64_t start, uint64_t stop, bool quiet = false);

/// @brief Initialize the platform.
inline Status Init() { return Status(platformInit(init_data)); }
Status Init() { return Status(platformInit(init_data)); }

/**
* @brief Write to an MMIO register.
* @param[in] offset Register offset to write to.
* @param[in] value Value to write.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status WriteMMIO(uint64_t offset, uint32_t value) { return Status(platformWriteMMIO(offset, value)); }
Status WriteMMIO(uint64_t offset, uint32_t value) { return Status(platformWriteMMIO(offset, value)); }

/**
* @brief Read from an MMIO register.
* @param[in] offset Register offset to read from.
* @param[out] value Pointer to a value to store the result.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status ReadMMIO(uint64_t offset, uint32_t *value) { return Status(platformReadMMIO(offset, value)); }
Status ReadMMIO(uint64_t offset, uint32_t *value) { return Status(platformReadMMIO(offset, value)); }

/**
* @brief Read 64 bit value from two successive 32 bit MMIO registers. The lower register will go to the lower bits.
Expand All @@ -96,7 +96,7 @@ class Platform {
* @param[in] size The amount of bytes to allocate
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status DeviceMalloc(da_t *device_address, size_t size) {
Status DeviceMalloc(da_t *device_address, size_t size) {
return Status(platformDeviceMalloc(device_address, size));
}

Expand All @@ -105,7 +105,7 @@ class Platform {
* @param[in] device_address The device address of the memory region.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status DeviceFree(da_t device_address) { return Status(platformDeviceFree(device_address)); }
Status DeviceFree(da_t device_address) { return Status(platformDeviceFree(device_address)); }

/**
* @brief Copy data from host memory to device memory.
Expand All @@ -114,7 +114,7 @@ class Platform {
* @param[in] size The amount of bytes to copy.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status CopyHostToDevice(uint8_t *host_source, da_t device_destination, uint64_t size) {
Status CopyHostToDevice(uint8_t *host_source, da_t device_destination, uint64_t size) {
return Status(platformCopyHostToDevice(host_source, device_destination, size));
}

Expand All @@ -125,7 +125,7 @@ class Platform {
* @param[in] size The amount of bytes to copy.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status CopyDeviceToHost(da_t device_source, uint8_t *host_destination, uint64_t size) {
Status CopyDeviceToHost(da_t device_source, uint8_t *host_destination, uint64_t size) {
return Status(platformCopyDeviceToHost(device_source, host_destination, size));
}

Expand All @@ -137,7 +137,7 @@ class Platform {
* @param[out] alloced Whether or not an allocation was made in device memory (that needs to be freed).
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status PrepareHostBuffer(const uint8_t *host_source, da_t *device_destination, int64_t size, bool *alloced) {
Status PrepareHostBuffer(const uint8_t *host_source, da_t *device_destination, int64_t size, bool *alloced) {
assert(platformPrepareHostBuffer != nullptr);
int ll_alloced = 0;
auto stat = platformPrepareHostBuffer(host_source, device_destination, size, &ll_alloced);
Expand All @@ -152,7 +152,7 @@ class Platform {
* @param[in] size The amount of bytes to copy.
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status CacheHostBuffer(const uint8_t *host_source, da_t *device_destination, int64_t size) {
Status CacheHostBuffer(const uint8_t *host_source, da_t *device_destination, int64_t size) {
assert(platformCacheHostBuffer != nullptr);
return Status(platformCacheHostBuffer(host_source, device_destination, size));
}
Expand All @@ -161,7 +161,7 @@ class Platform {
* @brief Terminate the platform
* @return Status::OK() if successful, otherwise a descriptive error status.
*/
inline Status Terminate() {
Status Terminate() {
assert(platformTerminate != nullptr);
terminated = true;
return Status(platformTerminate(terminate_data));
Expand Down
Loading
Loading