2015-05-03 02:14:02 -04:00
|
|
|
#Thanks to Andreas Knoeckler for providing stand-alone boost.python
|
|
|
|
#through PyOpenCL and PyCUDA
|
|
|
|
|
2015-01-12 13:20:53 -05:00
|
|
|
import os, sys
|
2014-10-14 23:49:18 -04:00
|
|
|
from distutils.command.build_ext import build_ext
|
2015-04-30 00:46:42 -04:00
|
|
|
from distutils.command.build_py import build_py
|
|
|
|
from distutils.core import setup, Extension
|
2014-10-14 23:49:18 -04:00
|
|
|
from distutils.sysconfig import get_python_inc
|
|
|
|
from distutils import sysconfig
|
2015-01-12 13:20:53 -05:00
|
|
|
from imp import find_module
|
|
|
|
from glob import glob
|
2014-10-14 23:49:18 -04:00
|
|
|
|
|
|
|
platform_cflags = {}
|
|
|
|
platform_ldflags = {}
|
|
|
|
platform_libs = {}
|
2015-04-30 00:46:42 -04:00
|
|
|
|
2014-10-14 23:49:18 -04:00
|
|
|
class build_ext_subclass(build_ext):
|
|
|
|
def build_extensions(self):
|
|
|
|
c = self.compiler.compiler_type
|
|
|
|
if c in platform_cflags.keys():
|
|
|
|
for e in self.extensions:
|
|
|
|
e.extra_compile_args = platform_cflags[c]
|
|
|
|
if c in platform_ldflags.keys():
|
|
|
|
for e in self.extensions:
|
|
|
|
e.extra_link_args = platform_ldflags[c]
|
|
|
|
if c in platform_libs.keys():
|
|
|
|
for e in self.extensions:
|
|
|
|
try:
|
|
|
|
e.libraries += platform_libs[c]
|
|
|
|
except:
|
|
|
|
e.libraries = platform_libs[c]
|
|
|
|
build_ext.build_extensions(self)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
2015-01-12 13:20:53 -05:00
|
|
|
def recursive_glob(rootdir='.', suffix=''):
|
|
|
|
return [os.path.join(looproot, filename)
|
|
|
|
for looproot, _, filenames in os.walk(rootdir)
|
|
|
|
for filename in filenames if filename.endswith(suffix)]
|
|
|
|
|
2014-10-14 23:49:18 -04:00
|
|
|
def remove_prefixes(optlist, bad_prefixes):
|
|
|
|
for bad_prefix in bad_prefixes:
|
|
|
|
for i, flag in enumerate(optlist):
|
|
|
|
if flag.startswith(bad_prefix):
|
|
|
|
optlist.pop(i)
|
|
|
|
break
|
|
|
|
return optlist
|
|
|
|
|
2015-05-03 02:14:02 -04:00
|
|
|
#Compiler options
|
2014-10-14 23:49:18 -04:00
|
|
|
cvars = sysconfig.get_config_vars()
|
2015-05-03 02:14:02 -04:00
|
|
|
cvars['OPT'] = str.join(' ', remove_prefixes(cvars['OPT'].split(), ['-g', '-Wstrict-prototypes']))
|
2015-05-04 02:15:29 -04:00
|
|
|
cvars["CFLAGS"] = cvars["BASECFLAGS"] + cvars['OPT']
|
2014-10-16 06:57:38 -04:00
|
|
|
cvars["LDFLAGS"] = '-Wl,--no-as-needed ' + cvars["LDFLAGS"]
|
2015-01-12 13:20:53 -05:00
|
|
|
|
2015-05-03 03:40:14 -04:00
|
|
|
#Includes
|
2015-05-13 02:20:44 -04:00
|
|
|
include =' src/include /usr/local/cuda/include'.split() + ['external/boost/include', os.path.join(find_module("numpy")[1], "core", "include")]
|
2015-05-03 02:14:02 -04:00
|
|
|
#Sources
|
2015-05-13 02:20:44 -04:00
|
|
|
src = 'src/lib/backend/templates/maxpy.cpp src/lib/backend/templates/mreduction.cpp src/lib/backend/templates/base.cpp src/lib/backend/templates/vaxpy.cpp src/lib/backend/templates/mproduct.cpp src/lib/backend/templates/reduction.cpp src/lib/backend/stream.cpp src/lib/backend/keywords.cpp src/lib/backend/mapped_object.cpp src/lib/backend/binder.cpp src/lib/backend/parse.cpp src/lib/exception/operation_not_supported.cpp src/lib/exception/unknown_datatype.cpp src/lib/value_scalar.cpp src/lib/model/predictors/random_forest.cpp src/lib/model/model.cpp src/lib/driver/check.cpp src/lib/driver/ndrange.cpp src/lib/driver/platform.cpp src/lib/driver/backend.cpp src/lib/driver/program.cpp src/lib/driver/command_queue.cpp src/lib/driver/event.cpp src/lib/driver/kernel.cpp src/lib/driver/handle.cpp src/lib/driver/device.cpp src/lib/driver/buffer.cpp src/lib/driver/context.cpp src/lib/symbolic/execute.cpp src/lib/symbolic/expression.cpp src/lib/symbolic/io.cpp src/lib/array.cpp '.split() + [os.path.join('src', 'wrap', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'model.cpp', 'exceptions.cpp']]
|
2015-05-03 03:40:14 -04:00
|
|
|
boostsrc = 'external/boost/libs/'
|
2015-01-12 13:20:53 -05:00
|
|
|
for s in ['numpy','python','smart_ptr','system','thread']:
|
2015-05-03 03:40:14 -04:00
|
|
|
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
2015-01-12 13:20:53 -05:00
|
|
|
# make sure next line succeeds even on Windows
|
|
|
|
src = [f.replace("\\", "/") for f in src]
|
|
|
|
if sys.platform == "win32":
|
|
|
|
src += glob(boostsrc + "/thread/src/win32/*.cpp")
|
|
|
|
src += glob(boostsrc + "/thread/src/tss_null.cpp")
|
|
|
|
else:
|
|
|
|
src += glob(boostsrc + "/thread/src/pthread/*.cpp")
|
|
|
|
src= [f for f in src if not f.endswith("once_atomic.cpp")]
|
|
|
|
|
2014-10-14 23:49:18 -04:00
|
|
|
|
|
|
|
setup(
|
2015-04-30 00:46:42 -04:00
|
|
|
name='isaac',
|
|
|
|
version='1.0',
|
|
|
|
description="Input-specific architecture-aware computations",
|
|
|
|
author='Philippe Tillet',
|
|
|
|
author_email='ptillet@g.harvard.edu',
|
|
|
|
license='MPL 2.0',
|
|
|
|
packages=["isaac"],
|
|
|
|
ext_package="isaac",
|
|
|
|
ext_modules=[Extension(
|
2015-04-29 15:50:57 -04:00
|
|
|
'_isaac',src,
|
2015-05-04 02:15:29 -04:00
|
|
|
extra_compile_args= ['-D__CL_ENABLE_EXCEPTIONS', '-std=c++11', '-Wno-unused-function', '-Wno-unused-local-typedefs', '-Wno-sign-compare'],
|
|
|
|
extra_link_args=['-Wl,-soname=_isaac.so'],
|
2015-04-30 00:46:42 -04:00
|
|
|
undef_macros=[],
|
2015-05-03 02:14:02 -04:00
|
|
|
include_dirs=include,
|
2015-05-04 02:15:29 -04:00
|
|
|
libraries=['OpenCL']
|
2015-04-30 00:46:42 -04:00
|
|
|
)],
|
|
|
|
cmdclass={'build_py': build_py, 'build_ext': build_ext_subclass},
|
|
|
|
classifiers=[
|
|
|
|
'Environment :: Console',
|
|
|
|
'Development Status :: 1 - Experimental',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: Other Audience',
|
|
|
|
'Intended Audience :: Science/Research',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Natural Language :: English',
|
|
|
|
'Programming Language :: C++',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Topic :: Scientific/Engineering',
|
|
|
|
'Topic :: Scientific/Engineering :: Mathematics',
|
|
|
|
'Topic :: Scientific/Engineering :: Physics',
|
|
|
|
'Topic :: Scientific/Engineering :: Machine Learning',
|
|
|
|
]
|
2014-10-14 23:49:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|