Skip to content

Commit 99dadd7

Browse files
wyz5864fandaoyi
andauthored
[dipu]clang tidy (#519)
* fix tidy * fix tidy * format * format * Update dipu/torch_dipu/csrc_dipu/vendor/cuda/communiatorimpl.cpp --------- Co-authored-by: fandaoyi <344031146@qq.com>
1 parent 22e1a82 commit 99dadd7

File tree

12 files changed

+159
-146
lines changed

12 files changed

+159
-146
lines changed

dipu/torch_dipu/csrc_dipu/runtime/core/MemChecker.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ int32_t MemChecker::log_interval() {
7373

7474
std::string MemChecker::current_state() const {
7575
std::stringstream stream;
76-
stream << "current block num = " << blocks_.size()
77-
<< ", total_size = " << (total_size_ >> 20) << "MB"
78-
<< ", insert count = " << insert_cnt_
79-
<< ", max block num = " << max_block_num()
80-
<< ", log interval = " << log_interval();
76+
stream
77+
<< "current block num = "
78+
<< blocks_.size()
79+
// convert B to MB
80+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
81+
<< ", total_size = " << (total_size_ >> 20) << "MB"
82+
<< ", insert count = " << insert_cnt_
83+
<< ", max block num = " << max_block_num()
84+
<< ", log interval = " << log_interval();
8185
return stream.str();
8286
}
8387

dipu/torch_dipu/csrc_dipu/runtime/core/MemChecker.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) 2023, DeepLink.
22
#pragma once
33

4+
#include <cstdint>
45
#include <mutex>
5-
#include <stdint.h>
66
#include <string>
77
#include <unordered_map>
88
#include <utility>
@@ -28,7 +28,6 @@ class MemChecker final {
2828
private:
2929
std::string current_state() const;
3030

31-
private:
3231
std::mutex mtx_;
3332
std::unordered_map<const void*, std::pair<size_t, std::string>> blocks_;
3433
int64_t total_size_ = 0;

dipu/torch_dipu/csrc_dipu/runtime/device/basedef.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace dipu {
1616
// "default", "hidden", "protected" or "internal
1717
#define DIPU_HIDDEN __attribute__((visibility("hidden")))
1818

19-
typedef int32_t enum_t;
19+
using enum_t = int32_t;
2020

2121
#define DIPU_STRING(x) #x
2222
#define DIPU_CODELOC __FILE__ " (" DIPU_STRING(__LINE__) ")"
@@ -55,14 +55,14 @@ enum class MemCPKind : enum_t {
5555
D2D,
5656
};
5757

58-
typedef enum {
58+
enum diclResult_t {
5959
/*! The operation was successful. */
6060
DICL_SUCCESS = 0x0,
6161

6262
/*! undefined error */
6363
DICL_ERR_UNDEF = 0x01000,
6464

65-
} diclResult_t;
65+
};
6666

6767
struct DIPUDeviceStatus {
6868
size_t freeGlobalMem = 0;

dipu/torch_dipu/csrc_dipu/runtime/devproxy/deviceproxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DIPUDeviceStatus getDeviceStatus(int32_t device_index) {
2828
if (devapis::getDeviceStatus) {
2929
return devapis::getDeviceStatus(device_index);
3030
}
31-
return DIPUDeviceStatus();
31+
return {};
3232
}
3333

3434
// set current device given device according to id

0 commit comments

Comments
 (0)