Skip to content

Commit 8439fc1

Browse files
authored
[Comgr] Add log entry for storing cache results
Comgr previously logged when a cache entry was found, but not when it was stored. This PR adds a stored log message and puts the found/stored distinction at the beginning of the message to make things more clear. (llvm#3987)
1 parent 7f8b37f commit 8439fc1

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

amd/comgr/src/comgr-cache.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ amd_comgr_status_t CommandCache::execute(CachedCommandAdaptor &C,
236236
AddStreamFn &AddStream = *AddStreamOrErr;
237237
if (!AddStream && readEntryFromCache(C, *CachedBuffer, LogS)) {
238238
if (env::shouldEmitVerboseLogs())
239-
LogS << "Comgr cache: entry " << *MaybeId << " found in cache.\n";
239+
LogS << "Comgr cache: found entry " << *MaybeId << " in cache.\n";
240240
return AMD_COMGR_STATUS_SUCCESS;
241241
}
242242

@@ -247,6 +247,8 @@ amd_comgr_status_t CommandCache::execute(CachedCommandAdaptor &C,
247247
LogS << CapturedLogS;
248248

249249
if (Result == AMD_COMGR_STATUS_SUCCESS && AddStream) {
250+
if (env::shouldEmitVerboseLogs())
251+
LogS << "Comgr cache: stored entry " << *MaybeId << " in cache.\n";
250252
saveCommandOutput(C, AddStream, CapturedLogS, LogS);
251253
}
252254

amd/comgr/test-lit/cache-tests/compile-minimal-test-cached.cl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
// RUN: rm -fr %t.cache
22
//
3+
// RUN: export AMD_COMGR_EMIT_VERBOSE_LOGS=1
4+
// RUN: export AMD_COMGR_REDIRECT_LOGS=stdout
5+
//
6+
//
7+
// COM: Check the default behavior of AMD_COMGR_CACHE
38
// RUN: unset AMD_COMGR_CACHE
49
// RUN: AMD_COMGR_CACHE_DIR=%t.cache compile-opencl-minimal \
5-
// RUN: %S/../compile-minimal-test.cl %t.bin 1.2
10+
// RUN: %S/../compile-minimal-test.cl %t.bin 1.2 | FileCheck --check-prefix=STORED %s
611
// RUN: llvm-objdump -d %t.bin | FileCheck %S/../compile-minimal-test.cl
712
// RUN: [ -d %t.cache ]
813
//
14+
// RUN: AMD_COMGR_CACHE_DIR=%t.cache compile-opencl-minimal \
15+
// RUN: %S/../compile-minimal-test.cl %t.bin 1.2 | FileCheck --check-prefix=FOUND %s
16+
// RUN: llvm-objdump -d %t.bin | FileCheck %S/../compile-minimal-test.cl
17+
//
918
// RUN: rm -fr %t.cache
1019
//
1120
// RUN: export AMD_COMGR_CACHE=0
@@ -20,7 +29,7 @@
2029
// COM 1 element (one for the cache tag, one or more for the cached
2130
// COM: commands)
2231
// RUN: AMD_COMGR_CACHE_DIR=%t.cache compile-opencl-minimal \
23-
// RUN: %S/../compile-minimal-test.cl %t_a.bin 1.2
32+
// RUN: %S/../compile-minimal-test.cl %t_a.bin 1.2 | FileCheck --check-prefix=STORED %s
2433
// RUN: llvm-objdump -d %t_a.bin | FileCheck %S/../compile-minimal-test.cl
2534
// RUN: COUNT_BEFORE=$(ls "%t.cache" | wc -l)
2635

@@ -29,8 +38,14 @@
2938
// RUN: [ 4 -eq $COUNT_BEFORE ]
3039
//
3140
// RUN: AMD_COMGR_CACHE_DIR=%t.cache compile-opencl-minimal \
32-
// RUN: %S/../compile-minimal-test.cl %t_b.bin 1.2
41+
// RUN: %S/../compile-minimal-test.cl %t_b.bin 1.2 | FileCheck --check-prefix=FOUND %s
3342
// RUN: llvm-objdump -d %t_b.bin | FileCheck %S/../compile-minimal-test.cl
3443
// RUN: COUNT_AFTER=$(ls "%t.cache" | wc -l)
3544
// RUN: [ $COUNT_AFTER = $COUNT_BEFORE ]
3645
//
46+
47+
// COM: check that an entry is stored
48+
// STORED: Comgr cache: stored entry
49+
50+
// COM: check that an entry is found
51+
// FOUND: Comgr cache: found entry

0 commit comments

Comments
 (0)