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

Give option to exclude compiling internal UMFPACK in cmake #578

Open
juhanikataja opened this issue Sep 19, 2024 · 10 comments
Open

Give option to exclude compiling internal UMFPACK in cmake #578

juhanikataja opened this issue Sep 19, 2024 · 10 comments

Comments

@juhanikataja
Copy link
Contributor

Elmer internal UMFPACK is not needed on supercomputing platforms and may cause problems with picky compiler stacks.

There should be a cmake build variable e.g. DISABLE_INTERNAL_UMFPACK which would disable compiling UMFPACK.

Changes would probably include:

  • Change #define HAVE_UMFPACK in fem/config.h.cmake to #cmakedefine @HAVE_UMFPACK@
  • Modify CMakeLists.txt in few places
@mmuetzel
Copy link
Contributor

I hope you don't mind me asking which issues those are.
Do these issues still occur if you build with a current version of UMFPACK from SuiteSparse and configure with -DEXTERNAL_UMFPACK=ON?

mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Sep 19, 2024
Add new CMake variable `WITH_UMFPACK` which can be used to build without
using any functions from the UMFPACK library.

The default for this new variable is `TRUE` so there is no difference in
the build configuration to before unless a user explicitly configure
with, e.g., `-DWITH_UMFPACK=OFF`.

This probably fixes the issue described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Sep 19, 2024
Add new CMake variable `WITH_UMFPACK` which can be used to build without
using any functions from the UMFPACK library.

The default for this new variable is `TRUE` so there is no difference in
the build configuration to before unless a user explicitly configures
with, e.g., `-DWITH_UMFPACK=OFF`.

This probably fixes the issue described in ElmerCSC#578.
@mmuetzel
Copy link
Contributor

The changes from #579 should allow building without UMFPACK.

@juhanikataja
Copy link
Contributor Author

It's not actually clear what is causing the incompatibility. The passage about picky compilers was weird humor that has no place in github issues, sorry about that.

The reasoning about giving an option to disable internal umfpack even without external is that

  • On a supercomputer, there is no point in having a non-parallel direct solver.
  • The internal UMFPACK solver in the elmer source tree adds to increased compile time, complexity and a source for weird compilation failures.
  • The internal UMFPACK version is old, newer versions are faster so for production runs one should anyhow have their own UMFPACK.
  • The internal UMFPACK shouldn't be completely removed since it enables Elmer to be a fully fledged FE solver without much external dependenices.

Do we assume internally in some parts of elmer the existence of UMFPACK or is it just in the solvers?

Currently there is a crude workaround at 778d9a3 where this issue stemmed from:

In file included from .../elmerfem/umfpack/src/umfpack/umf_analyze.c:29:
In file included from .../elmerfem/umfpack/src/umfpack/include/umf_internal.h:88:
In file included from .../elmerfem/umfpack/src/umfpack/../amd/amd_internal.h:72:
In file included from /usr/include/stdlib.h:394:
In file included from /usr/include/sys/types.h:29:
/usr/include/bits/types.h:155:34: error: typedef redefinition with different types ('struct __fsid_t' vs 'struct __fsid_t')
typedef struct { int __val[2]; } __fsid_t;
                                 ^
/usr/include/bits/types.h:155:26: note: previous definition is here
__STD_TYPE __FSID_T_TYPE __fsid_t;      /* Type of file system IDs.  */

@juharu
Copy link
Contributor

juharu commented Sep 20, 2024 via email

@mmuetzel
Copy link
Contributor

Thank you for clarifying.

True. UMFPACK (even the current upstream version) relies heavily on the respective BLAS and LAPACK implementations for parallelization. It isn't multi-threaded by itself if I understand correctly.

The compilation error you are seeing is odd. It looks like it is complaining about two conflicting type definitions in the same header?? That is odd indeed.
Can you share that header file (/usr/include/bits/types.h)? Maybe some incompatible combination of preprocessor definitions are set?

@juharu
Copy link
Contributor

juharu commented Sep 20, 2024 via email

@tzwinger
Copy link
Contributor

Am I mistaken to conclude that the conflicting type definition is something platform-specific and not able to be fixed in what comes to the umfpack included in Elmer? We experience the error on a HPE-Cray system with the Cray-CCE compiler set.

@mmuetzel
Copy link
Contributor

I'm not sure I understand the compiler error message correctly. It looks like it is referring to a conflicting type definition. But the locations that the error message presents look like they are from the same file and even the same line in that file.
However, it presents different content of that line. I honestly don't know what that means.
Is this a compiler error? Or some issue in glibc(?) heeders (missing inclusion guards?)? Or something completely different?

It might be that the line that it presents looks different because it is pre-processed for one and the "raw" source code for the other?

Maybe for some reason that header is included twice (and the inclusion guard isn't working for some reason).
Iiuc, headers are treated slightly differently when they are included via the system include path or via a user include path. Maybe, the header somehow ends up being included via both and the compiler doesn't "realize" it is the same???
If that is the case, compiling with -std=gnu11 (or whatever flag the Cray compiler needs for C11). C11 should allow multiple typedefs if they are compatible afaict.

Does the issue go away if you add that flag to CMAKE_C_FLAGS when configuring ElmerFEM?

@juhanikataja
Copy link
Contributor Author

The problem appears to be in the combination of specific cray programming environment modules where -fopenmp flag looks like it is injecting typedef ... __fsid_t in the global scope.

Since we don't hopefully need fsid_t, I suggest we just use the workaround 778d9a3 mentioned earlier in devel.

The following code reproduces the bug with cc -fopenmp bug.c when those modules are loaded:

typedef struct { int __val[2]; } __fsid_t;
typedef __fsid_t fsid_t;

int main(int argc, char** argv) {
  return 0;
}

mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Sep 26, 2024
Add new CMake variable `WITH_UMFPACK` which can be used to build without
using any functions from the UMFPACK library.

The default for this new variable is `TRUE` so there is no difference in
the build configuration to before unless a user explicitly configures
with, e.g., `-DWITH_UMFPACK=OFF`.

This probably fixes the issue described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Sep 27, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources.

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
@mmuetzel
Copy link
Contributor

mmuetzel commented Sep 28, 2024

This issue seems to be caused by the fact that the build rules of UMFPACK (and AMD) are preprocessing the original sources with a different set of flags than when compiling. The situation with the Cray compiler might not be the only affected build toolchain. (Theoretically, doing that could result in a "successful" compilation but undefined (or unexpected) behavior on runtime.)

The changes proposed in #587 avoid the separate preprocessing step entirely by using CMake object libraries to build parts of the sources for the "actual" libraries with different sets of preprocessor flags.

Do you still see the issues from here with the changes from PR #587?

mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Sep 30, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Oct 2, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Oct 10, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Oct 18, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Oct 30, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Nov 11, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
mmuetzel added a commit to mmuetzel/elmerfem that referenced this issue Nov 21, 2024
Avoid manually preprocessing the source files. Some compiler flags can
easily be missed which can lead to compilation issues with the
preprocessed sources (see ElmerCSC#578).

Instead, use object libraries to build the same source files with
different flags.

Potentially fixes the build issues described in ElmerCSC#578.
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

No branches or pull requests

4 participants