-
-
Notifications
You must be signed in to change notification settings - Fork 12
QuadDtype finfo support & Nightly CI #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SwayamInSync
wants to merge
18
commits into
numpy:main
Choose a base branch
from
SwayamInSync:finfo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fea68bd
small init fixes
SwayamInSync 317a961
small changes to reinstall.sh
SwayamInSync 8ba5167
constant refactor and initial finfo support
SwayamInSync cf9067a
nightlty ci test
SwayamInSync 65b5007
test-2
SwayamInSync 3707596
remove py3.10
SwayamInSync 773c945
dep fix
SwayamInSync 76c76c0
fixing typing comments
SwayamInSync df811f8
window fix && test fix
SwayamInSync c8bad4d
use --no-deps
SwayamInSync 6dbc411
use wheels instead of package
SwayamInSync 6e82b8a
ubuntu 24.04 with --break-system-packages)
SwayamInSync b10bae2
BECI:no update pip in ubuntu 24.04
SwayamInSync ab06d22
build from source in ppc machine
SwayamInSync 88ea5ed
--no-deps at test
SwayamInSync 40a66a5
argh syntax
SwayamInSync 7185807
memcpy in case unaligned
SwayamInSync e2d4778
cleaned finfo tests
SwayamInSync File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#ifndef QUAD_CONSTANTS_HPP | ||
#define QUAD_CONSTANTS_HPP | ||
|
||
#include <sleef.h> | ||
#include <sleefquad.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
// Quad precision constants using sleef_q macro | ||
SwayamInSync marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#define QUAD_PRECISION_ZERO sleef_q(+0x0000000000000LL, 0x0000000000000000ULL, -16383) | ||
#define QUAD_PRECISION_ONE sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, 0) | ||
#define QUAD_PRECISION_INF sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, 16384) | ||
#define QUAD_PRECISION_NINF sleef_q(-0x1000000000000LL, 0x0000000000000000ULL, 16384) | ||
#define QUAD_PRECISION_NAN sleef_q(+0x1ffffffffffffLL, 0xffffffffffffffffULL, 16384) | ||
|
||
// Additional constants | ||
#define QUAD_PRECISION_MAX_FINITE SLEEF_QUAD_MAX | ||
#define QUAD_PRECISION_MIN_FINITE Sleef_negq1(SLEEF_QUAD_MAX) | ||
#define QUAD_PRECISION_RADIX sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, 1) // 2.0 | ||
|
||
#ifdef SLEEF_QUAD_C | ||
static const Sleef_quad SMALLEST_SUBNORMAL_VALUE = SLEEF_QUAD_DENORM_MIN; | ||
#else | ||
static const union { | ||
struct { | ||
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) | ||
uint64_t h, l; | ||
#else | ||
uint64_t l, h; | ||
#endif | ||
} parts; | ||
Sleef_quad value; | ||
} smallest_subnormal_const = {.parts = { | ||
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) | ||
.h = 0x0000000000000000ULL, .l = 0x0000000000000001ULL | ||
#else | ||
.l = 0x0000000000000001ULL, .h = 0x0000000000000000ULL | ||
#endif | ||
}}; | ||
#define SMALLEST_SUBNORMAL_VALUE (smallest_subnormal_const.value) | ||
#endif | ||
|
||
// Integer constants for finfo | ||
#define QUAD_NMANT 112 // mantissa bits (excluding implicit bit) | ||
#define QUAD_MIN_EXP -16382 // minimum exponent for normalized numbers | ||
#define QUAD_MAX_EXP 16384 // maximum exponent | ||
#define QUAD_DECIMAL_DIGITS 33 // decimal digits of precision | ||
|
||
typedef enum ConstantResultType { | ||
CONSTANT_QUAD, // Sleef_quad value | ||
CONSTANT_INT64, // int64_t value | ||
CONSTANT_ERROR // Error occurred | ||
} ConstantResultType; | ||
|
||
typedef struct ConstantResult { | ||
ConstantResultType type; | ||
union { | ||
Sleef_quad quad_value; | ||
int64_t int_value; | ||
} data; | ||
} ConstantResult; | ||
|
||
|
||
static inline ConstantResult get_sleef_constant_by_name(const char* constant_name) { | ||
ConstantResult result; | ||
|
||
if (strcmp(constant_name, "pi") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_PIq; | ||
} | ||
else if (strcmp(constant_name, "e") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_Eq; | ||
} | ||
else if (strcmp(constant_name, "log2e") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_LOG2Eq; | ||
} | ||
else if (strcmp(constant_name, "log10e") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_LOG10Eq; | ||
} | ||
else if (strcmp(constant_name, "ln2") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_LN2q; | ||
} | ||
else if (strcmp(constant_name, "ln10") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_M_LN10q; | ||
} | ||
else if (strcmp(constant_name, "max_value") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_QUAD_MAX; | ||
} | ||
else if (strcmp(constant_name, "epsilon") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_QUAD_EPSILON; | ||
} | ||
else if (strcmp(constant_name, "smallest_normal") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SLEEF_QUAD_MIN; | ||
} | ||
else if (strcmp(constant_name, "smallest_subnormal") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
result.data.quad_value = SMALLEST_SUBNORMAL_VALUE; | ||
} | ||
else if (strcmp(constant_name, "bits") == 0) { | ||
result.type = CONSTANT_INT64; | ||
result.data.int_value = sizeof(Sleef_quad) * 8; | ||
} | ||
else if (strcmp(constant_name, "precision") == 0) { | ||
result.type = CONSTANT_INT64; | ||
// precision = int(-log10(epsilon)) | ||
result.data.int_value = | ||
Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); | ||
} | ||
else if (strcmp(constant_name, "resolution") == 0) { | ||
result.type = CONSTANT_QUAD; | ||
// precision = int(-log10(epsilon)) | ||
int64_t precision = | ||
Sleef_cast_to_int64q1(Sleef_negq1(Sleef_log10q1_u10(SLEEF_QUAD_EPSILON))); | ||
// resolution = 10 ** (-precision) | ||
result.data.quad_value = | ||
Sleef_powq1_u10(Sleef_cast_from_int64q1(10), Sleef_cast_from_int64q1(-precision)); | ||
} | ||
else { | ||
result.type = CONSTANT_ERROR; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
#endif // QUAD_CONSTANTS_HPP |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is dropping support for Python 3.10 entirely really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NumPy nightly wheels aren't available for 3.10. Even the LTS version 2.3.3 also only comes for 3.11-3.14
So I guess we are fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I get to upgrade my package then (yay less typing_extensions imports) once this big improvement lands (3.10 is unfortunately still used a lot in our national HPC)