Skip to content

Commit

Permalink
[test] Add simple test for offline-cache-key of compile-config (taich…
Browse files Browse the repository at this point in the history
…i-dev#4805)

* Add simple test for using offline-cache with changing compile-config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and k-ye committed May 5, 2022
1 parent 8e12ca1 commit 80a9252
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/python/test_offline_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,48 @@ def helper():
assert len(listdir(
tmp_offline_cache_file_path())) - count_of_cache_file == len(
simple_kernels_to_test) * cache_files_num_per_kernel


@pytest.mark.parametrize('curr_arch', supported_archs_offline_cache)
@_test_offline_cache_dec
def test_offline_cache_with_changing_compile_config(curr_arch):
count_of_cache_file = len(listdir(tmp_offline_cache_file_path()))

@ti.kernel
def helper():
a = 100
b = 200
c = a / b
for i in range(b):
c += i

assert len(listdir(tmp_offline_cache_file_path())
) - count_of_cache_file == 0 * cache_files_num_per_kernel
ti.init(arch=curr_arch,
enable_fallback=False,
default_fp=ti.f32,
**current_thread_ext_options())
helper()

ti.init(arch=curr_arch,
enable_fallback=False,
default_fp=ti.f64,
**current_thread_ext_options())
assert len(listdir(tmp_offline_cache_file_path())
) - count_of_cache_file == 1 * cache_files_num_per_kernel
helper()

ti.reset()
assert len(listdir(tmp_offline_cache_file_path())
) - count_of_cache_file == 2 * cache_files_num_per_kernel

ti.init(arch=curr_arch,
enable_fallback=False,
default_fp=ti.f32,
cc_compile_cmd='gcc -Wc99-c11-compat -c -o \'{}\' \'{}\' -O0',
**current_thread_ext_options())
helper()

ti.reset()
assert len(listdir(tmp_offline_cache_file_path())
) - count_of_cache_file == 2 * cache_files_num_per_kernel

0 comments on commit 80a9252

Please sign in to comment.