Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMP: Format code to address clang_format warnings #45

Merged
merged 2 commits into from Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/clang-format-linter.yml
Expand Up @@ -7,6 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- uses: actions/checkout@v2
- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@master
with:
error-message: 'Code is inconsistent with ITK Coding Style. Add the *action:ApplyClangFormat* PR label to correct.'
53 changes: 27 additions & 26 deletions include/itkVkCommon.h
Expand Up @@ -64,26 +64,28 @@ class VkFFTBackend_EXPORT VkCommon

struct VkParameters
{
uint64_t X = 0; // size of fastest varying dimension
uint64_t Y = 1; // size of second-fastest varying dimension, if any, otherwise 1.
uint64_t Z = 1; // size of third-fastest varying dimension, if any, otherwise 1.
uint64_t X{ 0 }; // size of fastest varying dimension
uint64_t Y{ 1 }; // size of second-fastest varying dimension, if any, otherwise 1.
uint64_t Z{ 1 }; // size of third-fastest varying dimension, if any, otherwise 1.
uint64_t omitDimension[3] = { 0,
0,
0 }; // disable FFT for this dimension (0 - FFT enabled, 1 - FFT disabled). Default 0.
// Doesn't work for R2C dimension 0 for now. Doesn't work with convolutions.
PrecisionEnum P = PrecisionEnum::FLOAT; // type for real numbers
uint64_t B = 1; // Number of batches -- always 1
uint64_t N = 1; // Number of redundant iterations, for benchmarking -- always 1.
FFTEnum fft = FFTEnum::C2C; // ComplexToComplex, RealToHalfHermetian, RealToFullHermetian
uint64_t PSize = 4; // sizeof(float), sizeof(double), or sizeof(half) according to VkParameters.P.
DirectionEnum I =
DirectionEnum::FORWARD; // forward or inverse transformation. (R2HalfH inverse is aka HalfH2R, etc.)
NormalizationEnum normalized =
NormalizationEnum::UNNORMALIZED; // Whether inverse transformation should be divided by array size
const void * inputCPUBuffer = 0; // input buffer in CPU memory
uint64_t inputBufferBytes = 0; // number of bytes in inputCPUBuffer
void * outputCPUBuffer = 0; // output buffer in CPU memory
uint64_t outputBufferBytes = 0; // number of bytes in outputCPUBuffer
uint64_t B{ 1 }; // Number of batches -- always 1
uint64_t N{ 1 }; // Number of redundant iterations, for benchmarking -- always 1.
FFTEnum fft{ FFTEnum::C2C }; // ComplexToComplex, RealToHalfHermetian, RealToFullHermetian
uint64_t PSize{ 4 }; // sizeof(float), sizeof(double), or sizeof(half) according to VkParameters.P.
DirectionEnum I{
DirectionEnum::FORWARD
}; // forward or inverse transformation. (R2HalfH inverse is aka HalfH2R, etc.)
NormalizationEnum normalized{
NormalizationEnum::UNNORMALIZED
}; // Whether inverse transformation should be divided by array size
const void * inputCPUBuffer{ nullptr }; // input buffer in CPU memory
uint64_t inputBufferBytes{ 0 }; // number of bytes in inputCPUBuffer
void * outputCPUBuffer{ nullptr }; // output buffer in CPU memory
uint64_t outputBufferBytes{ 0 }; // number of bytes in outputCPUBuffer

bool
operator!=(const VkParameters & rhs) const
Expand All @@ -99,23 +101,22 @@ class VkFFTBackend_EXPORT VkCommon
struct VkGPU
{
#if (VKFFT_BACKEND == CUDA)
CUdevice device = 0;
CUcontext context = 0;
CUdevice device{ 0 };
CUcontext context{ 0 };
#elif (VKFFT_BACKEND == OPENCL)
cl_platform_id platform = 0;
cl_device_id device = 0;
cl_context context = 0;
cl_command_queue commandQueue = 0;
cl_platform_id platform{ 0 };
cl_device_id device{ 0 };
cl_context context{ 0 };
cl_command_queue commandQueue{ 0 };
#endif
uint64_t device_id = 0; // default value
uint64_t device_id{ 0 }; // default value

bool
operator!=(const VkGPU & rhs) const
{
# if (VKFFT_BACKEND == CUDA)
return this->device != rhs.device || this->context != rhs.context ||
this->device_id != rhs.device_id;
# elif (VKFFT_BACKEND == OPENCL)
#if (VKFFT_BACKEND == CUDA)
return this->device != rhs.device || this->context != rhs.context || this->device_id != rhs.device_id;
#elif (VKFFT_BACKEND == OPENCL)
return this->platform != rhs.platform || this->device != rhs.device || this->context != rhs.context ||
this->commandQueue != rhs.commandQueue || this->device_id != rhs.device_id;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/itkVkComplexToComplex1DFFTImageFilter.hxx
Expand Up @@ -86,7 +86,7 @@ VkComplexToComplex1DFFTImageFilter<TInputImage, TOutputImage>::GenerateData()
vkParameters.normalized = vkParameters.I == VkCommon::DirectionEnum::INVERSE
? VkCommon::NormalizationEnum::NORMALIZED
: VkCommon::NormalizationEnum::UNNORMALIZED;
for (size_t dim = 0; dim < ImageDimension; ++dim)
for (size_t dim{ 0 }; dim < ImageDimension; ++dim)
{
if (this->GetDirection() != dim)
{
Expand Down
2 changes: 1 addition & 1 deletion include/itkVkForward1DFFTImageFilter.hxx
Expand Up @@ -81,7 +81,7 @@ VkForward1DFFTImageFilter<TInputImage, TOutputImage>::GenerateData()
vkParameters.PSize = sizeof(RealType);
vkParameters.I = VkCommon::DirectionEnum::FORWARD;
vkParameters.normalized = VkCommon::NormalizationEnum::UNNORMALIZED;
for (size_t dim = 0; dim < ImageDimension; ++dim)
for (size_t dim{ 0 }; dim < ImageDimension; ++dim)
{
if (this->GetDirection() != dim)
{
Expand Down
2 changes: 1 addition & 1 deletion include/itkVkInverse1DFFTImageFilter.hxx
Expand Up @@ -81,7 +81,7 @@ VkInverse1DFFTImageFilter<TInputImage, TOutputImage>::GenerateData()
vkParameters.PSize = sizeof(RealType);
vkParameters.I = VkCommon::DirectionEnum::INVERSE;
vkParameters.normalized = VkCommon::NormalizationEnum::NORMALIZED;
for (size_t dim = 0; dim < ImageDimension; ++dim)
for (size_t dim{ 0 }; dim < ImageDimension; ++dim)
{
if (this->GetDirection() != dim)
{
Expand Down
14 changes: 7 additions & 7 deletions src/itkVkCommon.cxx
Expand Up @@ -99,7 +99,7 @@ VkCommon::ConfigureBackend()
return VkFFTResult{ VKFFT_ERROR_FAILED_TO_INITIALIZE };
}
uint64_t k{ 0 };
for (uint64_t j = 0; j < numPlatforms; j++)
for (uint64_t j{ 0 }; j < numPlatforms; j++)
{
cl_uint numDevices;
resCL = clGetDeviceIDs(platforms[j], CL_DEVICE_TYPE_ALL, 0, nullptr, &numDevices);
Expand All @@ -113,7 +113,7 @@ VkCommon::ConfigureBackend()
std::cerr << __FILE__ "(" << __LINE__ << "): clGetDeviceIDs returned " << resCL << std::endl;
return VkFFTResult{ VKFFT_ERROR_FAILED_TO_GET_DEVICE };
}
for (uint64_t i = 0; i < numDevices; i++)
for (uint64_t i{ 0 }; i < numDevices; i++)
{
if (k == m_VkGPU.device_id)
{
Expand Down Expand Up @@ -163,7 +163,7 @@ VkCommon::ConfigureBackend()
{
m_VkFFTConfiguration.doublePrecision = 1;
}
for (size_t dim = 0; dim < 3; ++dim)
for (size_t dim{ 0 }; dim < 3; ++dim)
{
m_VkFFTConfiguration.omitDimension[dim] = m_VkParameters.omitDimension[dim];
}
Expand Down Expand Up @@ -496,9 +496,9 @@ VkCommon::PerformFFT()
{
using ComplexType = std::complex<float>;
ComplexType * const outputCPUFloat{ reinterpret_cast<ComplexType *>(m_VkParameters.outputCPUBuffer) };
for (uint64_t z = 0; z < m_VkFFTConfiguration.size[2]; ++z)
for (uint64_t z{ 0 }; z < m_VkFFTConfiguration.size[2]; ++z)
{
for (uint64_t y = 0; y < m_VkFFTConfiguration.size[1]; ++y)
for (uint64_t y{ 0 }; y < m_VkFFTConfiguration.size[1]; ++y)
{
const uint64_t offsetStart{ z * m_VkFFTConfiguration.bufferStride[1] +
y * m_VkFFTConfiguration.bufferStride[0] };
Expand All @@ -515,9 +515,9 @@ VkCommon::PerformFFT()
{
using ComplexType = std::complex<double>;
ComplexType * const outputCPUDouble{ reinterpret_cast<ComplexType *>(m_VkParameters.outputCPUBuffer) };
for (uint64_t z = 0; z < m_VkFFTConfiguration.size[2]; ++z)
for (uint64_t z{ 0 }; z < m_VkFFTConfiguration.size[2]; ++z)
{
for (uint64_t y = 0; y < m_VkFFTConfiguration.size[1]; ++y)
for (uint64_t y{ 0 }; y < m_VkFFTConfiguration.size[1]; ++y)
{
const uint64_t offsetStart{ z * m_VkFFTConfiguration.bufferStride[1] +
y * m_VkFFTConfiguration.bufferStride[0] };
Expand Down
5 changes: 3 additions & 2 deletions src/itkVkFFTImageFilterInitFactory.cxx
Expand Up @@ -36,7 +36,8 @@ VkFFTImageFilterInitFactory::VkFFTImageFilterInitFactory()
VkFFTImageFilterInitFactory::RegisterFactories();
}

void VkFFTImageFilterInitFactory::RegisterFactories()
void
VkFFTImageFilterInitFactory::RegisterFactories()
{
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkComplexToComplex1DFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
Expand All @@ -59,7 +60,7 @@ void VkFFTImageFilterInitFactory::RegisterFactories()
// Undocumented API used to register during static initialization.
// DO NOT CALL DIRECTLY.
void VkFFTBackend_EXPORT
VkFFTImageFilterInitFactoryRegister__Private()
VkFFTImageFilterInitFactoryRegister__Private()
{
VkFFTImageFilterInitFactory::RegisterFactories();
}
Expand Down
2 changes: 1 addition & 1 deletion test/itkVkComplexToComplex1DFFTImageFilterBaselineTest.cxx
Expand Up @@ -77,7 +77,7 @@ itkVkComplexToComplex1DFFTImageFilterBaselineTest(int argc, char * argv[])
}

using PixelType = double;
const unsigned int Dimension = 2;
const unsigned int Dimension{ 2 };
using ComplexImageType = itk::Image<std::complex<PixelType>, Dimension>;
using FFTInverseType = itk::VkComplexToComplex1DFFTImageFilter<ComplexImageType>;

Expand Down
8 changes: 4 additions & 4 deletions test/itkVkComplexToComplex1DFFTImageFilterSizesTest.cxx
Expand Up @@ -91,7 +91,7 @@ itkVkComplexToComplex1DFFTImageFilterSizesTest(int argc, char * argv[])

typename ShowProgress::Pointer showProgress{ ShowProgress::New() };

for (int i = 0; i < 2; ++i)
for (int i{ 0 }; i < 2; ++i)
{
image->FillBuffer(1.2f);
image->FillBuffer(1.1f);
Expand All @@ -117,7 +117,7 @@ itkVkComplexToComplex1DFFTImageFilterSizesTest(int argc, char * argv[])
using ComplexImageType = itk::Image<ComplexType, Dimension>;
typename ComplexImageType::SizeType size;
// Skip trivial case where 1D image of size 1 fails.
for (unsigned int mySize = 2; mySize <= 20; ++mySize)
for (unsigned int mySize{ 2 }; mySize <= 20; ++mySize)
{
// We expect that anything evenly divisible by a prime number greater than 13
// will succeed with Bluestein's Algorithm implementation in VkFFT, though
Expand Down Expand Up @@ -150,7 +150,7 @@ itkVkComplexToComplex1DFFTImageFilterSizesTest(int argc, char * argv[])
{
thisTestPassed = false;
}
for (unsigned int i = 0; i < mySize; ++i)
for (unsigned int i{ 0 }; i < mySize; ++i)
{
index[0] = i;

Expand Down Expand Up @@ -180,7 +180,7 @@ itkVkComplexToComplex1DFFTImageFilterSizesTest(int argc, char * argv[])
std::cout << "|difference| = " << std::abs(output2->GetPixel(index) - someValue) << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 1; i < mySize; ++i)
for (unsigned int i{ 1 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output2->GetPixel(index) - zeroValue) > valueTolerance)
Expand Down
8 changes: 4 additions & 4 deletions test/itkVkComplexToComplexFFTImageFilterTest.cxx
Expand Up @@ -88,7 +88,7 @@ itkVkComplexToComplexFFTImageFilterTest(int argc, char * argv[])

typename ShowProgress::Pointer showProgress{ ShowProgress::New() };

for (int i = 0; i < 2; ++i)
for (int i{ 0 }; i < 2; ++i)
{
image->FillBuffer(1.2f);
image->FillBuffer(1.1f);
Expand All @@ -114,7 +114,7 @@ itkVkComplexToComplexFFTImageFilterTest(int argc, char * argv[])
using ComplexImageType = itk::Image<ComplexType, Dimension>;
typename ComplexImageType::SizeType size;
// Skip trivial case where 1D image of size 1 fails.
for (unsigned int mySize = 2; mySize <= 20; ++mySize)
for (unsigned int mySize{ 2 }; mySize <= 20; ++mySize)
{
// We expect that anything evenly divisible by a prime number greater than 13
// will succeed with Bluestein's Algorithm implementation in VkFFT, though
Expand Down Expand Up @@ -147,7 +147,7 @@ itkVkComplexToComplexFFTImageFilterTest(int argc, char * argv[])
{
thisTestPassed = false;
}
for (unsigned int i = 0; i < mySize; ++i)
for (unsigned int i{ 0 }; i < mySize; ++i)
{
index[0] = i;

Expand Down Expand Up @@ -177,7 +177,7 @@ itkVkComplexToComplexFFTImageFilterTest(int argc, char * argv[])
std::cout << "|difference| = " << std::abs(output2->GetPixel(index) - someValue) << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 1; i < mySize; ++i)
for (unsigned int i{ 1 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output2->GetPixel(index) - zeroValue) > valueTolerance)
Expand Down
2 changes: 1 addition & 1 deletion test/itkVkFFTImageFilterFactoryTest.cxx
Expand Up @@ -34,7 +34,7 @@ int
itkVkFFTImageFilterFactoryTest(int, char *[])
{
using PixelType = double;
const unsigned int Dimension = 2;
const unsigned int Dimension{ 2 };
using ComplexImageType = itk::Image<std::complex<PixelType>, Dimension>;
using FFTBaseType = itk::ComplexToComplex1DFFTImageFilter<ComplexImageType>;
using FFTDefaultSubclassType = itk::VnlComplexToComplex1DFFTImageFilter<ComplexImageType>;
Expand Down
2 changes: 1 addition & 1 deletion test/itkVkForward1DFFTImageFilterBaselineTest.cxx
Expand Up @@ -76,7 +76,7 @@ itkVkForward1DFFTImageFilterBaselineTest(int argc, char * argv[])
}

using PixelType = double;
const unsigned int Dimension = 2;
const unsigned int Dimension{ 2 };

using ImageType = itk::Image<PixelType, Dimension>;
using FFTForwardType = itk::VkForward1DFFTImageFilter<ImageType>;
Expand Down
6 changes: 3 additions & 3 deletions test/itkVkForwardInverse1DFFTImageFilterTest.cxx
Expand Up @@ -77,7 +77,7 @@ itkVkForwardInverse1DFFTImageFilterTest(int argc, char * argv[])
bool firstPass{ true };

// Skip trivial case where 1D image of size 1 fails.
for (unsigned int mySize = 2; mySize <= 20; ++mySize)
for (unsigned int mySize{ 2 }; mySize <= 20; ++mySize)
{
// We expect that anything evenly divisible by a prime number greater than 13
// will succeed with Bluestein's Algorithm implementation in VkFFT, though
Expand Down Expand Up @@ -130,7 +130,7 @@ itkVkForwardInverse1DFFTImageFilterTest(int argc, char * argv[])
std::cout << "Size is " << outputSize[0] << " but should be " << mySize << "." << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 0; i < mySize; ++i)
for (unsigned int i{ 0 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output->GetPixel(index) - complexSomeValue) > valueTolerance)
Expand Down Expand Up @@ -161,7 +161,7 @@ itkVkForwardInverse1DFFTImageFilterTest(int argc, char * argv[])
<< ": |difference| = " << std::abs(output2->GetPixel(index) - realSomeValue) << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 1; i < mySize; ++i)
for (unsigned int i{ 1 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output2->GetPixel(index) - realZeroValue) > valueTolerance)
Expand Down
6 changes: 3 additions & 3 deletions test/itkVkForwardInverseFFTImageFilterTest.cxx
Expand Up @@ -77,7 +77,7 @@ itkVkForwardInverseFFTImageFilterTest(int argc, char * argv[])
bool firstPass{ true };

// Skip trivial case where 1D image of size 1 fails.
for (unsigned int mySize = 2; mySize <= 20; ++mySize, firstPass = false)
for (unsigned int mySize{ 2 }; mySize <= 20; ++mySize, firstPass = false)
{
// We expect that anything evenly divisible by a prime number greater than 13
// will succeed with Bluestein's Algorithm implementation in VkFFT, though
Expand Down Expand Up @@ -131,7 +131,7 @@ itkVkForwardInverseFFTImageFilterTest(int argc, char * argv[])
std::cout << "Size is " << outputSize[0] << " but should be " << mySize << "." << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 0; i < mySize; ++i)
for (unsigned int i{ 0 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output->GetPixel(index) - complexSomeValue) > valueTolerance)
Expand Down Expand Up @@ -162,7 +162,7 @@ itkVkForwardInverseFFTImageFilterTest(int argc, char * argv[])
<< ": |difference| = " << std::abs(output2->GetPixel(index) - realSomeValue) << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 1; i < mySize; ++i)
for (unsigned int i{ 1 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output2->GetPixel(index) - realZeroValue) > valueTolerance)
Expand Down
6 changes: 3 additions & 3 deletions test/itkVkHalfHermitianFFTImageFilterTest.cxx
Expand Up @@ -76,7 +76,7 @@ itkVkHalfHermitianFFTImageFilterTest(int argc, char * argv[])
typename RealImageType::IndexType index;
bool firstPass{ true };
// Skip trivial case where 1D image of size 1 fails.
for (unsigned int mySize = 2; mySize <= 20; ++mySize, firstPass = false)
for (unsigned int mySize{ 2 }; mySize <= 20; ++mySize, firstPass = false)
{
// We expect that anything evenly divisible by a prime number greater than 13
// will succeed with Bluestein's Algorithm implementation in VkFFT, though
Expand Down Expand Up @@ -134,7 +134,7 @@ itkVkHalfHermitianFFTImageFilterTest(int argc, char * argv[])
std::cout << "Size is " << outputSize[0] << " but should be " << desiredOutputSize << "." << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 0; i < desiredOutputSize; ++i)
for (unsigned int i{ 0 }; i < desiredOutputSize; ++i)
{
index[0] = i;
if (std::abs(output->GetPixel(index) - complexSomeValue) > valueTolerance)
Expand Down Expand Up @@ -166,7 +166,7 @@ itkVkHalfHermitianFFTImageFilterTest(int argc, char * argv[])
<< ": |difference| = " << std::abs(output2->GetPixel(index) - realSomeValue) << std::endl;
thisTestPassed = false;
}
for (unsigned int i = 1; i < mySize; ++i)
for (unsigned int i{ 1 }; i < mySize; ++i)
{
index[0] = i;
if (std::abs(output2->GetPixel(index) - realZeroValue) > valueTolerance)
Expand Down
2 changes: 1 addition & 1 deletion test/itkVkInverse1DFFTImageFilterBaselineTest.cxx
Expand Up @@ -69,7 +69,7 @@ itkVkInverse1DFFTImageFilterBaselineTest(int argc, char * argv[])
}

using PixelType = double;
const unsigned int Dimension = 2;
const unsigned int Dimension{ 2 };

using ComplexImageType = itk::Image<std::complex<PixelType>, Dimension>;
using FFTInverseType = itk::VkInverse1DFFTImageFilter<ComplexImageType>;
Expand Down