Changeset 5efe850 in sasmodels for sasmodels/kernel_template.c


Ignore:
Timestamp:
May 20, 2016 12:53:41 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c98c772, 4bfbca2
Parents:
33af590
Message:

Use tinycc if available; support float32 models in tinycc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_template.c

    r3832f27 r5efe850  
    1212// Note: if using a C++ compiler, then define kernel as extern "C" 
    1313#ifndef USE_OPENCL 
     14// Use SAS_DOUBLE to force the use of double even for float kernels 
     15#  define SAS_DOUBLE dou ## ble 
    1416#  ifdef __cplusplus 
    1517      #include <cstdio> 
     
    3840     #if defined(__TINYC__) 
    3941         #include <math.h> 
    40          inline double trunc(double x) { return x>=0?floor(x):-floor(-x); } 
    41          inline double fmin(double x, double y) { return x>y ? y : x; } 
    42          inline double fmax(double x, double y) { return x<y ? y : x; } 
    4342         // TODO: test isnan 
    4443         inline double _isnan(double x) { return x != x; } // hope this doesn't optimize away! 
    4544         #undef isnan 
    4645         #define isnan(x) _isnan(x) 
     46         // Defeat the double->float conversion since we don't have tgmath 
     47         inline SAS_DOUBLE trunc(SAS_DOUBLE x) { return x>=0?floor(x):-floor(-x); } 
     48         inline SAS_DOUBLE fmin(SAS_DOUBLE x, SAS_DOUBLE y) { return x>y ? y : x; } 
     49         inline SAS_DOUBLE fmax(SAS_DOUBLE x, SAS_DOUBLE y) { return x<y ? y : x; } 
    4750         #define NEED_EXPM1 
    4851         #define NEED_TGAMMA 
     
    7073 
    7174#if defined(NEED_EXPM1) 
    72    static double expm1(double x) { 
     75   static SAS_DOUBLE expm1(SAS_DOUBLE x_in) { 
     76      double x = (double)x_in;  // go back to float for single precision kernels 
    7377      // Adapted from the cephes math library. 
    7478      // Copyright 1984 - 1992 by Stephen L. Moshier 
Note: See TracChangeset for help on using the changeset viewer.