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

gromacs +cp2k: build in CI #40494

Merged
merged 8 commits into from
Oct 20, 2023
Merged

Conversation

haampie
Copy link
Member

@haampie haampie commented Oct 12, 2023

Since there were some issues with gromacs, lets build it in CI, together
with cp2k, which is an important and currently untested package in
Spack.

Overview of changes:

  • Require x86_64: in libxsmm s.t. dbcsr will default to ordinary BLAS on aarch64 / ppc64;
  • Fix compatibility issues with dbcsr and mpich@4.1: -- needs mpi_f08;
  • Bump C standard from C99 to C11 for newer versions of cp2k, for either build system
  • Add a patch for cp2k build_system=cmake that fixes installed config files
  • Remove dbcsr from gromacs+cp2k; it's not a direct dep, it's a dep of cp2k

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

@mtaillefumier can you have a look at the CP2K changes?

Do you know from what point CP2K switched from the C99 standard to C11?

Also I quickly glanced over the cmake build system for CP2K, is it missing set(CMAKE_C_STANDARD 11)?

Lastly, CP2K also seems to have this issue with mpich 4.1. Any workaround? Or should I put a hard upperbound on mpich 4.0?

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

@dev-zero / @alazzaro the ~mpi_f08 variant default in dbcsr is actually holding back mpich to version 4.0. Is it necessary to have it as a variant? Alternatively the cmake define could be set by default if mpich >= 4.1?

@mtaillefumier
Copy link
Contributor

we never switched to c11 or above. cp2k compiles fine with gnu17 (not fully c17 compliant) and should compile with c11 standard as well.
What MPI issue are you referring to because mpich is not particularly user friendly with fortran codes ?

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

we never switched to c11 or above.

cp2k/cp2k@77977db

In this commit it went from

const int D = DECIMAL_DIG; // In C11 we could use DBL_DECIMAL_DIG.

to

const int D = DBL_DECIMAL_DIG;

which is in CP2K v2023.2, so pressumably you went from C99 -> C11 during some release? It looks like the toolchain fails to set the relevant -std=c99/c11 flags. Apparently somebody ran into that earlier cause we explicitly set -std=c99 in the spack package, probably cause cp2k failed to compile with compilers that defaulted to c89.

@mtaillefumier
Copy link
Contributor

I do not see any potential issue setting the C standard to c11 though.

@mtaillefumier
Copy link
Contributor

that's the problem when two build systems are present. We always miss something in the process. So the only way to fix it is to enforce c11 in the spack recipe and the cmake build system. Actually the cmake build system will default to gnu17 for gcc 12 and 13. @haampie do you want me to do it ?

@mtaillefumier
Copy link
Contributor

Note it will require a PR in cp2k as well for the cmake build and we must have a workaround for the recipe (-DCMAKE_C_STANDARD) crossing our fingers that the standard defined for each target does not overwrite this.

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

I've created a PR cp2k/cp2k#3038.

I'd much rather use the CMake build system to be honest, exactly cause CMake knows how to set the language related flags, and the other build system (toolchain?) doesn't seem to care about it at all.

@mtaillefumier
Copy link
Contributor

mtaillefumier commented Oct 13, 2023

I've created a PR cp2k/cp2k#3038.

I'd much rather use the CMake build system to be honest, exactly cause CMake knows how to set the language related flags, and the other build system (toolchain?) doesn't seem to care about it at all.

I agree with you. But the toolchain is not going to disappear anytime soon. This problem is also related to this issue
#40372 where c99 is explicitly defined but the build still fails. I really suspect an issue with the compiler here more than anything else.

I wanted to enforce cmake use in spack with 2023.2 but my proposal was controversial. master should enforce cmake otherwise we will always have these problems.

@haampie haampie mentioned this pull request Oct 13, 2023
4 tasks
@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

where c99 is explicitly defined but the build still fails. I really suspect an issue with the compiler here more than anything else.

No, see https://en.cppreference.com/w/c/types/limits#Limits_of_floating_point_types for reference, -std=c99 fails correctly, CP2K is using C11.

@mtaillefumier
Copy link
Contributor

where c99 is explicitly defined but the build still fails. I really suspect an issue with the compiler here more than anything else.

No, see https://en.cppreference.com/w/c/types/limits#Limits_of_floating_point_types for reference, -std=c99 fails correctly, CP2K is using C11.

good to know thanks. That's why it is failing std=c99.

@mtaillefumier
Copy link
Contributor

We have to fix the recipe.

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

I wanted to enforce cmake use in spack with 2023.2

For my understanding, it looks like the CMake build of CP2K uses DBCSR as a separate package, whereas the toolchain is using the internal copy of DBCSR, or not?

I'd much rather use DBCSR as a separate package, cause otherwise we have to duplicate all conflicts and compat bounds from the DBCSR package into CP2K. (Right now: mpich 4.1 compatibility and fixes to make it work).

We have to fix the recipe.

Yeah, that's done in this PR ;)

@@ -82,6 +82,9 @@ class Libxsmm(MakefilePackage):
# (<https://github.com/spack/spack/pull/21671#issuecomment-779882282>).
depends_on("binutils+ld+gas@2.33:", type="build", when="@:1.17")

# Intel Architecture or compatible CPU required
requires("target=x86_64:")
Copy link
Member Author

@haampie haampie Oct 13, 2023

Choose a reason for hiding this comment

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

@hfp is this OK? I wanna turn the configure/build time error into a constraint, s.t. packages like dbcsr automatically use ordinary blas instead of libxsmm on arm / powerpc

@mtaillefumier
Copy link
Contributor

I wanted to enforce cmake use in spack with 2023.2

For my understanding, it looks like the CMake build of CP2K uses DBCSR as a separate package, whereas the toolchain is using the internal copy of DBCSR, or not?

I'd much rather use DBCSR as a separate package, cause otherwise we have to duplicate all conflicts and compat bounds from the DBCSR package into CP2K. (Right now: mpich 4.1 compatibility and fixes to make it work).

We have to fix the recipe.

Yeah, that's done in this PR ;)

You are right. DBCSR is an external package. I only added the option to build dbcsr with cp2k but i do not like the idea from the first place. That's also why the this option is not available with the spack recipe. If people build cp2k with spack and cmake then dbcsr will be considered external dependency. I am not going to change this what ever users want it or not.

@mtaillefumier
Copy link
Contributor

PR cp2k/cp2k#3039 for cp2k. Will solve issue #40372 at the same time.

@mtaillefumier
Copy link
Contributor

NB : dbcsr dependence is only activated when the build system is cmake.

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

Ok yeah. Whatever the default build system is, we can always decide to build with cmake in our CI 🙃 I think that's much better, given the dbcsr + mpich 4.1 issues... duplicating all dbcsr constraints in cp2k sounds like a bad idea.

Just pushed that, so we test gromacs +cp2k ^cp2k build_system=cmake

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

I've opened #40505 about going forward with cp2k build_system=cmake.

@haampie
Copy link
Member Author

haampie commented Oct 13, 2023

gromacs cannot locate cp2k through pkg-config when using build_system=cmake @mtaillefumier, does it generate a different pkg config file from the toolchain?

@mtaillefumier
Copy link
Contributor

gromacs cannot locate cp2k through pkg-config when using build_system=cmake @mtaillefumier, does it generate a different pkg config file from the toolchain?

I am sure I generate the pkgconfig file. I suspect I do not install it. One more fix

@mtaillefumier
Copy link
Contributor

You can also use find_package(cp2k). these files are installed

Copy link
Contributor

@mtaillefumier mtaillefumier left a comment

Choose a reason for hiding this comment

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

nothing to say. Approved.

@haampie
Copy link
Member Author

haampie commented Oct 19, 2023

gromacs+cp2k builds fine for x86 / arm / ppc, so should be good to go

Comment on lines 919 to 922
# C standard was omitted in the first release with CMake build system.
# https://github.com/cp2k/cp2k/pull/3039
if spec.satisfies("@2023.2"):
args.append(self.define("CMAKE_C_STANDARD", "11"))
Copy link
Member

Choose a reason for hiding this comment

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

Is this still useful given the patch?

Comment on lines +428 to +432
# Use of DBL_DECIMAL_DIG
cflags.append(self.compiler.c11_flag)
Copy link
Member

Choose a reason for hiding this comment

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

Is this still useful given the patch?

Copy link
Member Author

Choose a reason for hiding this comment

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

This one should stay, it's for the other build system

Copy link
Member

Choose a reason for hiding this comment

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

Given the CMake patch introduced here for @2023.2, I think the conflict with +mpi_f08 introduced in #40574 can be relaxed to include @2023.2 as well? (I think the changes introduced in #40574 are not currently in this PR.)

@haampie haampie force-pushed the ci/add-gromacs-cp2k branch 2 times, most recently from 85cb6c0 to 0713eb1 Compare October 20, 2023 08:21
@@ -277,11 +277,10 @@ class Cp2k(MakefilePackage, CudaPackage, CMakePackage, ROCmPackage):

with when("build_system=cmake"):
depends_on("dbcsr")
depends_on("dbcsr@2.6:", when="@2023.2:")
depends_on("dbcsr@2.6:")
Copy link
Member Author

Choose a reason for hiding this comment

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

this when condition was implied by build_system=cmake already

@msimberg msimberg merged commit 4bade7e into spack:develop Oct 20, 2023
34 checks passed
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Oct 23, 2023
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
victoria-cherkas pushed a commit to victoria-cherkas/spack that referenced this pull request Oct 30, 2023
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Nov 2, 2023
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
@haampie haampie deleted the ci/add-gromacs-cp2k branch November 21, 2023 08:10
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 11, 2024
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 31, 2024
* gromacs +cp2k: build in CI

* libxsmm: x86 only

* attempt to fix dbcsr + new mpich

* use c11 standard

* gromacs: does not depend on dbcsr

* cp2k: build with cmake in CI, s.t. dbcsr is a separate package

* cp2k: cmake patches for config files and C/C++ std

* cp2k: remove unnecessary constraints due to patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts core PR affects Spack core functionality dependencies gitlab Issues related to gitlab integration patch update-package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants