Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
9c925c4e
Commit
9c925c4e
authored
May 19, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1186 from kmod/numpy_perf
One small change for numpy performance
parents
49f8df10
307c2a08
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
28 deletions
+41
-28
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+2
-1
src/core/ast.cpp
src/core/ast.cpp
+1
-1
src/core/ast.h
src/core/ast.h
+1
-1
src/core/cfg.h
src/core/cfg.h
+3
-3
src/runtime/capi.cpp
src/runtime/capi.cpp
+7
-13
src/runtime/types.cpp
src/runtime/types.cpp
+3
-0
test/integration/numpy_test.py
test/integration/numpy_test.py
+24
-9
No files found.
src/codegen/unwinding.cpp
View file @
9c925c4e
...
...
@@ -546,7 +546,8 @@ public:
}
std
::
tuple
<
FrameInfo
*
,
ExcInfo
,
PythonStackExtractor
>
pause
()
{
t
.
end
();
static
StatCounter
stat
(
"us_unwind_session"
);
stat
.
log
(
t
.
end
());
return
std
::
make_tuple
(
std
::
move
(
prev_frame_info
),
std
::
move
(
exc_info
),
std
::
move
(
pystack_extractor
));
}
...
...
src/core/ast.cpp
View file @
9c925c4e
...
...
@@ -2223,7 +2223,7 @@ public:
}
};
void
flatten
(
const
std
::
vector
<
AST_stmt
*
>&
roots
,
std
::
vector
<
AST
*>&
output
,
bool
expand_scopes
)
{
void
flatten
(
const
llvm
::
SmallVector
<
AST_stmt
*
,
4
>&
roots
,
std
::
vector
<
AST
*>&
output
,
bool
expand_scopes
)
{
FlattenVisitor
visitor
(
&
output
,
expand_scopes
);
for
(
int
i
=
0
;
i
<
roots
.
size
();
i
++
)
{
...
...
src/core/ast.h
View file @
9c925c4e
...
...
@@ -1432,7 +1432,7 @@ public:
// Given an AST node, return a vector of the node plus all its descendents.
// This is useful for analyses that care more about the constituent nodes than the
// exact tree structure; ex, finding all "global" directives.
void
flatten
(
const
std
::
vector
<
AST_stmt
*
>&
roots
,
std
::
vector
<
AST
*>&
output
,
bool
expand_scopes
);
void
flatten
(
const
llvm
::
SmallVector
<
AST_stmt
*
,
4
>&
roots
,
std
::
vector
<
AST
*>&
output
,
bool
expand_scopes
);
void
flatten
(
AST_expr
*
root
,
std
::
vector
<
AST
*>&
output
,
bool
expand_scopes
);
// Similar to the flatten() function, but filters for a specific type of ast nodes:
template
<
class
T
,
class
R
>
void
findNodes
(
const
R
&
roots
,
std
::
vector
<
T
*>&
output
,
bool
expand_scopes
)
{
...
...
src/core/cfg.h
View file @
9c925c4e
...
...
@@ -53,12 +53,12 @@ public:
// contains the address of the entry function
std
::
pair
<
CFGBlock
*
,
Box
*>
(
*
entry_code
)(
void
*
interpeter
,
CFGBlock
*
block
,
Box
**
vregs
);
std
::
vector
<
AST_stmt
*
>
body
;
std
::
vector
<
CFGBlock
*
>
predecessors
,
successors
;
llvm
::
SmallVector
<
AST_stmt
*
,
4
>
body
;
llvm
::
SmallVector
<
CFGBlock
*
,
2
>
predecessors
,
successors
;
int
idx
;
// index in the CFG
const
char
*
info
;
typedef
std
::
vector
<
AST_stmt
*
>::
iterator
iterator
;
typedef
llvm
::
SmallVector
<
AST_stmt
*
,
4
>::
iterator
iterator
;
CFGBlock
(
CFG
*
cfg
,
int
idx
)
:
cfg
(
cfg
),
code
(
NULL
),
entry_code
(
NULL
),
idx
(
idx
),
info
(
NULL
)
{}
...
...
src/runtime/capi.cpp
View file @
9c925c4e
...
...
@@ -1714,15 +1714,6 @@ template <ExceptionStyle S>
Box
*
BoxedCApiFunction
::
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
if
(
S
==
CAPI
)
{
try
{
return
tppCall
<
CXX
>
(
_self
,
NULL
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
STAT_TIMER
(
t0
,
"us_timer_boxedcapifunction__call__"
,
10
);
BoxedCApiFunction
*
self
=
static_cast
<
BoxedCApiFunction
*>
(
_self
);
...
...
@@ -1791,6 +1782,7 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
rewrite_args
->
out_rtn
->
setType
(
RefType
::
OWNED
);
rewrite_args
->
out_success
=
true
;
}
assert
(
rtn
);
// This shouldn't throw, otherwise we would need to check the return value
return
rtn
;
}
// TODO rewrite these cases specially; tp_new_wrapper just slices the args array,
...
...
@@ -1861,18 +1853,20 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
}
if
(
rewrite_args
)
{
rewrite_args
->
rewriter
->
checkAndThrowCAPIException
(
rewrite_args
->
out_rtn
);
if
(
S
==
CXX
)
rewrite_args
->
rewriter
->
checkAndThrowCAPIException
(
rewrite_args
->
out_rtn
);
rewrite_args
->
out_success
=
true
;
}
if
(
S
==
CXX
&&
!
rtn
)
throwCAPIException
();
assert
(
rtn
&&
"should have set + thrown an exception!"
);
return
rtn
;
};
return
rearrangeArgumentsAndCall
(
paramspec
,
NULL
,
self
->
method_def
->
ml_name
,
defaults
,
rewrite_args
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
continuation
);
return
callCXXFromStyle
<
S
>
([
=
]()
{
return
rearrangeArgumentsAndCall
(
paramspec
,
NULL
,
self
->
method_def
->
ml_name
,
defaults
,
rewrite_args
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
continuation
);
});
}
/* extension modules might be compiled with GC support so these
...
...
src/runtime/types.cpp
View file @
9c925c4e
...
...
@@ -1162,6 +1162,9 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
class
InitHelper
{
public:
static
Box
*
call
(
STOLEN
(
Box
*
)
made
,
BoxedClass
*
cls
,
Box
*
args
,
Box
*
kwargs
)
noexcept
(
S
==
CAPI
)
{
if
(
S
==
CAPI
&&
!
made
)
return
NULL
;
if
(
!
isSubclass
(
made
->
cls
,
cls
))
return
made
;
...
...
test/integration/numpy_test.py
View file @
9c925c4e
...
...
@@ -38,6 +38,9 @@ def print_progress_header(text):
ENV_NAME
=
"numpy_test_env_"
+
os
.
path
.
basename
(
sys
.
executable
)
DEPENDENCIES
=
[
"nose==1.3.7"
]
import
platform
USE_CUSTOM_PATCHES
=
(
platform
.
python_implementation
()
==
"Pyston"
)
if
not
os
.
path
.
exists
(
ENV_NAME
)
or
os
.
stat
(
sys
.
executable
).
st_mtime
>
os
.
stat
(
ENV_NAME
+
"/bin/python"
).
st_mtime
:
print
"Creating virtualenv to install testing dependencies..."
VIRTUALENV_SCRIPT
=
os
.
path
.
dirname
(
__file__
)
+
"/../lib/virtualenv/virtualenv.py"
...
...
@@ -69,9 +72,10 @@ if not os.path.exists(CYTHON_DIR):
subprocess
.
check_call
([
"wget"
,
url
],
cwd
=
SRC_DIR
)
subprocess
.
check_call
([
"tar"
,
"-zxf"
,
"Cython-0.22.tar.gz"
],
cwd
=
SRC_DIR
)
PATCH_FILE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"Cython-0.22.patch"
))
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
CYTHON_DIR
)
print
">>> Applied Cython patch"
if
USE_CUSTOM_PATCHES
:
PATCH_FILE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"Cython-0.22.patch"
))
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
CYTHON_DIR
)
print
">>> Applied Cython patch"
try
:
...
...
@@ -93,8 +97,9 @@ else:
PATCH_FILE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"numpy_patch.patch"
))
print_progress_header
(
"Patching NumPy..."
)
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
NUMPY_DIR
)
if
USE_CUSTOM_PATCHES
:
print_progress_header
(
"Patching NumPy..."
)
subprocess
.
check_call
([
"patch"
,
"-p1"
,
"--input="
+
PATCH_FILE
],
cwd
=
NUMPY_DIR
)
try
:
env
=
os
.
environ
...
...
@@ -107,7 +112,16 @@ try:
print_progress_header
(
"Installing NumPy..."
)
subprocess
.
check_call
([
PYTHON_EXE
,
"setup.py"
,
"install"
],
cwd
=
NUMPY_DIR
,
env
=
env
)
except
:
subprocess
.
check_call
([
"rm"
,
"-rf"
,
NUMPY_DIR
])
if
USE_CUSTOM_PATCHES
:
print_progress_header
(
"Unpatching NumPy..."
)
cmd
=
[
"patch"
,
"-p1"
,
"--forward"
,
"-i"
,
NUMPY_PATCH_FILE
,
"-R"
,
"-d"
,
NUMPY_DIR
]
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
# TODO: I'm not sure we need to do this:
subprocess
.
check_call
([
"rm"
,
"-rf"
,
NUMPY_DIR
+
"/build"
])
subprocess
.
check_call
([
"rm"
,
"-rf"
,
NUMPY_DIR
+
"/dist"
])
raise
# From Wikipedia
script
=
"""
...
...
@@ -176,9 +190,10 @@ print_progress_header("Running NumPy test suite...")
# when all the crashes are fixed.
# subprocess.check_call([PYTHON_EXE, "-c", numpy_test], cwd=CYTHON_DIR)
print_progress_header
(
"Unpatching NumPy..."
)
cmd
=
[
"patch"
,
"-p1"
,
"--forward"
,
"-i"
,
NUMPY_PATCH_FILE
,
"-R"
,
"-d"
,
NUMPY_DIR
]
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
if
USE_CUSTOM_PATCHES
:
print_progress_header
(
"Unpatching NumPy..."
)
cmd
=
[
"patch"
,
"-p1"
,
"--forward"
,
"-i"
,
NUMPY_PATCH_FILE
,
"-R"
,
"-d"
,
NUMPY_DIR
]
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
print
print
"PASSED"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment