Skip to content

Commit 059c469

Browse files
committed
pcm-raw: lookup event files from the install directory
1 parent 94d94db commit 059c469

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/pcm-raw.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,24 @@ bool initPMUEventMap()
217217
inited = true;
218218
const auto mapfile = "mapfile.csv";
219219
const auto mapfilePath = eventFileLocationPrefix + "/" + mapfile;
220+
const auto mapfilePathAlt = getInstallPathPrefix() + "perfmon/" + mapfile;
220221
std::ifstream in(mapfilePath);
221222
std::string line, item;
222223

223224
if (!in.is_open())
224225
{
225-
cerr << "ERROR: File " << mapfilePath << " can't be open. \n";
226-
cerr << " Use -ep <pcm_source_directory>/perfmon option if you cloned PCM source repository recursively with submodules,\n";
227-
cerr << " or run 'git clone https://github.com/intel/perfmon' to download the perfmon event repository and use -ep <perfmon_directory> option\n";
228-
cerr << " or download the file from https://raw.githubusercontent.com/intel/perfmon/main/" << mapfile << " \n";
229-
return false;
226+
in.open(mapfilePathAlt);
227+
if (!in.is_open())
228+
{
229+
cerr << "ERROR: File " << mapfilePath << " or " << mapfilePathAlt << " can't be open. \n";
230+
#ifndef _MSC_VER
231+
cerr << " run 'make install' in the pcm build directory if you cloned PCM source repository recursively with submodules, or\n";
232+
#endif
233+
cerr << " use -ep <pcm_source_directory>/perfmon option if you cloned PCM source repository recursively with submodules,\n";
234+
cerr << " or run 'git clone https://github.com/intel/perfmon' to download the perfmon event repository and use -ep <perfmon_directory> option\n";
235+
cerr << " or download the file from https://raw.githubusercontent.com/intel/perfmon/main/" << mapfile << " \n";
236+
return false;
237+
}
230238
}
231239
int32 FMSPos = -1;
232240
int32 FilenamePos = -1;
@@ -300,6 +308,7 @@ bool initPMUEventMap()
300308
{
301309
const std::string path1 = eventFileLocationPrefix + evfile.second;
302310
const std::string path2 = eventFileLocationPrefix + evfile.second.substr(evfile.second.rfind('/'));
311+
const std::string path3 = getInstallPathPrefix() + "perfmon" + evfile.second;
303312

304313
if (std::ifstream(path1).good())
305314
{
@@ -309,9 +318,13 @@ bool initPMUEventMap()
309318
{
310319
path = path2;
311320
}
321+
else if (std::ifstream(path3).good())
322+
{
323+
path = path3;
324+
}
312325
else
313326
{
314-
std::cerr << "ERROR: Can't open event file at location " << path1 << " or " << path2 << "\n";
327+
std::cerr << "ERROR: Can't open event file at location " << path1 << " or " << path2 << " or " << path3 << "\n";
315328
printError();
316329
return false;
317330
}

0 commit comments

Comments
 (0)