-
Notifications
You must be signed in to change notification settings - Fork 91
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
Remove format_header.sh #1466
Remove format_header.sh #1466
Conversation
I like it, if it performs well, this should make IDE integration of our header ordering much smoother |
The non-whitespace diff can be obtained with:
The diff is also attached here. |
a2f77d4
to
b331a11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
b331a11
to
7af592f
Compare
7af592f
to
2a6d96f
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the regroup does not take care the header. for example cb_gmres example
The main goal of the PR is to remove
I don't follow, can you elaborate?
Do you mean the wrong comment on the main ginkgo header file? |
I think it does. Any |
2a6d96f
to
f8b038c
Compare
70bb6df
to
0d2e147
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
0d2e147
to
ba448c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
In general, all include statements should be present on the top of the file, | ||
ordered in the following groups, with two blank lines between each group: | ||
ordered in the following groups, with *one* blank lines between each group: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the following is slightly different from the clang_format group rule such as the ginkgo main header is in another group
#include <gtest/gtest.h> | ||
|
||
|
||
#include <ginkgo/core/base/array.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <ginkgo/core/base/array.hpp> | |
#include "ginkgo/core/base/array.hpp" |
such that it can be recognized as a main header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the main header. The conversation about main headers only makes sense for files which implement functions defined in a header file. This is not the case for the test files, so there is no main header here.
I think we had a different interpretation of main header previously, which was based on ~vibes~. Now we just follow clangs definition.
So all the comments on the test files are unnecessary. Sorry for not making that clearer before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this definition, the opposite part needs to change.
cuda/test/matrix/coo_kernels.cpp
uses core/matrix/coo_kernels.hpp
as the main header because they are in the mainHeaderSource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean cuda/matrix/coo_kernels.cpp
? Because there is no cuda/test/matrix/coo_kernels.cpp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I just randomly pick something might have issue.
something like this: cuda/test/solver/lower_trs_kernels.cu
uses core/solver/lower_trs_kernels.hpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. This poses an issue, because there doesn't seem to be a way to prevent clang from detecting core/solver/lower_trs_kernels.hpp
as main header. I think the simplest choice is to consider these headers as the main header again.
Side note: this particular header is unnecessary. The test doesn't call any kernel directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can just ignore it and live with these (small) inconsistencies. That means there will be some tests which have a main header and those that don't.
#include <ginkgo/core/base/exception.hpp> | ||
#include <ginkgo/core/base/exception_helpers.hpp> | ||
#include <ginkgo/core/base/executor.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <gtest/gtest.h> | ||
|
||
#include <ginkgo/core/base/exception_helpers.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <ginkgo/core/base/exception_helpers.hpp> | ||
#include <ginkgo/core/base/executor.hpp> | ||
#include <ginkgo/core/base/index_set.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <gtest/gtest.h> | ||
|
||
#include <ginkgo/core/stop/iteration.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <ginkgo/core/base/math.hpp> | ||
|
||
#include <ginkgo/core/stop/residual_norm.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <chrono> | ||
#include <thread> | ||
|
||
#include <ginkgo/core/stop/time.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <gtest/gtest.h> | ||
|
||
#include <ginkgo/core/base/timer.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
#include <ginkgo/core/base/exception.hpp> | ||
#include <ginkgo/core/base/executor.hpp> | ||
#include <ginkgo/core/matrix/coo.hpp> | ||
#include <ginkgo/core/matrix/csr.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
summary of my comments:
- oneapi except for dpl should be in the same group as cu/hip...
- sde_lib is also from papi. and maybe we can put the priority 4 and 5 together?
- some main headers are missed or wrong due to no
""
. - because dpl in priority -2, we do not need the clang-format on/off to force it. It may apply to runtime but I am not sure the priority 2 is enough for solving the compiling issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ignore main header inconsistentence for now.
the onedpl with disabling the clang-format is not changed and some wrong usage of header ""/<> is not resolved yet.
@@ -6,13 +6,11 @@ | |||
#define GKO_CORE_BASE_BATCH_MULTI_VECTOR_KERNELS_HPP_ | |||
|
|||
|
|||
#include <ginkgo/core/base/batch_multi_vector.hpp> | |||
|
|||
#include "ginkgo/core/base/batch_multi_vector.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the hpp is out of the maing header check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I will update this (and the others) accordingly
@@ -6,16 +6,13 @@ | |||
#define GKO_CORE_BASE_DEVICE_MATRIX_DATA_KERNELS_HPP_ | |||
|
|||
|
|||
#include <ginkgo/core/base/device_matrix_data.hpp> | |||
|
|||
#include "ginkgo/core/base/device_matrix_data.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question
core/base/utils.hpp
Outdated
#include <ginkgo/core/base/polymorphic_object.hpp> | ||
#include <ginkgo/core/base/types.hpp> | ||
#include <ginkgo/core/matrix/csr.hpp> | ||
|
||
#include "ginkgo/core/base/utils.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because no main header, use <> not ""
@@ -6,14 +6,12 @@ | |||
#define GKO_CORE_DISTRIBUTED_INDEX_MAP_KERNELS_HPP_ | |||
|
|||
|
|||
#include <ginkgo/core/distributed/index_map.hpp> | |||
|
|||
#include "ginkgo/core/distributed/index_map.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question for hpp
core/reorder/mc64.hpp
Outdated
#include "core/components/addressable_pq.hpp" | ||
#include "ginkgo/core/reorder/mc64.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use <>
TODO: remove or revert this commit
changes from: `./dev_tools/scripts/change-main-include.py $(git ls-files)` This is done based on the heuristic that the first include is the main include, except in some cases. Here are the cases where the heuristic can't determine either way: benchmark/utils/mpi_timer.cpp benchmark/utils/tuning_variables.cpp core/base/mpi.cpp core/base/segmented_array.cpp core/base/version.cpp core/config/multigrid_config.cpp core/distributed/index_map.cpp core/distributed/partition.cpp core/log/logger.cpp core/preconditioner/batch_jacobi.cpp core/stop/combined.cpp core/stop/criterion.cpp core/stop/iteration.cpp core/stop/time.cpp cuda/base/version.cpp devices/cuda/executor.cpp devices/hip/executor.cpp dpcpp/base/version.dp.cpp hip/base/version.hip.cpp omp/base/version.cpp reference/base/version.cpp
Co-authored-by: Yu-Hsiang M. Tsai <[email protected]>
This reverts commit a9880c2.
c545d97
to
e4d744e
Compare
I've rebased it after the changes from #1616. It went pretty smoothly. I don't think there are additional changes that were not reviewed before, so I will go a head and merge it when the tests pass. |
This PR removes the format_header.sh in favor of purely relying on clang-format. The .clang-format is updated to allow regrouping of includes. In total, out of the affected 1000 files, only ~200 have non-whitespace changes. Many of those are regarding the ginkgo main header, or previously missing
Include groups (ordered by their prority)
<oneapi/...
since we usedforce-top
with that a lot.<hip/hip_runtime.h>
same<...>
includes"..."
includesThis is mostly based on the already used regrouping in
format_header.sh
.Notable Changes
"..."
, instead of<...>
. This is required, since clang-format can't deduce the main header otherwise.force-top
is removed and instead handling by using negative priorities in .clang-format. In very few cases this is not sufficient, and thereclang-format on/off
achieves the same results.<ginkgo/ginkgo.hpp>
header is now ordered after standard library includescuda/matrix/batch_struct.hpp
will not havecore/matrix/batch_struct.hpp
as its main header anymore.Since the
format_header.sh
script is very complex, I think these changes are a small price to removing it.