SWDEV-306940 - Fix hip errors/warnings by CppCheck (#2486)
Change-Id: I91f5e97b0c7ca80b6d21fa66d24e3cf9fde716a9
[ROCm/hip-tests commit: 833e962ddd]
Цей коміт міститься в:
зафіксовано
GitHub
джерело
750df46bf8
коміт
4e9ddeee7d
@@ -69,9 +69,6 @@ int main() {
|
||||
HIP_CHECK(hipModuleLoad(&Module, fileName));
|
||||
HIP_CHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
uint32_t len = LEN;
|
||||
uint32_t one = 1;
|
||||
|
||||
struct {
|
||||
void* _Ad;
|
||||
void* _Bd;
|
||||
|
||||
@@ -401,7 +401,6 @@ void ResultDatabase::DumpCsv(string fileName) {
|
||||
// ****************************************************************************
|
||||
|
||||
bool ResultDatabase::IsFileEmpty(string fileName) {
|
||||
bool fileEmpty;
|
||||
|
||||
ifstream file(fileName.c_str());
|
||||
|
||||
@@ -409,6 +408,7 @@ bool ResultDatabase::IsFileEmpty(string fileName) {
|
||||
if (!file.good()) {
|
||||
return true;
|
||||
} else {
|
||||
bool fileEmpty;
|
||||
fileEmpty = (bool)(file.peek() == ifstream::traits_type::eof());
|
||||
file.close();
|
||||
|
||||
|
||||
@@ -252,9 +252,9 @@ void RunBenchmark_H2D(ResultDatabase& resultDB) {
|
||||
|
||||
case MallocUnpinned:
|
||||
if (p_alignedhost) {
|
||||
delete[] hostMem;
|
||||
} else {
|
||||
free(hostMem);
|
||||
} else {
|
||||
delete[] hostMem;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -393,7 +393,6 @@ void ResultDatabase::DumpCsv(string fileName) {
|
||||
// ****************************************************************************
|
||||
|
||||
bool ResultDatabase::IsFileEmpty(string fileName) {
|
||||
bool fileEmpty;
|
||||
|
||||
ifstream file(fileName.c_str());
|
||||
|
||||
@@ -401,6 +400,7 @@ bool ResultDatabase::IsFileEmpty(string fileName) {
|
||||
if (!file.good()) {
|
||||
return true;
|
||||
} else {
|
||||
bool fileEmpty;
|
||||
fileEmpty = (bool)(file.peek() == ifstream::traits_type::eof());
|
||||
file.close();
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ class Command {
|
||||
// HCC optimizes away fully NULL kernel calls, so run one that is nearly null:
|
||||
class ModuleKernelCommand : public Command {
|
||||
public:
|
||||
ModuleKernelCommand(CommandStream* cmdStream, const std::vector<std::string> args)
|
||||
ModuleKernelCommand(CommandStream* cmdStream, const std::vector<std::string>& args)
|
||||
: Command(cmdStream, args), _stream(cmdStream->currentStream()) {
|
||||
hipModule_t module;
|
||||
HIPCHECK(hipModuleLoad(&module, FILENAME));
|
||||
@@ -316,7 +316,7 @@ class ModuleKernelCommand : public Command {
|
||||
class KernelCommand : public Command {
|
||||
public:
|
||||
enum Type { Null, VectorAdd };
|
||||
KernelCommand(CommandStream* cmdStream, const std::vector<std::string> args, Type kind)
|
||||
KernelCommand(CommandStream* cmdStream, const std::vector<std::string>& args, Type kind)
|
||||
: Command(cmdStream, args), _kind(kind), _stream(cmdStream->currentStream()){};
|
||||
~KernelCommand(){};
|
||||
|
||||
@@ -390,7 +390,7 @@ class CopyCommand : public Command {
|
||||
};
|
||||
|
||||
|
||||
void dealloc(void* p, MemType memType) {
|
||||
static void dealloc(void* p, MemType memType) {
|
||||
if (memType == Device) {
|
||||
HIPCHECK(hipFree(p));
|
||||
} else if (memType == PinnedHost) {
|
||||
@@ -433,7 +433,7 @@ class StreamSyncCommand : public Command {
|
||||
StreamSyncCommand(CommandStream* cmdStream, const std::vector<std::string>& args)
|
||||
: Command(cmdStream, args), _stream(cmdStream->currentStream()){};
|
||||
|
||||
const char* help() { return "synchronizes the current stream"; };
|
||||
static const char* help() { return "synchronizes the current stream"; };
|
||||
|
||||
|
||||
void run() override { HIPCHECK(hipStreamSynchronize(_stream)); };
|
||||
@@ -537,8 +537,8 @@ CopyCommand::CopyCommand(CommandStream* cmdStream, const std::vector<std::string
|
||||
hipMemcpyKind kind, bool isAsync, bool isPinnedHost)
|
||||
: Command(cmdStream, args),
|
||||
_isAsync(isAsync),
|
||||
_kind(kind),
|
||||
_stream(cmdStream->currentStream()) {
|
||||
_stream(cmdStream->currentStream()),
|
||||
_kind(kind) {
|
||||
switch (kind) {
|
||||
case hipMemcpyDeviceToHost:
|
||||
_srcType = Device;
|
||||
|
||||
@@ -48,17 +48,14 @@ __global__ void incrementKernel(int32_t* in, int32_t* out, int32_t value, size_t
|
||||
|
||||
int main() {
|
||||
int32_t incrementValue = 10;
|
||||
// Host pointers
|
||||
int32_t* hInput = nullptr;
|
||||
int32_t* hOutput = nullptr;
|
||||
// Device pointers
|
||||
int32_t* dInput = nullptr;
|
||||
int32_t* dOutput = nullptr;
|
||||
|
||||
size_t NBytes = SIZE * sizeof(int32_t);
|
||||
|
||||
hInput = static_cast<int32_t*>(malloc(NBytes));
|
||||
hOutput = static_cast<int32_t*>(malloc(NBytes));
|
||||
// Host pointers
|
||||
int32_t* hInput = static_cast<int32_t*>(malloc(NBytes));
|
||||
int32_t* hOutput = static_cast<int32_t*>(malloc(NBytes));
|
||||
|
||||
HIP_STATUS_CHECK(hipMalloc(&dInput, NBytes));
|
||||
HIP_STATUS_CHECK(hipMalloc(&dOutput, NBytes));
|
||||
@@ -95,4 +92,4 @@ int main() {
|
||||
std::cout << "success\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ void run_test2() {
|
||||
|
||||
HIP_ASSERT(hipFree(A_d));
|
||||
HIP_ASSERT(hipFree(B_d));
|
||||
free(A_h);
|
||||
free(B_h);
|
||||
delete [] A_h;
|
||||
delete [] B_h;
|
||||
std::cout << "Test Passed!\n";
|
||||
}
|
||||
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача