Skip to content

Commit

Permalink
add a control to find unique log and report file names (#384)
Browse files Browse the repository at this point in the history
Also, consistently use the spelling "file name" vs. "filename".
  • Loading branch information
bashbaug authored Oct 26, 2024
1 parent 6c290af commit f744665
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 103 deletions.
5 changes: 4 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ The most likely cause of this issue is an application that loads and unloads the
When this occurs, the report file will only contain data collected between the last time the OpenCL Intercept Layer was loaded and unloaded, which could be no data at all.
To determine if this issue is occurring, and to work around the issue if it is occurring, set the `AppendFiles` control.
`AppendFiles` causes logs and reports to append to an existing file instead of overwriting the file each time the OpenCL Intercept Layer is unloaded, preserving log or report data even when the OpenCL Intercept Layer is loaded and unloaded multiple times.
`AppendFiles` causes logs and reports to append to an existing file instead of overwriting the file each time the OpenCL Intercept Layer is loaded, preserving log or report data even when the OpenCL Intercept Layer is loaded and unloaded multiple times.
For another option, set the `UniqueFiles` control.
`UniqueFiles` will find a unique file name for each log and report file instead of overwriting the file each time the OpenCL Intercept Layer is loaded.
## How can I debug or analyze multiple instances of an application?
Expand Down
32 changes: 18 additions & 14 deletions docs/controls.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/injecting_programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ that this is a subdirectory of the dump directory.
If the application compiles programs deterministically the program(s) or program
options can be copied unchanged. If the application compiles programs
non-deterministically, you may need rename the programs to modify to remove the
program number or compile count from the filename.
program number or compile count from the file name.

The Intercept Layer for OpenCL Applications searches for program source filenames
to inject in this order:

* `CLI_<program number>_<hash>_source.cl` - This is the default filename dumped
* `CLI_<program number>_<hash>_source.cl` - This is the default file name dumped
by DumpProgramSource.
* `CLI_<hash>_source.cl` - This is the default filename with the program number
* `CLI_<hash>_source.cl` - This is the default file name with the program number
removed, so the order the application calls clCreateProgramWithSource() does
not matter.

The Intercept Layer for OpenCL Applications searches for program option filenames
to inject in this order:

* `CLI_<program number>_<hash>_<count>_options.txt` - This is the default filename
* `CLI_<program number>_<hash>_<count>_options.txt` - This is the default file name
dumped by DumpProgramSource.
* `CLI_<hash>_<count>_options.txt` - This is the default filename with the program
* `CLI_<hash>_<count>_options.txt` - This is the default file name with the program
number removed, so the order the application calls clCreateProgramWithSource()
does not matter.
* `CLI_<hash>_options.txt` - This has both the program number and compile count
Expand Down
2 changes: 2 additions & 0 deletions intercept/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ set(CLINTERCEPT_SOURCE_FILES
src/main.cpp
src/objtracker.cpp
src/objtracker.h
src/utils.cpp
src/utils.h
"${CMAKE_CURRENT_BINARY_DIR}/git_version.cpp"
)
source_group(Source FILES
Expand Down
2 changes: 1 addition & 1 deletion intercept/OS/OS_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Services : public Services_Common
size_t& length ) const;

bool ExecuteCommand(
const std::string& filename ) const;
const std::string& fileName ) const;
bool StartAubCapture(
const std::string& fileName,
uint64_t delay ) const;
Expand Down
2 changes: 1 addition & 1 deletion intercept/OS/OS_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Services : public Services_Common
size_t& length ) const;

bool ExecuteCommand(
const std::string& filename ) const;
const std::string& fileName ) const;
bool StartAubCapture(
const std::string& fileName,
uint64_t delay ) const;
Expand Down
2 changes: 1 addition & 1 deletion intercept/OS/OS_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Services : public Services_Common
size_t& length ) const;

bool ExecuteCommand(
const std::string& filename ) const;
const std::string& fileName ) const;
bool StartAubCapture(
const std::string& fileName,
uint64_t delay ) const;
Expand Down
7 changes: 6 additions & 1 deletion intercept/mdapi/intercept_mdapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "common.h"
#include "intercept.h"
#include "utils.h"

#define CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL 0x407F

Expand Down Expand Up @@ -202,12 +203,16 @@ void CLIntercept::initCustomPerfCounters()
std::string fileName = "";
OS().GetDumpDirectoryName( sc_DumpDirectoryName, fileName );
fileName += '/';
fileName += sc_DumpPerfCountersFileNamePrefix;
fileName += sc_PerfCountersFileNamePrefix;
fileName += "_";
fileName += metricSetSymbolName;
fileName += ".csv";

OS().MakeDumpDirectories( fileName );
if( m_Config.UniqueFiles )
{
fileName = Utils::GetUniqueFileName(fileName);
}

m_MetricDump.open( fileName.c_str(), std::ios::out | std::ios::binary );

Expand Down
4 changes: 2 additions & 2 deletions intercept/scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from collections import defaultdict

def get_image_metadata(idx: int):
filename = f"./Image_MetaData_{idx}.txt"
with open(filename) as metadata:
fileName = f"./Image_MetaData_{idx}.txt"
with open(fileName) as metadata:
lines = metadata.readlines()

image_type = int(lines[8])
Expand Down
Loading

0 comments on commit f744665

Please sign in to comment.