Makefile: support UNALIGNED_ACCESS_SUPPORTED for RISC-V #1639
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When building on RISC-V, allow users to opt in to unaligned access by setting the UNALIGNED_ACCESS_SUPPORTED This appends
-DUNALIGNED_ACCESS_SUPPORTED to CFLAGS, which in turn enables LZ4_FORCE_MEMORY_ACCESS=2 under RISC-V only.
Usage:
make UNALIGNED_ACCESS_SUPPORTED=1
Reason for modification
During testing, we found that direct access to unaligned memory is currently the best method on RISC-V, similar to the method on ARMv6. However, not all RISC-V servers support unaligned memory, and the GCC compiler does not have a macro to distinguish whether unaligned memory is supported. Therefore, we chose to add a new macro to manually allow users to enable direct access on RISC-V servers that support unaligned memory to achieve performance improvement.
Testing
Testing of this modification on a RISC-V server found that the compression rate increased by 30%. The test data is as follows:
Tool: lzbench
Unaligned_Access_Supported disabled:
Unaligned_Access_Supported enabled: