Skip to content

Fix CUB imports for CUDA and CMake#31631

Closed
robertu94 wants to merge 5 commits intospack:developfrom
robertu94:cuda_cmake_fix
Closed

Fix CUB imports for CUDA and CMake#31631
robertu94 wants to merge 5 commits intospack:developfrom
robertu94:cuda_cmake_fix

Conversation

@robertu94
Copy link
Copy Markdown
Contributor

tl;dr Cuda installs CUB's (a cuda library) cmake files into a place where spack doesn't know about which means it can't tell cmake about it. We provide a mechanism to tell spack where to find this additional path, and then use it in the cuda package.

fixes #31568

@scheibelp you were the last person to work on the CMAKE_PREFIX_PATH logic. Could you please review this patch?

@ax3l @Rombur you two are the Cuda maintainers. Could you please review the change the the Cuda package?

@spackbot-app spackbot-app bot added build-environment core PR affects Spack core functionality update-package labels Jul 18, 2022
@robertu94 robertu94 requested review from ax3l and scheibelp July 18, 2022 20:29
@spackbot-app spackbot-app bot requested a review from Rombur July 18, 2022 20:29
Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

This overall looks good: I have a couple minor requests about comments. I have to think more about what to suggest regarding my comment about the side effects of modifications_for_dep (ideally running that function to collect CMAKE_PREFIX_PATH modifications wouldn't also do dpkg.setup_dependent_package(spec.package.module, spec))

# normal circumstances, it has to come from spack. include these second
# after the spack_built dependencies but before externals
env_mod_list = modifications_from_dependencies(pkg.spec, 'build',
custom_mods_only=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should also set set_package_py_globals=False.

With that, and if modifications_for_dep skipped dpkg.setup_dependent_package(spec.package.module, spec), this would have no side effects (but I'd need to think about what to suggest to skip the latter - maybe another parameter? That might be confusing for the interface).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@scheibelp this will be my first (second? not sure) contribution to spack core. Other than adding the argument you suggested I don't have context to understand what you want me to do here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry yes I need to think on it: my first naive suggestion is that we would need another parameter like set_package_py_globals which (when set =False) would skip dpkg.setup_dependent_package(spec.package.module, spec), but I'm thinking that having so many parameters to control small parts of the function's behavior will make it confusing to understand, so I'm thinking if I should work on refactoring it (which I could as a commit here if that's alright with you, but I wouldn't have time to do that until next week).

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp Sorry for the delay on this. I have pushed changes to the comments, and added a doc string. Please let me know if you want any more changes.

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp ping

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp This is blocking a fix for cuSZ being submitted. Is there a timeline on this being merged?

Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

I looked at this more and the side effects I am concerned about in #31631 (comment) should not be a problem. But I still think a refactor is in order, so I have added a suggestion for a TODO comment here. If you choose to commit it and the tests pass (assuming I formatted this right in the Github UI) then I'll merge it.

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp i can’t tell from the build log if that failure was spurious. However since it depends on Cuda, I don’t want to take a chance. How can we debug this failure?

@scheibelp
Copy link
Copy Markdown
Member

i can’t tell from the build log if that failure was spurious. However since it depends on Cuda, I don’t want to take a chance. How can we debug this failure?

It looks like the log for the failed package (mfem) is truncated - I'm checking if there's a way we can extend it.

I notice a couple of files are out of date - apologies for not noticing that before but FYI this will need to merge-from/rebase-on develop as well. It's possible that the errors will be resolved (if not though, we'll want to get the full log).

@scheibelp
Copy link
Copy Markdown
Member

I think I know how to get the full logs, but I suspect that since the latest run was a long time ago that they were discarded, so if the problem comes up again after a merge/rebase, I can see where the mfem build went wrong.

@scheibelp
Copy link
Copy Markdown
Member

(note you can run spack style --fix locally or the spackbot can do that here)

@robertu94
Copy link
Copy Markdown
Contributor Author

@spackbot fix style

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 23, 2022

Let me see if I can fix that for you!

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 23, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  lib/spack/spack/build_environment.py
  var/spack/repos/builtin/packages/cuda/package.py
==> Running isort checks
  isort checks were clean
==> Running mypy checks
Success: no issues found in 558 source files
  mypy checks were clean
==> Running black checks
reformatted var/spack/repos/builtin/packages/cuda/package.py
reformatted lib/spack/spack/build_environment.py
All done! ✨ 🍰 ✨
2 files reformatted.
  black checks were clean
==> Running flake8 checks
  flake8 checks were clean
==> spack style checks were clean
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp at least some of these failures seem to have come from other parts of spack not change by the PR that couldn't have been caused by this PR (i.e. undefined variables in code that I didn't change). What should I do next?

@scheibelp
Copy link
Copy Markdown
Member

scheibelp commented Aug 24, 2022

@robertu94 unfortunately after some investigation this error looks legitimate:

  • Most directly, it occurs because of my request to set set_package_py_globals=False
    • In more detail: our tests make sure that module globals are set when invoking functions like setup_build_environment
    • That function is used to compute the cmake_prefix_path
    • So for the time being in order to set variables like that, we must apply the module modifications
  • I don't think undoing that is the right approach (at least without refactoring the surrounding code)
  • I need to think a bit more on this, have an internal discussion on implied interfaces, and then circle back (ultimately that will likely involve me pushing additional changes to the PR)

That process will take at least a few days

@robertu94
Copy link
Copy Markdown
Contributor Author

@scheibelp following up to see what the status is on this.

@scheibelp
Copy link
Copy Markdown
Member

@robertu94 I spoke with @becker33 today and he proposed something I thought might address your needs in a simpler manner: could you let me know if #32547 would be an acceptable approach for you?

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

Labels

build-environment core PR affects Spack core functionality update-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmake build system needs a way to add additional CMAKE_PREFIX_PATH entries for things like CUDA

2 participants