Skip to content

algo: implement sine/cosine based on Intel SVML for single/double precision #1

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: Google
120 changes: 120 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Editor temporary/working/backup files #
#########################################
.#*
[#]*#
*~
*$
*.bak
*.diff
.idea/
*.iml
*.ipr
*.iws
*.org
.project
pmip
*.rej
.settings/
.*.sw[nop]
.sw[nop]
*.tmp
*.vim
.vscode
tags
cscope.out
# gnu global
GPATH
GRTAGS
GSYMS
GTAGS
.cache
.mypy_cache/

# Compiled source #
###################
*.a
*.com
*.class
*.dll
*.exe
*.o
*.o.d
*.py[ocd]
*.so
*.mod

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.bz2
*.bzip2
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.tbz2
*.tgz
*.zip

# Python files #
################
# meson build/installation directories
build
build-install
# meson python output
.mesonpy-native-file.ini
# sphinx build directory
_build
# dist directory is where sdist/wheel end up
dist
doc/build
doc/docenv
doc/cdoc/build
# Egg metadata
*.egg-info
# The shelf plugin uses this dir
./.shelf
.cache
pip-wheel-metadata
.python-version
# virtual envs
numpy-dev/
venv/

# Paver generated files #
#########################
/release

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# Patches #
###########
*.patch
*.diff

# Do not ignore the following patches: #
########################################
!tools/ci/emscripten/0001-do-not-set-meson-environment-variable-pyodide-gh-4502.patch

# OS generated files #
######################
.DS_Store*
.VolumeIcon.icns
.fseventsd
Icon?
.gdb_history
ehthumbs.db
Thumbs.db
.directory

# pytest generated files #
##########################
/.pytest_cache
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test/highway"]
path = test/highway
url = https://github.com/google/highway
97 changes: 97 additions & 0 deletions .spin/cmds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import os
import pathlib
import sys
import click
import spin
from spin.cmds import meson

curdir = pathlib.Path(__file__).parent
rootdir = curdir.parent


@click.command(help="Generate sollya python based files")
@click.option("-f", "--force", is_flag=True, help="Force regenerate all files")
@click.option("-s", "--sollya-path", help="Path to sollya")
def generate(*, force, sollya_path):
spin.util.run(
["python", str(rootdir / "tools" / "generator.py")]
+ (["--force"] if force else []),
)


@spin.util.extend_command(spin.cmds.meson.build)
def build(*, parent_callback, **kwargs):
parent_callback(**kwargs)


@click.option(
"-m",
"markexpr",
metavar="MARKEXPR",
default="",
help="Run tests with the given markers",
)
@click.option(
"-m",
"markexpr",
metavar="MARKEXPR",
default="",
help="Run tests with the given markers",
)
@spin.util.extend_command(spin.cmds.meson.test)
def test(*, parent_callback, pytest_args, tests, markexpr, **kwargs):
"""
By default, spin will run `-m 'not slow'`. To run the full test suite, use
`spin test -m full`
""" # noqa: E501
if (not pytest_args) and (not tests):
pytest_args = (
"--pyargs",
"numpy_sr",
)

if "-m" not in pytest_args:
if markexpr != "full":
pytest_args = ("-m", markexpr) + pytest_args

kwargs["pytest_args"] = pytest_args
parent_callback(**{"pytest_args": pytest_args, "tests": tests, **kwargs})


@spin.util.extend_command(meson.python)
def python(*, parent_callback, **kwargs):
env = os.environ
env["PYTHONWARNINGS"] = env.get("PYTHONWARNINGS", "all")

parent_callback(**kwargs)


@click.command(context_settings={"ignore_unknown_options": True})
@click.argument("ipython_args", metavar="", nargs=-1)
@meson.build_dir_option
def ipython(*, ipython_args, build_dir):
"""💻 Launch IPython shell with PYTHONPATH set

OPTIONS are passed through directly to IPython, e.g.:

spin ipython -i myscript.py
"""
env = os.environ
env["PYTHONWARNINGS"] = env.get("PYTHONWARNINGS", "all")

ctx = click.get_current_context()
ctx.invoke(spin.cmds.meson.build)

ppath = meson._set_pythonpath(build_dir)

print(f'💻 Launching IPython with PYTHONPATH="{ppath}"')

# In spin >= 0.13.1, can replace with extended command, setting `pre_import`
preimport = (
r"import numpy_sr as sr; "
r"print(f'\nPreimported NumPy SIMD Routines Tests {sr.__version__} as sr')"
)
spin.util.run(
["ipython", "--ignore-cwd", f"--TerminalIPythonApp.exec_lines={preimport}"]
+ list(ipython_args)
)
18 changes: 18 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project(
'NumPy SIMD routines tests',
'cpp',
version: '0.01',
license: 'BSD-3',
meson_version: '>=1.5.2',
default_options: [
'buildtype=debugoptimized',
'b_ndebug=if-release',
'cpp_std=c++17',
],
)

py = import('python').find_installation(pure: false)
npsr_dir = py.get_install_dir() / 'numpy_sr'

subdir('test')
subdir('npsr')
11 changes: 11 additions & 0 deletions npsr/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef NUMPY_SIMD_ROUTINES_NPSR_COMMON_H_
#define NUMPY_SIMD_ROUTINES_NPSR_COMMON_H_

#include <hwy/highway.h>

#include <cfenv>
#include <type_traits>

#include "precise.h"

#endif // NUMPY_SIMD_ROUTINES_NPSR_COMMON_H_
1 change: 1 addition & 0 deletions npsr/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install_subdir('trig/tests', install_dir: npsr_dir/'npsr'/'trig')
12 changes: 12 additions & 0 deletions npsr/npsr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// To include them once per target, which is ensured by the toggle check.
// clang-format off
#if defined(_NPSR_NPSR_H_) == defined(HWY_TARGET_TOGGLE) // NOLINT
#ifdef _NPSR_NPSR_H_
#undef _NPSR_NPSR_H_
#else
#define _NPSR_NPSR_H_
#endif

#include "npsr/trig/inl.h"

#endif // _NPSR_NPSR_H_
Loading