diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebf086bd..e0b70061 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,10 +22,9 @@ jobs: - name: Install sac2c run: | git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git - cd sac2c && mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=RELEASE .. - make -j2 - cp sac2c_p /usr/local/bin/sac2c + cd sac2c + make release -j2 + cp build_p/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Create build dir run: | @@ -64,10 +63,9 @@ jobs: - name: Install sac2c run: | git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git - cd sac2c && mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=RELEASE .. - make -j2 - cp sac2c_p /usr/local/bin/sac2c + cd sac2c + make release -j2 + cp build_p/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Create build dir run: | @@ -106,10 +104,9 @@ jobs: - name: Install sac2c run: | git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git - cd sac2c && mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=RELEASE .. - make -j2 - cp sac2c_p /usr/local/bin/sac2c + cd sac2c + make release -j2 + cp build_p/sac2c_p /usr/local/bin/sac2c sac2c -V - name: Create build dir run: | diff --git a/src/numerical/ComplexMath.sac b/src/numerical/ComplexMath.sac index 4d809d35..d941ff3b 100644 --- a/src/numerical/ComplexMath.sac +++ b/src/numerical/ComplexMath.sac @@ -1,3 +1,4 @@ +#pragma safe module ComplexMath; export all; diff --git a/src/numerical/Math.sac b/src/numerical/Math.sac index d2ef791c..12fe7f97 100644 --- a/src/numerical/Math.sac +++ b/src/numerical/Math.sac @@ -1,3 +1,4 @@ +#pragma safe module Math; use ScalarArith: all; @@ -245,7 +246,8 @@ external float, float modf(float X); * ******************************************************************************/ -inline int pow2(int a) { +inline int pow2(int a) +{ return _shl_SxS_(1, a); } diff --git a/src/numerical/MathArray.sac b/src/numerical/MathArray.sac index fce2abc4..7f1a3f22 100644 --- a/src/numerical/MathArray.sac +++ b/src/numerical/MathArray.sac @@ -1,3 +1,4 @@ +#pragma safe module MathArray; export all; diff --git a/src/numerical/Numerical.sac b/src/numerical/Numerical.sac index f98679d1..b150a3d2 100644 --- a/src/numerical/Numerical.sac +++ b/src/numerical/Numerical.sac @@ -1,3 +1,4 @@ +#pragma safe module Numerical; import Math: all; diff --git a/src/random/Xoshiro.sac b/src/random/Xoshiro.sac index 0d846153..a5f60965 100644 --- a/src/random/Xoshiro.sac +++ b/src/random/Xoshiro.sac @@ -1,24 +1,25 @@ -/** +/****************************************************************************** + * * # Introduction * - * This module implements pseudo-random number generators (PRNGs) for - * Monte-Carlo simulations and related algorithms. As of April 2025, - * the Xoshiro family is state of the art. We currently do not offer + * This module implements pseudo-random number generators (PRNGs) for + * Monte-Carlo simulations and related algorithms. As of April 2025, + * the Xoshiro family is state of the art. We currently do not offer * cryptographically-secure PRNGS. - * + * * A PRNG is a function [state space] -> [unsigned int type] x [state space] - * The unsigned integer can be converted to a real (float or double) of - * various distributions. + * The unsigned integer can be converted to a real (float or double) of + * various distributions. * * # API * * The 64-bit version has an l-suffix to avoid name conflicts. - * + * * ## Basic * * For generating double * ulong, struct State256 xoshiro256p(struct State256 state) - * + * * For generating float * uint, struct State128 xoshiro128p(struct State128 state) * @@ -39,7 +40,7 @@ * float , float to_normal(uint u1, uint u2, float mean, float stddev) * * ## Multithreading - * + * * For parallel exeuction, we can generate an array of * states that are 2^192, 2^96 apart * This can be created with @@ -79,13 +80,15 @@ * of SIMD-lanes, but struct is not yet mature enough to compile this * efficiently. * TODO: The parallel method allocates and copies the rows. - **/ - + * + ******************************************************************************/ +#pragma safe module Xoshiro; -use Array: all; +use ScalarArith: all; use Math: all; -export all except {rotl, splitmix64, srand_time}; + +export all except { rotl, splitmix64, srand_time }; struct State256 { ulong s0l; @@ -180,7 +183,7 @@ struct State256 jumpl(struct State256 state) LOOP_BODY_ULONG(1) LOOP_BODY_ULONG(2) LOOP_BODY_ULONG(3) - + return State256 {.s0l = s0, .s1l = s1, .s2l = s2, .s3l = s3}; } @@ -213,7 +216,7 @@ struct State128 jump(struct State128 state) LOOP_BODY_UINT(1) LOOP_BODY_UINT(2) LOOP_BODY_UINT(3) - + return State128 {.s0 = s0, .s1 = s1, .s2 = s2, .s3 = s3}; } @@ -267,7 +270,7 @@ double, double to_normal(ulong u1, ulong u2, double mean, double stddev) { U1 = to_uniform(u1, 0d, 1d); U2 = to_uniform(u2, 0d, 1d); - + Z1 = sqrt(-2d * log(U1)) * cos(2d * pi() * U2); Z2 = sqrt(-2d * log(U1)) * sin(2d * pi() * U2); @@ -279,7 +282,7 @@ float, float to_normal(uint u1, uint u2, float mean, float stddev) { U1 = to_uniform(u1, 0f, 1f); U2 = to_uniform(u2, 0f, 1f); - + Z1 = sqrt(-2f * log(U1)) * cos(2f * tof(pi()) * U2); Z2 = sqrt(-2f * log(U1)) * sin(2f * tof(pi()) * U2); @@ -300,7 +303,7 @@ external ulong srand_time(); struct State256 srand256() { - s0 = srand_time(); + s0 = srand_time(); s1 = splitmix64(s0); s2 = splitmix64(s1); s3 = splitmix64(s2); @@ -310,11 +313,11 @@ struct State256 srand256() struct State128 srand128() { - s0 = srand_time(); + s0 = srand_time(); s1 = splitmix64(s0); s2 = splitmix64(s1); s3 = splitmix64(s2); - return State128 {.s0 = _toui_S_(s0), .s1 = _toui_S_(s1), + return State128 {.s0 = _toui_S_(s0), .s1 = _toui_S_(s1), .s2 = _toui_S_(s2), .s3 = _toui_S_(s3)}; } diff --git a/src/structures/Array.sac b/src/structures/Array.sac index be12fae9..a696427b 100644 --- a/src/structures/Array.sac +++ b/src/structures/Array.sac @@ -2,6 +2,7 @@ module Array; +import ScalarArith: all; import ArrayArith: all; import ArrayBasics: all; import ArrayReduce: all; @@ -11,7 +12,4 @@ import ArrayTransform: all; import ArrayTransformApl: all; #endif /* EXT_STDLIB */ -// Do not import ScalarArith again; it is already imported through ArrayArith -// import ScalarArith: all; - export all; diff --git a/src/structures/ArrayArith.xsac b/src/structures/ArrayArith.xsac index d672b4d8..f6d841fc 100644 --- a/src/structures/ArrayArith.xsac +++ b/src/structures/ArrayArith.xsac @@ -2,8 +2,6 @@ module ArrayArith; -import ScalarArith: all; - export all; #include "builtin.mac" @@ -64,21 +62,21 @@ b[d>0:shp] name(a A, a[d>0:shp] B) \ #define MAP_BIN_INT_VxV(name, op) \ inline \ -int[n] (name)(int[n] A, int[n] B) \ +int[n] name(int[n] A, int[n] B) \ { \ return _##op##_VxV_(A, B); \ } #define MAP_BIN_INT_VxS(name, op) \ inline \ -int[n] (name)(int[n] A, int B) \ +int[n] name(int[n] A, int B) \ { \ return _##op##_VxS_(A, B); \ } #define MAP_BIN_INT_SxV(name, op) \ inline \ -int[n] (name)(int A, int[n] B) \ +int[n] name(int A, int[n] B) \ { \ return _##op##_SxV_(A, B); \ } diff --git a/src/structures/Quaternion.xsac b/src/structures/Quaternion.xsac index a9c3d0dd..ef12347d 100644 --- a/src/structures/Quaternion.xsac +++ b/src/structures/Quaternion.xsac @@ -1,3 +1,4 @@ +#pragma safe module Quaternion; export all;