提交 916f3b55 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1714 from abergeron/fix_slow_mac

Hide symbols in compiled modules
...@@ -255,6 +255,7 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -255,6 +255,7 @@ def struct_gen(args, struct_builders, blocks, sub):
# TODO: add some error checking to make sure storage_<x> are # TODO: add some error checking to make sure storage_<x> are
# 1-element lists and __ERROR is a 3-elements list. # 1-element lists and __ERROR is a 3-elements list.
struct_code = """ struct_code = """
namespace {
struct %(name)s { struct %(name)s {
PyObject* __ERROR; PyObject* __ERROR;
...@@ -287,6 +288,7 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -287,6 +288,7 @@ def struct_gen(args, struct_builders, blocks, sub):
%(do_return)s %(do_return)s
} }
}; };
}
""" % sub """ % sub
return struct_code return struct_code
...@@ -1285,22 +1287,22 @@ class CLinker(link.Linker): ...@@ -1285,22 +1287,22 @@ class CLinker(link.Linker):
# instantiate. # instantiate.
if PY3: if PY3:
static = """ static = """
int {struct_name}_executor({struct_name} *self) {{ static int {struct_name}_executor({struct_name} *self) {{
return self->run(); return self->run();
}} }}
void {struct_name}_destructor(PyObject *capsule) {{ static void {struct_name}_destructor(PyObject *capsule) {{
{struct_name} *self = ({struct_name} *)PyCapsule_GetContext(capsule); {struct_name} *self = ({struct_name} *)PyCapsule_GetContext(capsule);
delete self; delete self;
}} }}
""".format(struct_name=self.struct_name) """.format(struct_name=self.struct_name)
else: else:
static = """ static = """
int %(struct_name)s_executor(%(struct_name)s* self) { static int %(struct_name)s_executor(%(struct_name)s* self) {
return self->run(); return self->run();
} }
void %(struct_name)s_destructor(void* executor, void* self) { static void %(struct_name)s_destructor(void* executor, void* self) {
delete ((%(struct_name)s*)self); delete ((%(struct_name)s*)self);
} }
""" % dict(struct_name=self.struct_name) """ % dict(struct_name=self.struct_name)
......
...@@ -51,7 +51,7 @@ def compile_cutils(): ...@@ -51,7 +51,7 @@ def compile_cutils():
'op': complexadd % {'type': t}} 'op': complexadd % {'type': t}}
for t in complex_types]) for t in complex_types])
fn_array = ("inplace_map_binop addition_funcs[] = {" + fn_array = ("static inplace_map_binop addition_funcs[] = {" +
''.join([""" ''.join(["""
#if defined(%(typen)s) #if defined(%(typen)s)
%(type)s_inplace_add, %(type)s_inplace_add,
...@@ -61,7 +61,7 @@ def compile_cutils(): ...@@ -61,7 +61,7 @@ def compile_cutils():
"""NULL}; """NULL};
""") """)
type_number_array = ("int type_numbers[] = {" + type_number_array = ("static int type_numbers[] = {" +
''.join([""" ''.join(["""
#if defined(%(typen)s) #if defined(%(typen)s)
%(typen)s, %(typen)s,
......
...@@ -793,7 +793,8 @@ int lazy_rec_eval(CLazyLinker * self, Py_ssize_t var_idx, PyObject*one, PyObject ...@@ -793,7 +793,8 @@ int lazy_rec_eval(CLazyLinker * self, Py_ssize_t var_idx, PyObject*one, PyObject
set_position_of_error(self, owner_idx); set_position_of_error(self, owner_idx);
return err; return err;
} }
PyObject *
static PyObject *
CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds) CLazyLinker_call(PyObject *_self, PyObject *args, PyObject *kwds)
{ {
CLazyLinker * self = (CLazyLinker*)_self; CLazyLinker * self = (CLazyLinker*)_self;
......
...@@ -92,9 +92,8 @@ def detect_macos_sdot_bug(): ...@@ -92,9 +92,8 @@ def detect_macos_sdot_bug():
# Then, try a simple fix # Then, try a simple fix
test_fix_code = textwrap.dedent("""\ test_fix_code = textwrap.dedent("""\
extern "C" float sdot_(int*, float*, int*, float*, int*);
extern "C" float cblas_sdot(int, float*, int, float*, int); extern "C" float cblas_sdot(int, float*, int, float*, int);
float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy) static float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy)
{ {
return cblas_sdot(*Nx, x, *Sx, y, *Sy); return cblas_sdot(*Nx, x, *Sx, y, *Sy);
} }
...@@ -924,7 +923,7 @@ def blas_header_text(): ...@@ -924,7 +923,7 @@ def blas_header_text():
if detect_macos_sdot_bug.fix_works: if detect_macos_sdot_bug.fix_works:
header += textwrap.dedent("""\ header += textwrap.dedent("""\
extern "C" float cblas_sdot(int, float*, int, float*, int); extern "C" float cblas_sdot(int, float*, int, float*, int);
float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy) static float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy)
{ {
return cblas_sdot(*Nx, x, *Sx, y, *Sy); return cblas_sdot(*Nx, x, *Sx, y, *Sy);
} }
...@@ -932,7 +931,7 @@ def blas_header_text(): ...@@ -932,7 +931,7 @@ def blas_header_text():
else: else:
# Make sure the buggy version of sdot_ is never used # Make sure the buggy version of sdot_ is never used
header += textwrap.dedent("""\ header += textwrap.dedent("""\
float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy) static float sdot_(int* Nx, float* x, int* Sx, float* y, int* Sy)
{ {
fprintf(stderr, fprintf(stderr,
"FATAL: The implementation of BLAS SDOT " "FATAL: The implementation of BLAS SDOT "
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论