Get rid of most of the various inline macros.
This commit is contained in:
committed by
David Goldblatt
parent
7d86c92c61
commit
4d2e4bf5eb
@@ -33,8 +33,8 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* @file SFMT-alti.h
|
||||
/**
|
||||
* @file SFMT-alti.h
|
||||
*
|
||||
* @brief SIMD oriented Fast Mersenne Twister(SFMT)
|
||||
* pseudorandom number generator
|
||||
@@ -95,7 +95,7 @@ vector unsigned int vec_recursion(vector unsigned int a,
|
||||
* This function fills the internal state array with pseudorandom
|
||||
* integers.
|
||||
*/
|
||||
JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
|
||||
static inline void gen_rand_all(sfmt_t *ctx) {
|
||||
int i;
|
||||
vector unsigned int r, r1, r2;
|
||||
|
||||
@@ -119,10 +119,10 @@ JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
|
||||
* This function fills the user-specified array with pseudorandom
|
||||
* integers.
|
||||
*
|
||||
* @param array an 128-bit array to be filled by pseudorandom numbers.
|
||||
* @param array an 128-bit array to be filled by pseudorandom numbers.
|
||||
* @param size number of 128-bit pesudorandom numbers to be generated.
|
||||
*/
|
||||
JEMALLOC_INLINE void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
|
||||
static inline void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
|
||||
int i, j;
|
||||
vector unsigned int r, r1, r2;
|
||||
|
||||
@@ -173,7 +173,7 @@ JEMALLOC_INLINE void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
|
||||
* @param array an 128-bit array to be swaped.
|
||||
* @param size size of 128-bit array.
|
||||
*/
|
||||
JEMALLOC_INLINE void swap(w128_t *array, int size) {
|
||||
static inline void swap(w128_t *array, int size) {
|
||||
int i;
|
||||
const vector unsigned char perm = ALTI_SWAP;
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* @file SFMT-sse2.h
|
||||
* @brief SIMD oriented Fast Mersenne Twister(SFMT) for Intel SSE2
|
||||
*
|
||||
@@ -60,10 +60,10 @@
|
||||
* @param mask 128-bit mask
|
||||
* @return output
|
||||
*/
|
||||
JEMALLOC_ALWAYS_INLINE __m128i mm_recursion(__m128i *a, __m128i *b,
|
||||
JEMALLOC_ALWAYS_INLINE __m128i mm_recursion(__m128i *a, __m128i *b,
|
||||
__m128i c, __m128i d, __m128i mask) {
|
||||
__m128i v, x, y, z;
|
||||
|
||||
|
||||
x = _mm_load_si128(a);
|
||||
y = _mm_srli_epi32(*b, SR1);
|
||||
z = _mm_srli_si128(c, SR2);
|
||||
@@ -81,7 +81,7 @@ JEMALLOC_ALWAYS_INLINE __m128i mm_recursion(__m128i *a, __m128i *b,
|
||||
* This function fills the internal state array with pseudorandom
|
||||
* integers.
|
||||
*/
|
||||
JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
|
||||
static inline void gen_rand_all(sfmt_t *ctx) {
|
||||
int i;
|
||||
__m128i r, r1, r2, mask;
|
||||
mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
|
||||
@@ -108,10 +108,10 @@ JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
|
||||
* This function fills the user-specified array with pseudorandom
|
||||
* integers.
|
||||
*
|
||||
* @param array an 128-bit array to be filled by pseudorandom numbers.
|
||||
* @param array an 128-bit array to be filled by pseudorandom numbers.
|
||||
* @param size number of 128-bit pesudorandom numbers to be generated.
|
||||
*/
|
||||
JEMALLOC_INLINE void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
|
||||
static inline void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
|
||||
int i, j;
|
||||
__m128i r, r1, r2, mask;
|
||||
mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
|
||||
|
@@ -81,76 +81,62 @@ const char *get_idstring(void);
|
||||
int get_min_array_size32(void);
|
||||
int get_min_array_size64(void);
|
||||
|
||||
#ifndef JEMALLOC_ENABLE_INLINE
|
||||
double to_real1(uint32_t v);
|
||||
double genrand_real1(sfmt_t *ctx);
|
||||
double to_real2(uint32_t v);
|
||||
double genrand_real2(sfmt_t *ctx);
|
||||
double to_real3(uint32_t v);
|
||||
double genrand_real3(sfmt_t *ctx);
|
||||
double to_res53(uint64_t v);
|
||||
double to_res53_mix(uint32_t x, uint32_t y);
|
||||
double genrand_res53(sfmt_t *ctx);
|
||||
double genrand_res53_mix(sfmt_t *ctx);
|
||||
#endif
|
||||
|
||||
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(SFMT_C_))
|
||||
/* These real versions are due to Isaku Wada */
|
||||
/** generates a random number on [0,1]-real-interval */
|
||||
JEMALLOC_INLINE double to_real1(uint32_t v) {
|
||||
static inline double to_real1(uint32_t v) {
|
||||
return v * (1.0/4294967295.0);
|
||||
/* divided by 2^32-1 */
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1]-real-interval */
|
||||
JEMALLOC_INLINE double genrand_real1(sfmt_t *ctx) {
|
||||
static inline double genrand_real1(sfmt_t *ctx) {
|
||||
return to_real1(gen_rand32(ctx));
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1)-real-interval */
|
||||
JEMALLOC_INLINE double to_real2(uint32_t v) {
|
||||
static inline double to_real2(uint32_t v) {
|
||||
return v * (1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1)-real-interval */
|
||||
JEMALLOC_INLINE double genrand_real2(sfmt_t *ctx) {
|
||||
static inline double genrand_real2(sfmt_t *ctx) {
|
||||
return to_real2(gen_rand32(ctx));
|
||||
}
|
||||
|
||||
/** generates a random number on (0,1)-real-interval */
|
||||
JEMALLOC_INLINE double to_real3(uint32_t v) {
|
||||
static inline double to_real3(uint32_t v) {
|
||||
return (((double)v) + 0.5)*(1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/** generates a random number on (0,1)-real-interval */
|
||||
JEMALLOC_INLINE double genrand_real3(sfmt_t *ctx) {
|
||||
static inline double genrand_real3(sfmt_t *ctx) {
|
||||
return to_real3(gen_rand32(ctx));
|
||||
}
|
||||
/** These real versions are due to Isaku Wada */
|
||||
|
||||
/** generates a random number on [0,1) with 53-bit resolution*/
|
||||
JEMALLOC_INLINE double to_res53(uint64_t v) {
|
||||
static inline double to_res53(uint64_t v) {
|
||||
return v * (1.0/18446744073709551616.0L);
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1) with 53-bit resolution from two
|
||||
* 32 bit integers */
|
||||
JEMALLOC_INLINE double to_res53_mix(uint32_t x, uint32_t y) {
|
||||
static inline double to_res53_mix(uint32_t x, uint32_t y) {
|
||||
return to_res53(x | ((uint64_t)y << 32));
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1) with 53-bit resolution
|
||||
*/
|
||||
JEMALLOC_INLINE double genrand_res53(sfmt_t *ctx) {
|
||||
static inline double genrand_res53(sfmt_t *ctx) {
|
||||
return to_res53(gen_rand64(ctx));
|
||||
}
|
||||
|
||||
/** generates a random number on [0,1) with 53-bit resolution
|
||||
using 32bit integer.
|
||||
*/
|
||||
JEMALLOC_INLINE double genrand_res53_mix(sfmt_t *ctx) {
|
||||
static inline double genrand_res53_mix(sfmt_t *ctx) {
|
||||
uint32_t x, y;
|
||||
|
||||
x = gen_rand32(ctx);
|
||||
@@ -158,4 +144,3 @@ JEMALLOC_INLINE double genrand_res53_mix(sfmt_t *ctx) {
|
||||
return to_res53_mix(x, y);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -1,12 +1,3 @@
|
||||
#ifndef JEMALLOC_ENABLE_INLINE
|
||||
double ln_gamma(double x);
|
||||
double i_gamma(double x, double p, double ln_gamma_p);
|
||||
double pt_norm(double p);
|
||||
double pt_chi2(double p, double df, double ln_gamma_df_2);
|
||||
double pt_gamma(double p, double shape, double scale, double ln_gamma_shape);
|
||||
#endif
|
||||
|
||||
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(MATH_C_))
|
||||
/*
|
||||
* Compute the natural log of Gamma(x), accurate to 10 decimal places.
|
||||
*
|
||||
@@ -15,7 +6,7 @@ double pt_gamma(double p, double shape, double scale, double ln_gamma_shape);
|
||||
* Pike, M.C., I.D. Hill (1966) Algorithm 291: Logarithm of Gamma function
|
||||
* [S14]. Communications of the ACM 9(9):684.
|
||||
*/
|
||||
JEMALLOC_INLINE double
|
||||
static inline double
|
||||
ln_gamma(double x) {
|
||||
double f, z;
|
||||
|
||||
@@ -50,7 +41,7 @@ ln_gamma(double x) {
|
||||
* Bhattacharjee, G.P. (1970) Algorithm AS 32: The incomplete Gamma integral.
|
||||
* Applied Statistics 19:285-287.
|
||||
*/
|
||||
JEMALLOC_INLINE double
|
||||
static inline double
|
||||
i_gamma(double x, double p, double ln_gamma_p) {
|
||||
double acu, factor, oflo, gin, term, rn, a, b, an, dif;
|
||||
double pn[6];
|
||||
@@ -134,7 +125,7 @@ i_gamma(double x, double p, double ln_gamma_p) {
|
||||
* Wichura, M.J. (1988) Algorithm AS 241: The percentage points of the normal
|
||||
* distribution. Applied Statistics 37(3):477-484.
|
||||
*/
|
||||
JEMALLOC_INLINE double
|
||||
static inline double
|
||||
pt_norm(double p) {
|
||||
double q, r, ret;
|
||||
|
||||
@@ -222,7 +213,7 @@ pt_norm(double p) {
|
||||
* Shea, B.L. (1991) Algorithm AS R85: A remark on AS 91: The percentage
|
||||
* points of the Chi^2 distribution. Applied Statistics 40(1):233-235.
|
||||
*/
|
||||
JEMALLOC_INLINE double
|
||||
static inline double
|
||||
pt_chi2(double p, double df, double ln_gamma_df_2) {
|
||||
double e, aa, xx, c, ch, a, q, p1, p2, t, x, b, s1, s2, s3, s4, s5, s6;
|
||||
unsigned i;
|
||||
@@ -309,8 +300,7 @@ pt_chi2(double p, double df, double ln_gamma_df_2) {
|
||||
* compute the upper limit on the definite integral from [0..z] that satisfies
|
||||
* p.
|
||||
*/
|
||||
JEMALLOC_INLINE double
|
||||
static inline double
|
||||
pt_gamma(double p, double shape, double scale, double ln_gamma_shape) {
|
||||
return pt_chi2(p, shape * 2.0, ln_gamma_shape) * 0.5 * scale;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user