Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install wheel setuptools
python -m pip install mako
python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tinycc siphash24
python -m pip install numpy scipy matplotlib docutils pytest sphinx bumps==0.* unittest-xml-reporting tccbox siphash24

- name: setup pyopencl on Linux + macOS
if: ${{ matrix.os != 'windows-latest' }}
Expand Down
22 changes: 2 additions & 20 deletions sasmodels/kernel_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,8 @@
#else // !__cplusplus
#include <inttypes.h> // C99 guarantees that int32_t types is here
#include <stdio.h>
#if defined(__TINYC__)
typedef int int32_t;
#include <math.h>
// TODO: check isnan is correct
inline double _isnan(double x) { return x != x; } // hope this doesn't optimize away!
#undef isnan
#define isnan(x) _isnan(x)
// Defeat the double->float conversion since we don't have tgmath
inline SAS_DOUBLE trunc(SAS_DOUBLE x) { return x>=0?floor(x):-floor(-x); }
inline SAS_DOUBLE fmin(SAS_DOUBLE x, SAS_DOUBLE y) { return x>y ? y : x; }
inline SAS_DOUBLE fmax(SAS_DOUBLE x, SAS_DOUBLE y) { return x<y ? y : x; }
#define NEED_ERF
#define NEED_EXPM1
#define NEED_TGAMMA
#define NEED_CBRT
// expf missing from windows?
#define expf exp
#else
#include <tgmath.h> // C99 type-generic math, so sin(float) => sinf
#endif
#define NEED_ERF
#include <tgmath.h> // C99 type-generic math, so sin(float) => sinf
// MSVC doesn't support C99, so no need for dllexport on C99 branch
#define kernel
#define SINCOS(angle,svar,cvar) do {const double _t_=angle; svar=sin(_t_);cvar=cos(_t_);} while (0)
Expand Down
18 changes: 14 additions & 4 deletions sasmodels/kerneldll.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
import numpy as np # type: ignore

try:
import tinycc
import tccbox
except ImportError:
tinycc = None
tccbox = None

from . import generate
from .kernel import KernelModel, Kernel
Expand Down Expand Up @@ -112,7 +112,7 @@
if "SAS_COMPILER" in os.environ:
COMPILER = os.environ["SAS_COMPILER"]
elif os.name == 'nt':
if tinycc is not None:
if tccbox is not None:
COMPILER = "tinycc"
elif "VCINSTALLDIR" in os.environ:
# If vcvarsall.bat has been called, then VCINSTALLDIR is in the
Expand Down Expand Up @@ -166,7 +166,17 @@ def compile_command(source, output):
return CC + ["/Tp%s"%source] + LN + ["/OUT:%s"%output]
elif COMPILER == "tinycc":
# TinyCC compiler.
CC = [tinycc.TCC] + "-shared -rdynamic -Wall".split()
CC = [
tccbox.tcc_bin_path(),
"-nostdinc",
"-std=c99",
f"-L{tccbox.tcc_lib_dir()}",
f"-L{joinpath(tccbox.tcc_lib_dir(), 'tcc')}",
f"-I{tccbox.tcc_dist_dir()}/include",
"-shared",
"-rdynamic",
"-Wall",
]
def compile_command(source, output):
"""tinycc compiler command"""
return CC + [source, "-o", output]
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ def find_version(package):
return version[1:-1]
raise RuntimeError("Could not read version from %s/__init__.py"%package)

install_requires = ['numpy', 'scipy']
install_requires = ['numpy', 'scipy', 'tccbox']

with open('README.rst') as fid:
long_description = fid.read()

if sys.platform=='win32' or sys.platform=='cygwin':
install_requires.append('tinycc')

setup(
name='sasmodels',
version=find_version('sasmodels'),
Expand Down