feat(gpu): add common cache directory

This commit is contained in:
Anthony Berg 2025-06-25 15:08:10 +02:00
parent 4df7b9b6b7
commit 3aedef93cf
3 changed files with 9 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Cache directory for kernels from this repository
/.fvm_cache
.vscode/settings.json
/data

View File

@ -76,6 +76,7 @@ class HIPArray2D(BaseArray2D):
self.check(x, y, nx, ny, cpu_data)
# TODO implement non-async to test if it actually works - avoid errors
# Create a copy object from device to host
hip_check(hip.hipMemcpyAsync(self.data_d, self.data_h, self.num_bytes, hip.hipMemcpyKind.hipMemcpyHostToDevice,
stream))

View File

@ -5,6 +5,8 @@ import re
import logging
from hashlib import md5
from GPUSimulators.common.utils import get_project_root
class Context(object):
"""
@ -24,10 +26,10 @@ class Context(object):
self.autotuner = None
# Creates cache directory if specified
self.cache_path = os.path.join(self.module_path, f"{language}_cache")
self.cache_path = os.path.join(get_project_root(), ".fvm_cache", type(self).__name__.lower())
if self.use_cache:
if not os.path.isdir(self.cache_path):
os.mkdir(self.cache_path)
os.makedirs(self.cache_path)
self.logger.info(f"Using cache dir {self.cache_path}")
def __del__(self):
@ -81,7 +83,7 @@ class Context(object):
kernel_hasher.update(str(modified).encode('utf-8'))
# Find all the includes
includes = re.findall('^\W*#include\W+(.+?)\W*$', file_str, re.M)
includes = re.findall('^\\W*#include\\W+(.+?)\\W*$', file_str, re.M)
# Iterate through everything that looks like is an ``include``
for include_file in includes: