Conversation
|
I still need to update the CI build and test scripts because the Mac (as per) needs some more TLC to get it right. |
1377afa to
1f36f1d
Compare
This reverts commit c212a5f.
…o see something.)
73ecdc6 to
8bdf70d
Compare
nclack
left a comment
There was a problem hiding this comment.
Left some comments. Be sure to break the performance improvements into multiple pr's if you can.
src/streaming/array.writer.cpp
Outdated
| size_t bytes_written = 0; | ||
| const auto n_tiles = n_tiles_x * n_tiles_y; | ||
|
|
||
| #pragma omp parallel for reduction(+ : bytes_written) |
There was a problem hiding this comment.
Check this with a benchmark, but this will scale better if you make bytes_written an atomic and a plain old parallel for.
Most of the work here is not involved with the reduction, and the way reductions get parallelized might be limiting.
Maybe omp figures this out for you, but it's better not to rely on that.
There was a problem hiding this comment.
I actually see significant improvement with the reduction.
- atomic: 1.081 GiB/s
- reduction: 1.354 GiB/s
I ran multiple times and saw similar numbers.
src/streaming/file.sink.cpp
Outdated
| : file_(filename.data(), | ||
| truncate ? (std::ios::binary | std::ios::trunc) : std::ios::binary) | ||
| namespace { | ||
| #ifdef _WIN32 |
There was a problem hiding this comment.
If there's a way to factor out the platform-dependent things into their own source files, it makes the code much easier to read and maintain.
| #undef min | ||
| #endif | ||
|
|
||
| #ifdef max |
There was a problem hiding this comment.
You might be able to just say #undef without needing the #ifdef.
More importantly, where are these symbols leaking in from? If possible you should handle this as close to the source as possible.
This reverts commit 687efc0.
79bf22c to
ce52121
Compare
jeskesen
left a comment
There was a problem hiding this comment.
Trying to remove my "approve", because I hit it accidentally before.
shlomnissan
left a comment
There was a problem hiding this comment.
I’ve flagged one potential bug — it looks like the wrong pointer might be getting deleted, so I’m requesting changes just to ensure that’s double-checked.
Beyond that, I think there’s a lot of room to improve the robustness and readability of the code. The manual pointer management, in particular, feels risky and could lead to maintenance issues. If possible, I'd recommend avoiding raw pointers in favor of safer patterns.
That said, the rest of my comments are just suggestions — feel free to weigh them against your judgment.
| # Apple Silicon | ||
| set(LIBOMP_PATH "/opt/homebrew/opt/libomp") | ||
| set(CMAKE_OSX_ARCHITECTURES "arm64") | ||
| else () |
There was a problem hiding this comment.
This might be overkill since it handles 99% of cases, but if you want to be defensive, you could improve this by:
- Making the architecture checks case-insensitive
- Adding a fallback for unknown architectures (e.g. older or future variants)
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Aa][Rr][Mm]64")
set(ARCH "arm64")
set(LIBOMP_PATH "/opt/homebrew/opt/libomp")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^[Xx]86_64")
set(ARCH "x86_64")
set(LIBOMP_PATH "/usr/local/opt/libomp")
else()
message(WARNING "Unknown architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(ARCH "${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()| endif () | ||
|
|
||
| # OpenMP support | ||
| set(OpenMP_C_FLAGS "-Xclang -fopenmp -I${LIBOMP_PATH}/include") |
There was a problem hiding this comment.
Is OpenMP being used in the C code as well?
There was a problem hiding this comment.
Not at this point, but in case any is added down the line I don't want the configuration to break inexplicably for future users.
| - name: Install vcpkg | ||
| run: | | ||
| git clone https://github.com/microsoft/vcpkg.git | ||
| git clone https://github.com/microsoft/vcpkg.git -b 2025.02.14 |
There was a problem hiding this comment.
Out of curiosity — what’s the reason for tagging vcpkg here?
| ./vcpkg integrate install | ||
| shell: bash | ||
|
|
||
| - name: Install OpenMP |
There was a problem hiding this comment.
I'd recommend renaming this task to "Install OpenMP on macOS" to make the platform-specific purpose clearer. The same comment applies to all instances in this PR.
src/streaming/file.sink.cpp
Outdated
| : file_(filename.data(), | ||
| truncate ? (std::ios::binary | std::ios::trunc) : std::ios::binary) | ||
| namespace { | ||
| #ifdef _WIN32 |
248a378 to
bf1bc86
Compare
|
Thanks for comments @nclack @shlomnissan. I've made the following changes:
|
shlomnissan
left a comment
There was a problem hiding this comment.
Unblocking now that the bug is fixed.
ArrayDimension.forloop inArrayWriter::write_frame_to_chunks_()in a#pragma omp parallel for.