-
Notifications
You must be signed in to change notification settings - Fork 101
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
support for "threads" and "min-optlevel" julia options #493
Changes from all commits
e097806
aa8063e
fa21094
939d214
f27efd1
5dd3dcb
3fb8cf5
624dc96
daaff7c
b9985ea
e935692
2ce534b
45d1ec3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,35 @@ def _domain(self): # used in test | |
return str | ||
|
||
|
||
class IntEtc(OptionDescriptor): | ||
def __init__(self, name, *, etc={}): | ||
self.name = name | ||
self.default = etc | ||
|
||
def __set__(self, instance, value): | ||
if instance is None: | ||
raise AttributeError(self.name) | ||
elif value in {None, *self.default} or isinstance(value, int): | ||
setattr(instance, self.dataname, value) | ||
else: | ||
if self.default: | ||
part = " or " + " ".join(map(str, self.default)) | ||
else: | ||
part = "" | ||
raise ValueError( | ||
f"Option {self.name} only accepts integers{part}. Got: {value}" | ||
) | ||
|
||
def _domain(self): | ||
return {int, *self.default} | ||
|
||
def cli_argument_spec(self): | ||
return dict( | ||
super(IntEtc, self).cli_argument_spec(), | ||
choices=list(self.default) + ["1", "2", "3", "..."], | ||
) | ||
|
||
|
||
class Choices(OptionDescriptor): | ||
def __init__(self, name, choicemap, default=None): | ||
self.name = name | ||
|
@@ -110,6 +139,12 @@ def yes_no_etc(*etc): | |
|
||
warn_overwrite: {True, False, 'yes', 'no'} | ||
Enable or disable method overwrite warnings. | ||
|
||
min_optlevel: {0, 1, 2, 3} | ||
Lower bound on the optimization level. | ||
|
||
threads: {int, 'auto'} | ||
How many threads to use. | ||
""" | ||
|
||
|
||
|
@@ -134,9 +169,11 @@ class JuliaOptions(object): | |
compile = Choices("compile", yes_no_etc("all", "min")) | ||
depwarn = Choices("depwarn", yes_no_etc("error")) | ||
warn_overwrite = Choices("warn_overwrite", yes_no_etc()) | ||
min_optlevel = Choices("min_optlevel", dict(zip(range(4), map(str, range(4))))) | ||
optimize = Choices("optimize", dict(zip(range(4), map(str, range(4))))) | ||
inline = Choices("inline", yes_no_etc()) | ||
check_bounds = Choices("check_bounds", yes_no_etc()) | ||
threads = IntEtc("threads", etc={"auto"}) | ||
|
||
def __init__(self, **kwargs): | ||
unsupported = [] | ||
|
@@ -168,8 +205,12 @@ def specified(self): | |
def as_args(self): | ||
args = [] | ||
for (desc, value) in self.specified(): | ||
args.append(desc.cli_argument_name()) | ||
args.append(value) | ||
if value is None: | ||
... | ||
elif len(desc.cli_argument_name()) == 1: | ||
args.append(desc.cli_argument_name() + str(value)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need test case for this branch. (unless there already is one?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, there are no options that could trigger this... Is that correct? So maybe this branch can be removed. |
||
else: | ||
args.append(desc.cli_argument_name() + "=" + str(value)) | ||
return args | ||
|
||
@classmethod | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this new logic to avoid adding arguments if the value is unset. Not sure why this wasn't set up before - @mkitti or @marius311 any idea why?