Make HEAP_CAP and MAX_THREADS configurable via compile-time defines#49
Open
lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
Open
Make HEAP_CAP and MAX_THREADS configurable via compile-time defines#49lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
HEAP_CAP and MAX_THREADS configurable via compile-time defines#49lancejpollard wants to merge 1 commit intoHigherOrderCO:mainfrom
Conversation
Wrap HEAP_CAP and MAX_THREADS in #ifndef guards so embedders can tune them at compile time without modifying source. Add a compile-time check that HEAP_CAP_BITS does not exceed VAL_BITS, since heap addresses must fit in the 38-bit VAL field of a term. Usage: clang -O2 -DHEAP_CAP_BITS=28 -DMAX_THREADS=4 -o main main.c Defaults are unchanged. No behavior change on existing platforms.
c5dd5b8 to
1c1cd8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Wraps
HEAP_CAPandMAX_THREADSin#ifndefguards so they can be overridden at compile time with-Dflags. Adds a compile-time check thatHEAP_CAP_BITSdoes not exceedVAL_BITS.Usage
Without
-Dflags, defaults are identical to current behavior (HEAP_CAP_BITS=38,MAX_THREADS=64).Why
HEAP_CAPis1ULL << 38(256GB virtual). This works on desktop/server but exceeds the address space on some targets:MAX_THREADSis 64. Not all targets have 64 cores. Embedded and mobile targets benefit from a lower default.Making these configurable lets embedders tune for their target without patching source. This also sets a precedent for future platform targets (CUDA #33, Metal #30) that may need different defaults.
Safety
A
#errorfires ifHEAP_CAP_BITS > VAL_BITS, since heap addresses must fit in the 38-bit VAL field of a term.Changes
clang/hvm.conly. 9 lines added, 1 removed. Zero changes to core logic.Risk
Don't think there are any. Defaults are unchanged. Only affects builds that explicitly pass
-Dflags. All existing tests pass.