Skip to content

Conversation

@LukasBreitwieser
Copy link
Contributor

In order to reduce binary size and compile time, we add the LLVM's NVPTX target only if ROOT's cmake option 'cuda' was enabled. See: #20208

Add null object definition for IncrementalCUDADeviceCompiler to avoid that the client code of this class needs to be wrapped in #ifdefs, in order to compile.

In order to reduce binary size and compile time, we add LLVM's NVPTX
target only if ROOT's cmake option 'cuda' was enabled.
See: root-project#20208

Add null object definition for IncrementalCUDADeviceCompiler to avoid that the
client code of this class needs to be wrapped in #ifdefs, in order to compile.
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Test Results

    22 files      22 suites   3d 15h 1m 45s ⏱️
 3 706 tests  3 706 ✅ 0 💤 0 ❌
79 584 runs  79 584 ✅ 0 💤 0 ❌

Results for commit 883eb20.

♻️ This comment has been updated with latest results.

@dpiparo
Copy link
Member

dpiparo commented Oct 30, 2025

Do I understand correctly that if the tests pass, we will merge this change?

@dpiparo
Copy link
Member

dpiparo commented Oct 30, 2025

and, btw, what is the improvement in size and compile time?

@hahnjo
Copy link
Member

hahnjo commented Oct 30, 2025

and, btw, what is the improvement in size and compile time?

I didn't measure, but I would expect only little: the backends are a very small part of the entire LLVM libraries, the generic infrastructure, optimization passes and JIT functionality is much bigger.

@vgvassilev
Copy link
Member

and, btw, what is the improvement in size and compile time?

I didn't measure, but I would expect only little: the backends are a very small part of the entire LLVM libraries, the generic infrastructure, optimization passes and JIT functionality is much bigger.

I've mentioned privately that there is a little point in this change even if requested by an experiment. I do not oppose it but I do not see a benefit either except for adding some more conditionals in the codebase..

@vgvassilev
Copy link
Member

Including "llvm/Config/llvm-config.h" will break the builtin_clang=Off I think.

cc: @guitargeek

@hahnjo
Copy link
Member

hahnjo commented Oct 30, 2025

Including "llvm/Config/llvm-config.h" will break the builtin_clang=Off I think.

cc: @guitargeek

Why? It is included by a number of headers and installed as part of LLVM. builtin_clang has nothing to do with it.

@pcanal
Copy link
Member

pcanal commented Oct 30, 2025

and, btw, what is the improvement in size and compile time?
I didn't measure, but I would expect only little: the backends are a very small part of the entire LLVM libraries, the generic infrastructure, optimization passes and JIT functionality is much bigger.
I've mentioned privately that there is a little point in this change even if requested by an experiment. I do not oppose it but I do not see a benefit either except for adding some more conditionals in the codebase..

I agree with Vassil. Before merging this we ought to measure the change in size and time as the stated motivation in #20208 is:

In order to reduce binary size and compile time ...

If this PR does not accomplish this, it sounds like the extra complication is not worth it.
However, if the requester had additional motivation/need behind the request then we ought to update the issue and re-review the PR in view of those.

TLDR: Please measure the gains :)

@LukasBreitwieser
Copy link
Contributor Author

This PR reduces the size of ROOT's install directory for a release build by a mere 2020 kB, which is a 0.3% improvement. For the build time I don't have a number right now.

Due to your comments, the complication is now quite small. So I would argue that it would be worth merging.

@vgvassilev
Copy link
Member

My problem with merging this is that we lose the ability to call cling -cuda for such builds, not a big deal if we have diagnostics for the case but that makes the distribution less flexible for not a real impact…

I will let other decide though…

Copy link
Contributor

@devajithvs devajithvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also propose to close this PR due to the lower than expected positive impact.

@ferdymercury
Copy link
Collaborator

Maybe related: #20231

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the small changes required and that #20231 proposes a less correct approach, I personally think we should merge this even if the gain is small. Maybe we should update the commit message with a different motivation (and squash the commits). For me, that would be the fact that CUDA in Cling is an optional feature that we know doesn't properly work from inside ROOT (with modules). I am less worried about standalone cling since there the user has to actively work to turn off backends.

return;
}

#if LLVM_HAS_NVPTX_TARGET == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if LLVM_HAS_NVPTX_TARGET == 1
#if LLVM_HAS_NVPTX_TARGET

LLVMInitializeNVPTXAsmPrinter();

m_Init = true;
#endif // #if LLVM_HAS_NVPTX_TARGET == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif // #if LLVM_HAS_NVPTX_TARGET == 1
#endif // LLVM_HAS_NVPTX_TARGET

endif()

if(NOT "${ROOT_CLING_TARGET}" STREQUAL "all")
if(cuda)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the previous condition:

Suggested change
if(cuda)
if(cuda AND NOT "${ROOT_CLING_TARGET}" STREQUAL "all")

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants