Skip to content

Commit b5db647

Browse files
amdkilasaadrahim
authored andcommitted
Clang9 formatting (ROCm#177)
* Ran clang-format 9.0.0 on rocFFT repo. Changed shared library branch … (ROCm#174) * Ran clang-format 9.0.0 on rocFFT repo * Changed shared library branch in Jenkinsfile to 'clang9' * Added pre-commit hooks (ROCm#176) Changed clang-format version from 3.8 to 9.0 in install script
1 parent 57797eb commit b5db647

36 files changed

+257
-300
lines changed

.githooks/install

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
cd $(git rev-parse --git-dir)
4+
cd hooks
5+
6+
echo "Installing hooks..."
7+
ln -s ../../.githooks/pre-commit pre-commit
8+
echo "Done!"

.githooks/pre-commit

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
#
3+
# This pre-commit hook checks if any versions of clang-format
4+
# are installed, and if so, uses the installed version to format
5+
# the staged changes.
6+
7+
base=/opt/rocm/hcc/bin/clang-format
8+
format=""
9+
10+
# Redirect output to stderr.
11+
exec 1>&2
12+
13+
# check if clang-format is installed
14+
type "$base" >/dev/null 2>&1 && format="$base"
15+
16+
# no versions of clang-format are installed
17+
if [ -z "$format" ]
18+
then
19+
echo "$base is not installed. Pre-commit hook will not be executed."
20+
exit 0
21+
fi
22+
23+
# Do everything from top - level
24+
cd $(git rev-parse --show-toplevel)
25+
26+
if git rev-parse --verify HEAD >/dev/null 2>&1
27+
then
28+
against=HEAD
29+
else
30+
# Initial commit: diff against an empty tree object
31+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
32+
fi
33+
34+
# do the formatting
35+
for file in $(git diff-index --cached --name-only $against | grep -E '\.h$|\.hpp$|\.cpp$|\.cl$|\.h\.in$|\.hpp\.in$|\.cpp\.in$')
36+
do
37+
if [ -e "$file" ]
38+
then
39+
echo "$format $file"
40+
"$format" -i -style=file "$file"
41+
fi
42+
done
43+

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env groovy
22
// This shared library is available at https://github.com/ROCmSoftwarePlatform/rocJENKINS/
3-
@Library('rocJenkins') _
3+
@Library('rocJenkins@clang9') _
44

55
// This is file for internal AMD use.
66
// If you are interested in running your own Jenkins, please raise a github issue for assistance.

clients/rider/rider.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace po = boost::program_options;
2222
// and we store into an enum varaible
2323
template <class _Elem, class _Traits>
2424
std::basic_istream<_Elem, _Traits>& operator>>(std::basic_istream<_Elem, _Traits>& stream,
25-
rocfft_array_type& atype)
25+
rocfft_array_type& atype)
2626
{
2727
unsigned tmp;
2828
stream >> tmp;
@@ -33,7 +33,7 @@ std::basic_istream<_Elem, _Traits>& operator>>(std::basic_istream<_Elem, _Traits
3333
// similarly for transform type
3434
template <class _Elem, class _Traits>
3535
std::basic_istream<_Elem, _Traits>& operator>>(std::basic_istream<_Elem, _Traits>& stream,
36-
rocfft_transform_type& ttype)
36+
rocfft_transform_type& ttype)
3737
{
3838
unsigned tmp;
3939
stream >> tmp;
@@ -395,9 +395,7 @@ int transform(size_t* lengths,
395395
rocfft_execution_info info = NULL;
396396

397397
if((place == rocfft_placement_inplace) && packed && (scale == 1.0) && (inOffset[0] == 0)
398-
&& (inOffset[1] == 0)
399-
&& (outOffset[0] == 0)
400-
&& (outOffset[1] == 0))
398+
&& (inOffset[1] == 0) && (outOffset[0] == 0) && (outOffset[1] == 0))
401399
{
402400
LIB_V_THROW(rocfft_plan_create(
403401
&plan, place, transformType, precision, dim, lengths, batchSize, NULL),
@@ -994,7 +992,11 @@ int main(int argc, char* argv[])
994992

995993
// input output array type support matrix
996994
int ioArrTypeSupport[5][5] = {
997-
{1, 1, 0, 0, 0}, {1, 1, 0, 0, 0}, {0, 0, 0, 1, 1}, {0, 0, 1, 0, 0}, {0, 0, 1, 0, 0},
995+
{1, 1, 0, 0, 0},
996+
{1, 1, 0, 0, 0},
997+
{0, 0, 0, 1, 1},
998+
{0, 0, 1, 0, 0},
999+
{0, 0, 1, 0, 0},
9981000
};
9991001

10001002
if(inL > 4)
@@ -1007,10 +1009,7 @@ int main(int argc, char* argv[])
10071009

10081010
bool packed = false;
10091011
if((iStrides[0] == 1) && (iStrides[1] == 0) && (iStrides[2] == 0) && (iStrides[3] == 0)
1010-
&& (oStrides[0] == 1)
1011-
&& (oStrides[1] == 0)
1012-
&& (oStrides[2] == 0)
1013-
&& (oStrides[3] == 0))
1012+
&& (oStrides[0] == 1) && (oStrides[1] == 0) && (oStrides[2] == 0) && (oStrides[3] == 0))
10141013
packed = true;
10151014

10161015
if((transformType == rocfft_transform_type_complex_forward)

clients/rider/rider.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ struct Timer
7777
struct timespec start, end;
7878

7979
public:
80-
Timer()
81-
{
82-
}
80+
Timer() {}
8381

8482
void Start()
8583
{

clients/selftest/test_complex.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ template <typename T, typename CT>
479479
class BasicInterfaceBasisTest : public ::testing::Test
480480
{
481481
protected:
482-
virtual void TearDown()
483-
{
484-
}
482+
virtual void TearDown() {}
485483
virtual void SetUp()
486484
{
487485
in = NULL;

clients/tests/accuracy_test_1D.cpp

+20-54
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,31 @@
1414
#include "rocfft_against_fftw.h"
1515
#include "test_constants.h"
1616

17+
using ::testing::Combine;
1718
using ::testing::TestWithParam;
1819
using ::testing::Values;
1920
using ::testing::ValuesIn;
20-
using ::testing::Combine;
2121

2222
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
2323
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
2424
class accuracy_test_complex_pow2_single : public ::testing::Test
2525
{
2626
protected:
27-
accuracy_test_complex_pow2_single()
28-
{
29-
}
30-
virtual ~accuracy_test_complex_pow2_single()
31-
{
32-
}
33-
virtual void SetUp()
34-
{
35-
}
36-
virtual void TearDown()
37-
{
38-
}
27+
accuracy_test_complex_pow2_single() {}
28+
virtual ~accuracy_test_complex_pow2_single() {}
29+
virtual void SetUp() {}
30+
virtual void TearDown() {}
3931
};
4032

4133
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
4234
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
4335
class accuracy_test_complex_pow2_double : public ::testing::Test
4436
{
4537
protected:
46-
accuracy_test_complex_pow2_double()
47-
{
48-
}
49-
virtual ~accuracy_test_complex_pow2_double()
50-
{
51-
}
52-
virtual void SetUp()
53-
{
54-
}
55-
virtual void TearDown()
56-
{
57-
}
38+
accuracy_test_complex_pow2_double() {}
39+
virtual ~accuracy_test_complex_pow2_double() {}
40+
virtual void SetUp() {}
41+
virtual void TearDown() {}
5842
};
5943
// 65536=pow(2,16) //8388608 = pow(2,23)
6044
#define POW2_RANGE \
@@ -113,42 +97,24 @@ static std::vector<size_t> generate_random(size_t number_run)
11397
return output;
11498
}
11599

116-
class accuracy_test_complex : public ::TestWithParam<std::tuple<size_t,
117-
size_t,
118-
rocfft_result_placement,
119-
rocfft_transform_type,
120-
size_t>>
100+
class accuracy_test_complex
101+
: public ::TestWithParam<
102+
std::tuple<size_t, size_t, rocfft_result_placement, rocfft_transform_type, size_t>>
121103
{
122104
protected:
123-
accuracy_test_complex()
124-
{
125-
}
126-
virtual ~accuracy_test_complex()
127-
{
128-
}
129-
virtual void SetUp()
130-
{
131-
}
132-
virtual void TearDown()
133-
{
134-
}
105+
accuracy_test_complex() {}
106+
virtual ~accuracy_test_complex() {}
107+
virtual void SetUp() {}
108+
virtual void TearDown() {}
135109
};
136110

137111
class accuracy_test_real : public ::TestWithParam<std::tuple<size_t, size_t>>
138112
{
139113
protected:
140-
accuracy_test_real()
141-
{
142-
}
143-
virtual ~accuracy_test_real()
144-
{
145-
}
146-
virtual void SetUp()
147-
{
148-
}
149-
virtual void TearDown()
150-
{
151-
}
114+
accuracy_test_real() {}
115+
virtual ~accuracy_test_real() {}
116+
virtual void SetUp() {}
117+
virtual void TearDown() {}
152118
};
153119

154120
template <class T, class fftw_T>

clients/tests/accuracy_test_2D.cpp

+17-49
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,31 @@
1414
#include "rocfft_against_fftw.h"
1515
#include "test_constants.h"
1616

17+
using ::testing::Combine;
1718
using ::testing::TestWithParam;
1819
using ::testing::Values;
1920
using ::testing::ValuesIn;
20-
using ::testing::Combine;
2121

2222
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
2323
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
2424
class accuracy_test_complex_2D_pow2_single : public ::testing::Test
2525
{
2626
protected:
27-
accuracy_test_complex_2D_pow2_single()
28-
{
29-
}
30-
virtual ~accuracy_test_complex_2D_pow2_single()
31-
{
32-
}
33-
virtual void SetUp()
34-
{
35-
}
36-
virtual void TearDown()
37-
{
38-
}
27+
accuracy_test_complex_2D_pow2_single() {}
28+
virtual ~accuracy_test_complex_2D_pow2_single() {}
29+
virtual void SetUp() {}
30+
virtual void TearDown() {}
3931
};
4032

4133
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
4234
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
4335
class accuracy_test_complex_2D_pow2_double : public ::testing::Test
4436
{
4537
protected:
46-
accuracy_test_complex_2D_pow2_double()
47-
{
48-
}
49-
virtual ~accuracy_test_complex_2D_pow2_double()
50-
{
51-
}
52-
virtual void SetUp()
53-
{
54-
}
55-
virtual void TearDown()
56-
{
57-
}
38+
accuracy_test_complex_2D_pow2_double() {}
39+
virtual ~accuracy_test_complex_2D_pow2_double() {}
40+
virtual void SetUp() {}
41+
virtual void TearDown() {}
5842
};
5943
// 65536=pow(2,16) //8388608 = pow(2,23)
6044
#define POW2_RANGE \
@@ -132,36 +116,20 @@ class accuracy_test_complex_2D : public ::TestWithParam<std::tuple<std::vector<s
132116
data_pattern>>
133117
{
134118
protected:
135-
accuracy_test_complex_2D()
136-
{
137-
}
138-
virtual ~accuracy_test_complex_2D()
139-
{
140-
}
141-
virtual void SetUp()
142-
{
143-
}
144-
virtual void TearDown()
145-
{
146-
}
119+
accuracy_test_complex_2D() {}
120+
virtual ~accuracy_test_complex_2D() {}
121+
virtual void SetUp() {}
122+
virtual void TearDown() {}
147123
};
148124

149125
class accuracy_test_real_2D
150126
: public ::TestWithParam<std::tuple<std::vector<size_t>, size_t, data_pattern>>
151127
{
152128
protected:
153-
accuracy_test_real_2D()
154-
{
155-
}
156-
virtual ~accuracy_test_real_2D()
157-
{
158-
}
159-
virtual void SetUp()
160-
{
161-
}
162-
virtual void TearDown()
163-
{
164-
}
129+
accuracy_test_real_2D() {}
130+
virtual ~accuracy_test_real_2D() {}
131+
virtual void SetUp() {}
132+
virtual void TearDown() {}
165133
};
166134

167135
template <class T, class fftw_T>

0 commit comments

Comments
 (0)