Skip to content

Commit

Permalink
[test] Enable cfg_optimization in all tests (#2106)
Browse files Browse the repository at this point in the history
* [test] Enable cfg_optimization in all tests

* [skip ci] enforce code format

* trigger CI

* add a check of CompileConfig::cfg_optimization in full_simplify

Co-authored-by: Taichi Gardener <[email protected]>
  • Loading branch information
xumingkuan and taichi-gardener authored Dec 21, 2020
1 parent 65dad7e commit bd41157
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions taichi/transforms/compile_to_offloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void compile_to_offloads(IRNode *ir,
print("Offloaded");
irpass::analysis::verify(ir);

// TODO: This pass may be redundant as cfg_optimization() is already called
// in full_simplify().
if (config.cfg_optimization) {
irpass::cfg_optimization(ir, false);
print("Optimized by CFG");
Expand Down
1 change: 1 addition & 0 deletions taichi/transforms/simplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ void full_simplify(IRNode *root, bool after_lower_access, Kernel *kernel) {
if ((first_iteration || modified) && whole_kernel_cse(root))
modified = true;
if ((first_iteration || modified) &&
root->get_config().cfg_optimization &&
cfg_optimization(root, after_lower_access))
modified = true;
first_iteration = false;
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_bit_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_1D_bit_array():
ci1 = ti.type_factory_.get_custom_int_type(1, False)

Expand All @@ -28,7 +28,7 @@ def verify_val():
verify_val()


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_2D_bit_array():
ci1 = ti.type_factory_.get_custom_int_type(1, False)

Expand Down
11 changes: 4 additions & 7 deletions tests/python/test_bit_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_simple_array():
ci13 = ti.type_factory_.get_custom_int_type(13, True)
cu19 = ti.type_factory_.get_custom_int_type(19, False)
Expand Down Expand Up @@ -36,7 +36,7 @@ def verify_val():
verify_val.__wrapped__()


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_custom_int_load_and_store():
ci13 = ti.type_factory_.get_custom_int_type(13, True)
cu14 = ti.type_factory_.get_custom_int_type(14, False)
Expand Down Expand Up @@ -77,7 +77,7 @@ def verify_val(idx: ti.i32):
verify_val.__wrapped__(idx)


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_custom_int_full_struct():
cit = ti.type_factory_.get_custom_int_type(32, True)
x = ti.field(dtype=cit)
Expand Down Expand Up @@ -108,10 +108,7 @@ def varify_val2():
def test_bit_struct():
def test_single_bit_struct(physical_type, compute_type, custom_bits,
test_case):
ti.init(arch=ti.cpu,
debug=True,
print_ir=False,
cfg_optimization=False)
ti.init(arch=ti.cpu, debug=True, print_ir=False)

cit1 = ti.type_factory_.get_custom_int_type(custom_bits[0], True,
compute_type)
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_custom_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pytest import approx


@ti.test(require=ti.extension.quant, cfg_optimization=False)
@ti.test(require=ti.extension.quant)
def test_custom_float():
ci13 = ti.type_factory_.get_custom_int_type(13, True)
cft = ti.type_factory_.get_custom_float_type(ci13, ti.f32.get_ptr(), 0.1)
Expand All @@ -25,7 +25,7 @@ def foo():
assert x[None] == approx(0.7)


@ti.test(require=ti.extension.quant, cfg_optimization=False)
@ti.test(require=ti.extension.quant)
def test_custom_matrix_rotation():
ci16 = ti.type_factory_.get_custom_int_type(16, True)
cft = ti.type_factory_.get_custom_float_type(ci16, ti.f32.get_ptr(),
Expand Down
6 changes: 3 additions & 3 deletions tests/python/test_custom_type_atomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytest import approx


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_custom_int_atomics():
ci13 = ti.type_factory_.get_custom_int_type(13, True)
ci5 = ti.type_factory_.get_custom_int_type(5, True)
Expand Down Expand Up @@ -36,7 +36,7 @@ def foo():
assert z[None] == 3


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_custom_int_atomics_b64():
ci13 = ti.type_factory_.get_custom_int_type(13, True)

Expand All @@ -60,7 +60,7 @@ def foo():
assert x[2] == 315


@ti.test(require=ti.extension.quant, debug=True, cfg_optimization=False)
@ti.test(require=ti.extension.quant, debug=True)
def test_custom_float_atomics():
ci13 = ti.type_factory_.get_custom_int_type(13, True)
ci19 = ti.type_factory_.get_custom_int_type(19, False)
Expand Down

0 comments on commit bd41157

Please sign in to comment.