Skip to content
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

adding the trace-compile option to the julia initialization #530

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions src/julia/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def yes_no_etc(*etc):

threads: {int, 'auto'}
How many threads to use.

trace_compile: str
Trace precompile statements during execution to the given file.
"""


Expand Down Expand Up @@ -174,6 +177,7 @@ class JuliaOptions(object):
inline = Choices("inline", yes_no_etc())
check_bounds = Choices("check_bounds", yes_no_etc())
threads = IntEtc("threads", etc={"auto"})
trace_compile = String("trace_compile")

def __init__(self, **kwargs):
unsupported = []
Expand Down
26 changes: 26 additions & 0 deletions src/julia/tests/test_trace_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from pathlib import Path
from subprocess import check_call

import pytest

from .test_compatible_exe import runcode
from .utils import skip_in_windows


@skip_in_windows
def test_trace_file_created(tmpdir):
trace_compile_path = Path(tmpdir) / "trace_compile.jl"
runcode(
"""
from julia.api import Julia
jl = Julia(trace_compile="{}")

from julia import Main
Main.sin(2.0)
""".format(
str(trace_compile_path)
)
)
assert (trace_compile_path).exists()
assert len(trace_compile_path.read_text().strip()) > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some compilation string that you know should be printed to this file? If so, could you test that it actually shows up there?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a great idea! I added a check for the precompilation directive of the sin function we invoke to test precompilation.