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

[test] Add simple test for offline-cache-key of compile-config #4805

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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