Skip to content

Commit 4161e1c

Browse files
authored
Enable clang-tidy for hip tests (#7943)
* Enable clang-tidy for hip tests Add HIP multi-threaded stream test Signed-off-by: Sonal Santan <[email protected]> * Add missing call to stream destroy * DCO Remediation Commit for Sonal Santan <[email protected]> I, Sonal Santan <[email protected]>, hereby add my Signed-off-by to this commit: 70b9a11 Signed-off-by: Sonal Santan <[email protected]> * Always enable clang-tidy in Debug configuration for hip runtime and hip test code Signed-off-by: Sonal Santan <[email protected]> --------- Signed-off-by: Sonal Santan <[email protected]>
1 parent 989c2ef commit 4161e1c

File tree

10 files changed

+754
-2
lines changed

10 files changed

+754
-2
lines changed

src/runtime_src/hip/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright (C) 2023 Advanced Micro Device, Inc. All rights reserved.
3+
4+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
5+
find_program(CLANG_TIDY "clang-tidy")
6+
if(NOT CLANG_TIDY)
7+
message(WARNING "-- clang-tidy not found, cannot enable static analysis")
8+
else()
9+
message("-- Enabling clang-tidy")
10+
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
11+
endif()
12+
endif()
13+
314
add_subdirectory(core)
415
add_subdirectory(api)
516

tests/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ PROJECT(TESTS)
99
set(CMAKE_CXX_STANDARD 17)
1010
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
1111
set(CMAKE_VERBOSE_MAKEFILE ON)
12-
1312
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1413

1514
add_subdirectory(unit_test)

tests/hip/.clang-tidy

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
---
2+
# The following configuration was generated with --dump-config and then manually tweaked to suit XRT coding style.
3+
# The command line used to generate the global src/.clang-tidy is:
4+
# clang-tidy "-checks=cert-*,bugprone-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,hicpp-*,modernize-*" --dump-config
5+
# clang-tidy looks for .clang-tidy file walking up the source directory structure to identify which checks to run
6+
# One can customize checks in specific source directories by placing custom .clang-tidy in those source directories
7+
Checks: '
8+
clang-diagnostic-*,
9+
clang-analyzer-*,
10+
cert-*,
11+
bugprone-*,
12+
clang-analyzer-*,
13+
concurrency-*,
14+
cppcoreguidelines-*,
15+
hicpp-*,
16+
-hicpp-no-array-decay,
17+
-hicpp-signed-bitwise,
18+
modernize-*,
19+
-modernize-use-trailing-return-type,
20+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
21+
-cppcoreguidelines-pro-type-union-access,
22+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
23+
-cppcoreguidelines-pro-type-reinterpret-cast,
24+
-cppcoreguidelines-pro-bounds-constant-array-index,
25+
'
26+
27+
WarningsAsErrors: ''
28+
HeaderFilterRegex: ''
29+
AnalyzeTemporaryDtors: false
30+
FormatStyle: none
31+
User: sonals
32+
CheckOptions:
33+
- key: bugprone-argument-comment.CommentBoolLiterals
34+
value: '0'
35+
- key: bugprone-argument-comment.CommentCharacterLiterals
36+
value: '0'
37+
- key: bugprone-argument-comment.CommentFloatLiterals
38+
value: '0'
39+
- key: bugprone-argument-comment.CommentIntegerLiterals
40+
value: '0'
41+
- key: bugprone-argument-comment.CommentNullPtrs
42+
value: '0'
43+
- key: bugprone-argument-comment.CommentStringLiterals
44+
value: '0'
45+
- key: bugprone-argument-comment.CommentUserDefinedLiterals
46+
value: '0'
47+
- key: bugprone-argument-comment.IgnoreSingleArgument
48+
value: '0'
49+
- key: bugprone-argument-comment.StrictMode
50+
value: '0'
51+
- key: bugprone-assert-side-effect.AssertMacros
52+
value: assert
53+
- key: bugprone-assert-side-effect.CheckFunctionCalls
54+
value: '0'
55+
- key: bugprone-dangling-handle.HandleClasses
56+
value: 'std::basic_string_view;std::experimental::basic_string_view'
57+
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
58+
value: ',h,hh,hpp,hxx'
59+
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
60+
value: ''
61+
- key: bugprone-exception-escape.IgnoredExceptions
62+
value: ''
63+
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
64+
value: '0'
65+
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
66+
value: '1'
67+
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
68+
value: ''
69+
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
70+
value: '1'
71+
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
72+
value: '1'
73+
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
74+
value: '0'
75+
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
76+
value: '1'
77+
- key: bugprone-string-constructor.LargeLengthThreshold
78+
value: '8388608'
79+
- key: bugprone-string-constructor.WarnOnLargeLength
80+
value: '1'
81+
- key: bugprone-suspicious-enum-usage.StrictMode
82+
value: '0'
83+
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
84+
value: '5'
85+
- key: bugprone-suspicious-missing-comma.RatioThreshold
86+
value: '0.200000'
87+
- key: bugprone-suspicious-missing-comma.SizeThreshold
88+
value: '5'
89+
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
90+
value: ''
91+
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
92+
value: '1'
93+
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
94+
value: '0'
95+
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
96+
value: '16'
97+
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
98+
value: '1'
99+
- key: bugprone-unused-return-value.CheckedFunctions
100+
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty'
101+
- key: cert-dcl16-c.IgnoreMacros
102+
value: '1'
103+
- key: cert-dcl16-c.NewSuffixes
104+
value: 'L;LL;LU;LLU'
105+
- key: cert-dcl59-cpp.HeaderFileExtensions
106+
value: ',h,hh,hpp,hxx'
107+
- key: cert-err09-cpp.CheckThrowTemporaries
108+
value: '1'
109+
- key: cert-err61-cpp.CheckThrowTemporaries
110+
value: '1'
111+
- key: cert-msc32-c.DisallowedSeedTypes
112+
value: 'time_t,std::time_t'
113+
- key: cert-msc51-cpp.DisallowedSeedTypes
114+
value: 'time_t,std::time_t'
115+
- key: cert-oop11-cpp.IncludeStyle
116+
value: llvm
117+
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
118+
value: '0'
119+
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
120+
value: '1.0;100.0;'
121+
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
122+
value: '1;2;3;4;'
123+
- key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
124+
value: '0'
125+
- key: cppcoreguidelines-explicit-virtual-functions.FinalSpelling
126+
value: final
127+
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
128+
value: '1'
129+
- key: cppcoreguidelines-explicit-virtual-functions.OverrideSpelling
130+
value: override
131+
- key: cppcoreguidelines-macro-usage.AllowedRegexp
132+
value: '^DEBUG_*'
133+
- key: cppcoreguidelines-macro-usage.CheckCapsOnly
134+
value: '0'
135+
- key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros
136+
value: '1'
137+
- key: cppcoreguidelines-no-malloc.Allocations
138+
value: '::malloc;::calloc'
139+
- key: cppcoreguidelines-no-malloc.Deallocations
140+
value: '::free'
141+
- key: cppcoreguidelines-no-malloc.Reallocations
142+
value: '::realloc'
143+
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
144+
value: '1'
145+
- key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
146+
value: '::free;::realloc;::freopen;::fclose'
147+
- key: cppcoreguidelines-owning-memory.LegacyResourceProducers
148+
value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
149+
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
150+
value: '0'
151+
- key: cppcoreguidelines-pro-type-member-init.UseAssignment
152+
value: '0'
153+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
154+
value: '0'
155+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
156+
value: '0'
157+
- key: google-readability-braces-around-statements.ShortStatementLines
158+
value: '1'
159+
- key: google-readability-function-size.StatementThreshold
160+
value: '800'
161+
- key: google-readability-namespace-comments.ShortNamespaceLines
162+
value: '10'
163+
- key: google-readability-namespace-comments.SpacesBeforeComments
164+
value: '2'
165+
- key: hicpp-braces-around-statements.ShortStatementLines
166+
value: '4'
167+
- key: hicpp-function-size.BranchThreshold
168+
value: '4294967295'
169+
- key: hicpp-function-size.LineThreshold
170+
value: '4294967295'
171+
- key: hicpp-function-size.NestingThreshold
172+
value: '4294967295'
173+
- key: hicpp-function-size.ParameterThreshold
174+
value: '4294967295'
175+
- key: hicpp-function-size.StatementThreshold
176+
value: '800'
177+
- key: hicpp-function-size.VariableThreshold
178+
value: '4294967295'
179+
- key: hicpp-member-init.IgnoreArrays
180+
value: '0'
181+
- key: hicpp-member-init.UseAssignment
182+
value: '0'
183+
- key: hicpp-move-const-arg.CheckTriviallyCopyableMove
184+
value: '1'
185+
- key: hicpp-multiway-paths-covered.WarnOnMissingElse
186+
value: '0'
187+
- key: hicpp-named-parameter.IgnoreFailedSplit
188+
value: '0'
189+
- key: hicpp-no-malloc.Allocations
190+
value: '::malloc;::calloc'
191+
- key: hicpp-no-malloc.Deallocations
192+
value: '::free'
193+
- key: hicpp-no-malloc.Reallocations
194+
value: '::realloc'
195+
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
196+
value: '1'
197+
- key: hicpp-special-member-functions.AllowMissingMoveFunctions
198+
value: '0'
199+
- key: hicpp-special-member-functions.AllowSoleDefaultDtor
200+
value: '0'
201+
- key: hicpp-uppercase-literal-suffix.IgnoreMacros
202+
value: '1'
203+
- key: hicpp-uppercase-literal-suffix.NewSuffixes
204+
value: ''
205+
- key: hicpp-use-auto.MinTypeNameLength
206+
value: '5'
207+
- key: hicpp-use-auto.RemoveStars
208+
value: '0'
209+
- key: hicpp-use-emplace.ContainersWithPushBack
210+
value: '::std::vector;::std::list;::std::deque'
211+
- key: hicpp-use-emplace.SmartPointers
212+
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
213+
- key: hicpp-use-emplace.TupleMakeFunctions
214+
value: '::std::make_pair;::std::make_tuple'
215+
- key: hicpp-use-emplace.TupleTypes
216+
value: '::std::pair;::std::tuple'
217+
- key: hicpp-use-equals-default.IgnoreMacros
218+
value: '1'
219+
- key: hicpp-use-equals-delete.IgnoreMacros
220+
value: '1'
221+
- key: hicpp-use-noexcept.ReplacementString
222+
value: ''
223+
- key: hicpp-use-noexcept.UseNoexceptFalse
224+
value: '1'
225+
- key: hicpp-use-nullptr.NullMacros
226+
value: ''
227+
- key: hicpp-use-override.AllowOverrideAndFinal
228+
value: '0'
229+
- key: hicpp-use-override.FinalSpelling
230+
value: final
231+
- key: hicpp-use-override.IgnoreDestructors
232+
value: '0'
233+
- key: hicpp-use-override.OverrideSpelling
234+
value: override
235+
- key: modernize-loop-convert.MaxCopySize
236+
value: '16'
237+
- key: modernize-loop-convert.MinConfidence
238+
value: reasonable
239+
- key: modernize-loop-convert.NamingStyle
240+
value: CamelCase
241+
- key: modernize-make-shared.IgnoreMacros
242+
value: '1'
243+
- key: modernize-make-shared.MakeSmartPtrFunction
244+
value: 'std::make_shared'
245+
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
246+
value: memory
247+
- key: modernize-make-unique.IgnoreMacros
248+
value: '1'
249+
- key: modernize-make-unique.MakeSmartPtrFunction
250+
value: 'std::make_unique'
251+
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
252+
value: memory
253+
- key: modernize-pass-by-value.IncludeStyle
254+
value: llvm
255+
- key: modernize-pass-by-value.ValuesOnly
256+
value: '0'
257+
- key: modernize-raw-string-literal.ReplaceShorterLiterals
258+
value: '0'
259+
- key: modernize-replace-auto-ptr.IncludeStyle
260+
value: llvm
261+
- key: modernize-replace-random-shuffle.IncludeStyle
262+
value: llvm
263+
- key: modernize-use-auto.MinTypeNameLength
264+
value: '5'
265+
- key: modernize-use-auto.RemoveStars
266+
value: '0'
267+
- key: modernize-use-default-member-init.IgnoreMacros
268+
value: '1'
269+
- key: modernize-use-default-member-init.UseAssignment
270+
value: '0'
271+
- key: modernize-use-emplace.ContainersWithPushBack
272+
value: '::std::vector;::std::list;::std::deque'
273+
- key: modernize-use-emplace.SmartPointers
274+
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
275+
- key: modernize-use-emplace.TupleMakeFunctions
276+
value: '::std::make_pair;::std::make_tuple'
277+
- key: modernize-use-emplace.TupleTypes
278+
value: '::std::pair;::std::tuple'
279+
- key: modernize-use-equals-default.IgnoreMacros
280+
value: '1'
281+
- key: modernize-use-equals-delete.IgnoreMacros
282+
value: '1'
283+
- key: modernize-use-nodiscard.ReplacementString
284+
value: '[[nodiscard]]'
285+
- key: modernize-use-noexcept.ReplacementString
286+
value: ''
287+
- key: modernize-use-noexcept.UseNoexceptFalse
288+
value: '1'
289+
- key: modernize-use-nullptr.NullMacros
290+
value: 'NULL'
291+
- key: modernize-use-override.AllowOverrideAndFinal
292+
value: '0'
293+
- key: modernize-use-override.FinalSpelling
294+
value: final
295+
- key: modernize-use-override.IgnoreDestructors
296+
value: '0'
297+
- key: modernize-use-override.OverrideSpelling
298+
value: override
299+
- key: modernize-use-transparent-functors.SafeMode
300+
value: '0'
301+
- key: modernize-use-using.IgnoreMacros
302+
value: '1'
303+
...

tests/hip/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@ set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/opt/rocm/lib/cmake/hip;/opt/rocm/li
2929
include(hip-config)
3030
message("-- Found at ${HIP_INCLUDE_DIR}")
3131

32+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
33+
find_program(CLANG_TIDY "clang-tidy")
34+
if(NOT CLANG_TIDY)
35+
message(WARNING "-- clang-tidy not found, cannot enable static analysis")
36+
else()
37+
message("-- Enabling clang-tidy")
38+
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
39+
endif()
40+
endif()
41+
3242
include_directories(${HIP_INCLUDE_DIRS})
3343

3444
add_subdirectory(device)
3545
add_subdirectory(vadd)
46+
add_subdirectory(vadd-stream)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
3+
#
4+
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
5+
PROJECT(device)
6+
set(TESTNAME "vadd-stream")
7+
8+
include(../../CMake/utils.cmake)
9+
10+
add_executable(${TESTNAME} main.cpp)
11+
target_link_libraries(${TESTNAME} PRIVATE ${xrt_hip_LIBRARY})
12+
13+
if (NOT WIN32)
14+
target_link_libraries(${TESTNAME} PRIVATE ${uuid_LIBRARY} pthread)
15+
endif(NOT WIN32)
16+
17+
install(TARGETS ${TESTNAME}
18+
RUNTIME DESTINATION ${INSTALL_DIR}/${TESTNAME})

0 commit comments

Comments
 (0)