Skip to content

Commit ed44d8b

Browse files
committed
Write errors/warnings to std::err
1 parent 55c9432 commit ed44d8b

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

amd/hipcc/src/hipBin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ THE SOFTWARE.
2323
#include "hipBin_util.h"
2424
#include "hipBin_amd.h"
2525
#include "hipBin_nvidia.h"
26+
#include <iostream>
2627
#include <vector>
2728
#include <string>
2829

@@ -75,7 +76,7 @@ HipBin::HipBin() {
7576
}
7677
// if no device is detected, then it is defaulted to AMD
7778
if (!platformDetected) {
78-
cout << "Device not supported - Defaulting to AMD" << endl;
79+
std::cerr << "Device not supported - Defaulting to AMD" << endl;
7980
// populates the struct with AMD info
8081
const PlatformInfo& platformInfo = hipBinAMDPtr_->getPlatformInfo();
8182
platformVec_.push_back(platformInfo);
@@ -109,7 +110,7 @@ void HipBin::executeHipBin(string filename, int argc, char* argv[]) {
109110
} else if (hipBinUtilPtr_->substringPresent(filename, "hipcc")) {
110111
executeHipCC(argc, argv);
111112
} else {
112-
cout << "Command " << filename
113+
std::cerr << "Command " << filename
113114
<< " not supported. Name the exe as hipconfig"
114115
<< " or hipcc and then try again ..." << endl;
115116
exit(-1);

amd/hipcc/src/hipBin_amd.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ THE SOFTWARE.
2525

2626
#include "hipBin_base.h"
2727
#include "hipBin_util.h"
28+
#include <iostream>
2829
#include <vector>
2930
#include <string>
3031
#include <unordered_set>
@@ -296,7 +297,7 @@ string HipBinAmd::getCompilerVersion() {
296297
}
297298
}
298299
} else {
299-
cout << "Hip Clang Compiler not found" << endl;
300+
std::cerr << "Hip Clang Compiler not found" << endl;
300301
}
301302
return complierVersion;
302303
}
@@ -379,7 +380,7 @@ bool HipBinAmd::detectPlatform() {
379380
var.hipPlatformEnv_ == "hcc") {
380381
detected = true;
381382
if (var.hipPlatformEnv_ == "hcc")
382-
cout <<
383+
std::cerr <<
383384
"Warning: HIP_PLATFORM=hcc is deprecated."<<
384385
"Please use HIP_PLATFORM=amd." << endl;
385386
}
@@ -425,7 +426,7 @@ void HipBinAmd::checkHipconfig() {
425426
cout << endl << "Check system installation: " << endl;
426427
cout << "check hipconfig in PATH..." << endl;
427428
if (system("which hipconfig > /dev/null 2>&1") != 0) {
428-
cout << "FAIL " << endl;
429+
std::cerr << "FAIL " << endl;
429430
} else {
430431
cout << "good" << endl;
431432
}
@@ -436,7 +437,7 @@ void HipBinAmd::checkHipconfig() {
436437
cout << "check LD_LIBRARY_PATH (" << ldLibraryPath <<
437438
") contains HSA_PATH (" << hsaPath << ")..." << endl;
438439
if (ldLibraryPath.find(hsaPath) == string::npos) {
439-
cout << "FAIL" << endl;
440+
std::cerr << "FAIL" << endl;
440441
} else {
441442
cout << "good" << endl;
442443
}
@@ -619,8 +620,8 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
619620
string pattern = "^" + targetOpt + ".*";
620621
if (hipBinUtilPtr_->stringRegexMatch(arg, pattern)) {
621622
if (targetOpt == "--amdgpu-target=") {
622-
cout << "Warning: The --amdgpu-target option has been deprecated and will be removed in the future."
623-
<< " Use --offload-arch instead.\n";
623+
std::cerr << "Warning: The --amdgpu-target option has been deprecated and will be removed in the future."
624+
<< " Use --offload-arch instead.\n";
624625
}
625626
// If targets string is not empty,
626627
// add a comma before adding new target option value.
@@ -669,8 +670,8 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
669670
}
670671
if (hipBinUtilPtr_->substringPresent(
671672
arg, "--amdhsa-code-object-version=")) {
672-
cout << "Warning: The --amdhsa-code-object-version option has been deprecated and will be removed in the future."
673-
<< " Use -mllvm -mcode-object-version instead.\n";
673+
std::cerr << "Warning: The --amdhsa-code-object-version option has been deprecated and will be removed in the future."
674+
<< " Use -mllvm -mcode-object-version instead.\n";
674675
arg = hipBinUtilPtr_->replaceStr(
675676
arg, "--amdhsa-code-object-version=", "");
676677
hsacoVersion = arg;
@@ -689,7 +690,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
689690
string file = split_arg.at(1);
690691
ifstream in(file);
691692
if (!in.is_open()) {
692-
cout << "unable to open file for reading: " << file << endl;
693+
std::cerr << "unable to open file for reading: " << file << endl;
693694
exit(-1);
694695
}
695696
string new_arg;
@@ -698,7 +699,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
698699
new_file /= "response_file";
699700
ofstream out(new_file);
700701
if (!out.is_open()) {
701-
cout << "unable to open file for writing: " <<
702+
std::cerr << "unable to open file for writing: " <<
702703
new_file.string() << endl;
703704
exit(-1);
704705
}
@@ -884,10 +885,10 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
884885
if (hipBinUtilPtr_->stringRegexMatch(arg, "^--hipcc.*")) {
885886
swallowArg = 1;
886887
if (arg == "--hipcc-func-supp") {
887-
cout << "Warning: The --hipcc-func-supp option has been deprecated and will be removed in the future.\n";
888+
std::cerr << "Warning: The --hipcc-func-supp option has been deprecated and will be removed in the future.\n";
888889
funcSupp = 1;
889890
} else if (arg == "--hipcc-no-func-supp") {
890-
cout << "Warning: The --hipcc-no-func-supp option has been deprecated and will be removed in the future.\n";
891+
std::cerr << "Warning: The --hipcc-no-func-supp option has been deprecated and will be removed in the future.\n";
891892
funcSupp = 0;
892893
}
893894
} else {
@@ -981,7 +982,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
981982
// does not check if the device supports the feature or not
982983
// e.g. vega10 does not support sramecc
983984
if (knownFeatures.find(procAndFeatures.at(i)) == knownFeatures.end()) {
984-
cout << "Warning: The Feature: "<< procAndFeatures.at(i) <<
985+
std::cerr << "Warning: The Feature: "<< procAndFeatures.at(i) <<
985986
" is unknown. Correct compilation is not guaranteed.\n";
986987
}
987988
}
@@ -1006,8 +1007,8 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
10061007
// rocm_agent_enumerator failed! Throw an error and die if linking is required
10071008
if (default_amdgpu_target == 1 && compileOnly == 0) {
10081009
// TODO(agunashe) exit from function
1009-
cout << "No valid AMD GPU target was either specified or found."
1010-
<< "Please specify a valid target using --offload-arch=<target>.\n";
1010+
std::cerr << "No valid AMD GPU target was either specified or found."
1011+
<< "Please specify a valid target using --offload-arch=<target>.\n";
10111012
}
10121013
HCC_EXTRA_LIBRARIES ="\n"; // TODO(agunashe) write to env
10131014

@@ -1119,7 +1120,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
11191120
string cmdOut = sysOut.out;
11201121
int CMD_EXIT_CODE = sysOut.exitCode;
11211122
if (CMD_EXIT_CODE !=0) {
1122-
cout << "failed to execute:" << CMD << std::endl;
1123+
std::cerr << "failed to execute:" << CMD << std::endl;
11231124
}
11241125
exit(CMD_EXIT_CODE);
11251126
} // end of runCmd section

amd/hipcc/src/hipBin_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ THE SOFTWARE.
2424

2525

2626
#include "hipBin_util.h"
27+
#include <iostream>
2728
#include <vector>
2829
#include <string>
2930

amd/hipcc/src/hipBin_nvidia.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ THE SOFTWARE.
2525

2626
#include "hipBin_base.h"
2727
#include "hipBin_util.h"
28+
#include <iostream>
2829
#include <vector>
2930
#include <string>
3031

@@ -88,7 +89,7 @@ bool HipBinNvidia::detectPlatform() {
8889
if (var.hipPlatformEnv_ == "nvidia" || var.hipPlatformEnv_ == "nvcc") {
8990
detected = true;
9091
if (var.hipPlatformEnv_ == "nvcc")
91-
cout << "Warning: HIP_PLATFORM=nvcc is deprecated."
92+
std::cerr << "Warning: HIP_PLATFORM=nvcc is deprecated."
9293
<< "Please use HIP_PLATFORM=nvidia." << endl;
9394
}
9495
}
@@ -126,7 +127,7 @@ void HipBinNvidia::checkHipconfig() {
126127
cout << endl << "Check system installation: " << endl;
127128
cout << "check hipconfig in PATH..." << endl;
128129
if (system("which hipconfig > /dev/null 2>&1") != 0) {
129-
cout << "FAIL " << endl;
130+
std::cerr << "FAIL " << endl;
130131
} else {
131132
cout << "good" << endl;
132133
}

amd/hipcc/src/hipBin_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ string HipBinUtil::getSelfPath() const {
213213
fs::path exePath(path);
214214
path = exePath.parent_path().string();
215215
} else {
216-
cout << "readlink: Error reading the exe path" << endl;
216+
std::cerr << "readlink: Error reading the exe path" << endl;
217217
perror("readlink");
218218
exit(-1);
219219
}
@@ -297,10 +297,10 @@ void HipBinUtil::deleteTempFiles() {
297297
for (unsigned int i = 0; i < tmpFiles_.size(); i++) {
298298
try {
299299
if (!fs::remove(tmpFiles_.at(i)))
300-
cout << "Error deleting temp name: "<< tmpFiles_.at(i) <<endl;
300+
std::cerr << "Error deleting temp name: "<< tmpFiles_.at(i) <<endl;
301301
}
302302
catch(...) {
303-
cout << "Error deleting temp name: "<< tmpFiles_.at(i) <<endl;
303+
std::cerr << "Error deleting temp name: "<< tmpFiles_.at(i) <<endl;
304304
}
305305
}
306306
}
@@ -332,7 +332,7 @@ SystemCmdOut HipBinUtil::exec(const char* cmd,
332332
result += buffer;
333333
}
334334
} catch (...) {
335-
cout << "Error while executing the command: " << cmd << endl;
335+
std::cerr << "Error while executing the command: " << cmd << endl;
336336
}
337337
#if defined(_WIN32) || defined(_WIN64)
338338
sysOut.exitCode = _pclose(pipe);

0 commit comments

Comments
 (0)