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

Updating LLVM to version 18.1 for CMSSW_14_2_X #45870

Closed
smuzaffar opened this issue Sep 4, 2024 · 14 comments
Closed

Updating LLVM to version 18.1 for CMSSW_14_2_X #45870

smuzaffar opened this issue Sep 4, 2024 · 14 comments

Comments

@smuzaffar
Copy link
Contributor

@cms-sw/all-l2 , we are going to update llvm to version 18.1.6 for CMSSW_14_2_X. The new clang-format in LLVM 18.1 proposes couple of new changes which were not handled properly by llvm 17.

  1. extra space for inline function: (){} -> () {}: clang-format in llvm 17 was only adding the space it there is no ; after the function definition e.g. for https://github.com/cms-sw/cmssw/blob/master/DataFormats/Math/interface/Graph.h#L121-L122
    Graph() : edges_(1) {}
    ~Graph() {}

llvm 17 was adding the extra space but not for https://github.com/cms-sw/cmssw/blob/master/Alignment/CocoaDDLObjects/interface/CocoaMaterialElementary.h#L20

~CocoaMaterialElementary(){};

llvm 18 has fixed this and now clang-format properly handle this case.

  1. Comments alignment: new clang-format also suggest changes like
--- a/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorMuonSystemMap1D.cc
+++ b/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorMuonSystemMap1D.cc
@@ -276,7 +276,7 @@ void AlignmentMonitorMuonSystemMap1D::book() {
           }
         }
       }  // endcaps
-  }      // stations
+  }  // stations
 
   m_counter_event = 0;
   m_counter_track = 0;
@@ -322,7 +322,7 @@ void AlignmentMonitorMuonSystemMap1D::event(const edm::Event &iEvent,
           processMuonResidualsFromTrack(muonResidualsFromTrack, iEvent);
         }
       }  // end if track has acceptable momentum
-    }    // end loop over tracks
+    }  // end loop over tracks
   } else {
     const edm::Handle<reco::MuonCollection> &muons = iEvent.getHandle(muonToken_);

List of all clang-format changes (2148 files in total) are available here. Once llvm 18 is part of 14.2.X IBs then @cms-sw/core-l2 team will open code format updates PRs for files which are not already touched by any existing PR. Note that these changes llvm18 based code-format changes should be done once llvm 18 is in IBs otherwise PR code-checks using llvm17 will suggest to revert these changes.

Let us know if you have any concerns

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2024

A new Issue was created by @smuzaffar.

@Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@fwyzard
Copy link
Contributor

fwyzard commented Sep 4, 2024

~CocoaMaterialElementary(){};

Shouldn't the trailing ; be removed ?

@fwyzard
Copy link
Contributor

fwyzard commented Sep 4, 2024

There are some other kind of changes:

diff --git a/HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h b/HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h
index 36aa8ec079b..64b518e02c2 100644
--- a/HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h
+++ b/HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h
@@ -26,8 +26,9 @@ namespace cms::alpakatools {
     template <typename TElem, typename TDim, typename TIdx, typename TQueue>
     struct CachedBufAlloc<TElem, TDim, TIdx, alpaka::DevCpu, TQueue, void> {
       template <typename TExtent>
-      ALPAKA_FN_HOST static auto allocCachedBuf(alpaka::DevCpu const& dev, TQueue queue, TExtent const& extent)
-          -> alpaka::BufCpu<TElem, TDim, TIdx> {
+      ALPAKA_FN_HOST static auto allocCachedBuf(alpaka::DevCpu const& dev,
+                                                TQueue queue,
+                                                TExtent const& extent) -> alpaka::BufCpu<TElem, TDim, TIdx> {
         // non-cached, queue-ordered asynchronous host-only memory
         return alpaka::allocAsyncBuf<TElem, TIdx>(queue, extent);
       }

(I don't mind, just pointing it out)

@smuzaffar
Copy link
Contributor Author

ah right, sorry I missed that one. The change in #45870 (comment) is also only suggested by llvm18 and llvm17 will revert it

@smuzaffar
Copy link
Contributor Author

~CocoaMaterialElementary(){};

Shouldn't the trailing ; be removed ?

yes, I agree

@smuzaffar
Copy link
Contributor Author

There is RemoveSemicolon: true (currently set to false for cmssw via Google code Style) which can remove the trailing ; but looks like it is not working properly in llvm18 (or earlier releases). This has been fixed for llvm19 (not yet released though)

This was referenced Sep 5, 2024
@tomalin
Copy link
Contributor

tomalin commented Sep 11, 2024

@smuzaffar for development work in a personal branch based on a branch of 14_1, this PR causes a lot of git conflicts, as LLVM 18.1 changes many lines of code. Can you advise how people can run the LLVM 18.1 corrections on their personal 14_1 branches, before they make a PR to master, to avoid this?

@smuzaffar
Copy link
Contributor Author

smuzaffar commented Sep 11, 2024

@tomalin , first I would suggest to move the development to 14.2.X if changes are to be included in master branch.
If it is not possible or not easy then you can try the following ( make sure to make a copy of your existing 14.1.X src tree)

#create a CMSSW_14_2_X IB area  and set env
scram project CMSSW_14_2_X_2024-09-10-2300
cd CMSSW_14_2_X_2024-09-10-2300
cmsenv

# go to your 14.1.X dev area and run clang-format for all changed files e.g. if it is CMSSW_14_1_X_2024-09-10-2300
cd CMSSW_14_1_X_2024-09-10-2300
cd src
git diff --name-only CMSSW_14_1_X_2024-09-10-2300 | xargs clang-format -i 

Note that there are some manual changes required too e.g. removing the ; (see #45870 (comment))

@makortel
Copy link
Contributor

@smuzaffar Have we concluded everything here? (i.e. can we close the issue?)

@smuzaffar
Copy link
Contributor Author

+core
@makortel , yes this is complete and we can close it now

@cmsbuild
Copy link
Contributor

This issue is fully signed and ready to be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants