Skip to content

Commit

Permalink
[misc] 'ti.init()' now supports all exported configurations in ti.cfg (
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate authored Jul 10, 2020
1 parent 02d89dc commit 65bf964
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
24 changes: 12 additions & 12 deletions python/taichi/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ class _EnvironmentConfigurator:
def __init__(self, kwargs, cfg):
self.cfg = cfg
self.kwargs = kwargs
self.keys = []

def add(self, key, cast=None):
cast = cast or self.bool_int

self.keys.append(key)

# TI_ASYNC= : no effect
# TI_ASYNC=0 : False
# TI_ASYNC=1 : True
Expand Down Expand Up @@ -177,18 +180,15 @@ def init(arch=None,
env_spec.add('excepthook')

# compiler configuations (ti.cfg):
env_comp.add('debug')
env_comp.add('print_ir')
env_comp.add('verbose')
env_comp.add('fast_math')
env_comp.add('async')
env_comp.add('use_unified_memory')
env_comp.add('print_benchmark_stat')
env_comp.add('advanced_optimization')
# TODO(yuanming-hu): Maybe these CUDA specific configs should be moved
# to somewhere like ti.cfg.cuda so that user don't get confused?
env_comp.add('device_memory_fraction', float)
env_comp.add('device_memory_GB', float)
# TODO(yuanming-hu): Maybe CUDA specific configs like device_memory_* should be moved
# to somewhere like ti.cuda_cfg so that user don't get confused?
for key in dir(ti.cfg):
if key in ['default_fp', 'default_ip']:
continue
cast = type(getattr(ti.cfg, key))
if cast is bool:
cast = None
env_comp.add(key, cast)

unexpected_keys = kwargs.keys()
if len(unexpected_keys):
Expand Down
10 changes: 10 additions & 0 deletions tests/python/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@ def patch_os_environ_helper(custom_environ: dict, excludes: dict):
'verbose': [True, TF],
'fast_math': [True, TF],
'async': [False, TF],
'flatten_if': [False, TF],
'simplify_before_lower_access': [True, TF],
'simplify_after_lower_access': [True, TF],
'use_unified_memory': [ti.get_os_name() != 'win', TF],
'print_benchmark_stat': [False, TF],
'kernel_profiler': [False, TF],
'check_out_of_bound': [False, TF],
'print_accessor_ir': [False, TF],
'print_evaluator_ir': [False, TF],
'print_struct_llvm_ir': [False, TF],
'print_kernel_llvm_ir': [False, TF],
'print_kernel_llvm_ir_optimized': [False, TF],
# FIXME: figure out why these two failed test:
#'device_memory_fraction': [0.0, [0.5, 1, 0]],
#'device_memory_GB': [1.0, [0.5, 1, 1.5, 2]],
Expand Down

0 comments on commit 65bf964

Please sign in to comment.