Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 72d1247

Browse filesBrowse files
committed
Fix warnings related to Version class
1 parent 786c249 commit 72d1247
Copy full SHA for 72d1247

File tree

Expand file treeCollapse file tree

6 files changed

+36
-29
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+36
-29
lines changed

‎src/backend/common/ArrayFireTypesIO.hpp

Copy file name to clipboardExpand all lines: src/backend/common/ArrayFireTypesIO.hpp
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ struct fmt::formatter<arrayfire::common::Version> {
6464
template<typename FormatContext>
6565
auto format(const arrayfire::common::Version& ver, FormatContext& ctx)
6666
-> decltype(ctx.out()) {
67-
if (ver.major == -1) return format_to(ctx.out(), "N/A");
68-
if (ver.minor == -1) show_minor = false;
69-
if (ver.patch == -1) show_patch = false;
67+
if (ver.major() == -1) return format_to(ctx.out(), "N/A");
68+
if (ver.minor() == -1) show_minor = false;
69+
if (ver.patch() == -1) show_patch = false;
7070
if (show_major && !show_minor && !show_patch) {
71-
return format_to(ctx.out(), "{}", ver.major);
71+
return format_to(ctx.out(), "{}", ver.major());
7272
}
7373
if (show_major && show_minor && !show_patch) {
74-
return format_to(ctx.out(), "{}.{}", ver.major, ver.minor);
74+
return format_to(ctx.out(), "{}.{}", ver.major(), ver.minor());
7575
}
7676
if (show_major && show_minor && show_patch) {
77-
return format_to(ctx.out(), "{}.{}.{}", ver.major, ver.minor,
78-
ver.patch);
77+
return format_to(ctx.out(), "{}.{}.{}", ver.major(), ver.minor(),
78+
ver.patch());
7979
}
8080
return ctx.out();
8181
}

‎src/backend/common/DependencyModule.cpp

Copy file name to clipboardExpand all lines: src/backend/common/DependencyModule.cpp
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ vector<string> libNames(const std::string& name, const string& suffix,
5252
UNUSED(suffix);
5353
const string noVerName = libraryPrefix + name + librarySuffix;
5454
if (ver != arrayfire::common::NullVersion) {
55-
const string infix = "." + to_string(ver.major) + ".";
55+
const string infix = "." + to_string(ver.major()) + ".";
5656
return {libraryPrefix + name + infix + librarySuffix, noVerName};
5757
} else {
5858
return {noVerName};
@@ -71,10 +71,11 @@ vector<string> libNames(const std::string& name, const string& suffix,
7171
UNUSED(suffix);
7272
const string noVerName = libraryPrefix + name + librarySuffix;
7373
if (ver != arrayfire::common::NullVersion) {
74-
const string soname("." + to_string(ver.major));
74+
const string soname("." + to_string(ver.major()));
7575

76-
const string vsfx = "." + to_string(ver.major) + "." +
77-
to_string(ver.minor) + "." + to_string(ver.patch);
76+
const string vsfx = "." + to_string(ver.major()) + "." +
77+
to_string(ver.minor()) + "." +
78+
to_string(ver.patch());
7879
return {noVerName + vsfx, noVerName + soname, noVerName};
7980
} else {
8081
return {noVerName};

‎src/backend/common/Version.hpp

Copy file name to clipboardExpand all lines: src/backend/common/Version.hpp
+15-10Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121

2222
namespace arrayfire {
2323
namespace common {
24-
struct Version {
25-
int major = -1;
26-
int minor = -1;
27-
int patch = -1;
24+
class Version {
25+
int major_ = -1;
26+
int minor_ = -1;
27+
int patch_ = -1;
2828

29+
public:
2930
/// Checks if the major version is defined before minor and minor is defined
3031
/// before patch
3132
constexpr static bool validate(int major_, int minor_,
@@ -34,14 +35,18 @@ struct Version {
3435
!(minor_ < 0 && patch_ >= 0);
3536
}
3637

38+
constexpr int major() const { return major_; }
39+
constexpr int minor() const { return minor_; }
40+
constexpr int patch() const { return patch_; }
41+
3742
constexpr Version(const int ver_major, const int ver_minor = -1,
3843
const int ver_patch = -1) noexcept
39-
: major(ver_major), minor(ver_minor), patch(ver_patch) {}
44+
: major_(ver_major), minor_(ver_minor), patch_(ver_patch) {}
4045
};
4146

4247
constexpr bool operator==(const Version& lhs, const Version& rhs) {
43-
return lhs.major == rhs.major && lhs.minor == rhs.minor &&
44-
lhs.patch == rhs.patch;
48+
return lhs.major() == rhs.major() && lhs.minor() == rhs.minor() &&
49+
lhs.patch() == rhs.patch();
4550
}
4651

4752
constexpr bool operator!=(const Version& lhs, const Version& rhs) {
@@ -52,11 +57,11 @@ constexpr static Version NullVersion{-1, -1, -1};
5257

5358
constexpr bool operator<(const Version& lhs, const Version& rhs) {
5459
if (lhs == NullVersion || rhs == NullVersion) return false;
55-
if (lhs.major != -1 && rhs.major != -1 && lhs.major < rhs.major)
60+
if (lhs.major() != -1 && rhs.major() != -1 && lhs.major() < rhs.major())
5661
return true;
57-
if (lhs.minor != -1 && rhs.minor != -1 && lhs.minor < rhs.minor)
62+
if (lhs.minor() != -1 && rhs.minor() != -1 && lhs.minor() < rhs.minor())
5863
return true;
59-
if (lhs.patch != -1 && rhs.patch != -1 && lhs.patch < rhs.patch)
64+
if (lhs.patch() != -1 && rhs.patch() != -1 && lhs.patch() < rhs.patch())
6065
return true;
6166
return false;
6267
}

‎src/backend/cuda/convolveNN.cpp

Copy file name to clipboardExpand all lines: src/backend/cuda/convolveNN.cpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pair<cudnnConvolutionFwdAlgo_t, size_t> getForwardAlgorithm(
7070
size_t workspace_bytes = 0;
7171

7272
auto version = getCudnnPlugin().getVersion();
73-
if (version.major >= 8) {
73+
if (version.major() >= 8) {
7474
int maxAlgoCount = 0;
7575
CUDNN_CHECK(cuda::cudnnGetConvolutionForwardAlgorithmMaxCount(
7676
cudnn, &maxAlgoCount));
@@ -419,7 +419,7 @@ pair<cudnnConvolutionBwdFilterAlgo_t, size_t> getBackwardFilterAlgorithm(
419419
size_t workspace_bytes = 0;
420420

421421
auto version = getCudnnPlugin().getVersion();
422-
if (version.major >= 8) {
422+
if (version.major() >= 8) {
423423
int maxAlgoCount = 0;
424424
CUDNN_CHECK(cuda::cudnnGetConvolutionBackwardFilterAlgorithmMaxCount(
425425
cudnn, &maxAlgoCount));

‎src/backend/cuda/cudnn.cpp

Copy file name to clipboardExpand all lines: src/backend/cuda/cudnn.cpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ cudnnStatus_t cudnnGetConvolutionForwardAlgorithm(
238238
cudnnConvolutionFwdPreference_t preference, size_t memoryLimitInBytes,
239239
cudnnConvolutionFwdAlgo_t *algo) {
240240
auto version = getCudnnPlugin().getVersion();
241-
if (version.major < 8) {
241+
if (version.major() < 8) {
242242
return getCudnnPlugin().cudnnGetConvolutionForwardAlgorithm(
243243
handle, xDesc, wDesc, convDesc, yDesc, preference,
244244
memoryLimitInBytes, algo);
@@ -259,7 +259,7 @@ cudnnStatus_t cudnnGetConvolutionBackwardFilterAlgorithm(
259259
cudnnConvolutionBwdFilterPreference_t preference, size_t memoryLimitInBytes,
260260
cudnnConvolutionBwdFilterAlgo_t *algo) {
261261
auto version = getCudnnPlugin().getVersion();
262-
if (version.major < 8) {
262+
if (version.major() < 8) {
263263
return getCudnnPlugin().cudnnGetConvolutionBackwardFilterAlgorithm(
264264
handle, xDesc, dyDesc, convDesc, dwDesc, preference,
265265
memoryLimitInBytes, algo);

‎src/backend/cuda/cudnnModule.cpp

Copy file name to clipboardExpand all lines: src/backend/cuda/cudnnModule.cpp
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ cudnnModule::cudnnModule()
111111

112112
// Check to see if the version of cuDNN ArrayFire was compiled against
113113
// is compatible with the version loaded at runtime
114-
if (compiled_cudnn_version.major <= 6 &&
114+
if (compiled_cudnn_version.major() <= 6 &&
115115
compiled_cudnn_version < cudnn_version) {
116116
string error_msg = fmt::format(
117117
"ArrayFire was compiled with an older version of cuDNN({}.{}) that "
118118
"does not support the version that was loaded at runtime({}.{}).",
119-
CUDNN_MAJOR, CUDNN_MINOR, cudnn_version.major, cudnn_version.minor);
119+
CUDNN_MAJOR, CUDNN_MINOR, cudnn_version.major(),
120+
cudnn_version.minor());
120121
AF_ERROR(error_msg, AF_ERR_NOT_SUPPORTED);
121122
}
122123

@@ -152,14 +153,14 @@ cudnnModule::cudnnModule()
152153
MODULE_FUNCTION_INIT(cudnnGetConvolutionBackwardFilterWorkspaceSize);
153154
MODULE_FUNCTION_INIT(cudnnFindConvolutionForwardAlgorithm);
154155
MODULE_FUNCTION_INIT(cudnnFindConvolutionBackwardFilterAlgorithm);
155-
if (cudnn_version.major < 8) {
156+
if (cudnn_version.major() < 8) {
156157
MODULE_FUNCTION_INIT(cudnnGetConvolutionForwardAlgorithm);
157158
MODULE_FUNCTION_INIT(cudnnGetConvolutionBackwardFilterAlgorithm);
158159
}
159160
MODULE_FUNCTION_INIT(cudnnGetConvolutionNdForwardOutputDim);
160161
MODULE_FUNCTION_INIT(cudnnSetConvolution2dDescriptor);
161162
MODULE_FUNCTION_INIT(cudnnSetFilter4dDescriptor);
162-
if (cudnn_version.major == 4) {
163+
if (cudnn_version.major() == 4) {
163164
MODULE_FUNCTION_INIT(cudnnSetFilter4dDescriptor_v4);
164165
}
165166
MODULE_FUNCTION_INIT(cudnnSetStream);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.