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

how to install SuperLU_MT on windows #2

Open
Ning-Li-Ambition opened this issue Feb 4, 2022 · 15 comments
Open

how to install SuperLU_MT on windows #2

Ning-Li-Ambition opened this issue Feb 4, 2022 · 15 comments

Comments

@Ning-Li-Ambition
Copy link

Hi, I try to install SuperLU_MT on windows with visual studio following your instructions on this webpage https://portal.nersc.gov/project/sparse/superlu/faq.html#windows. But it does not work and I got the following errors. Could you please help me to fix these errors? thanks

Severity Code Description Project File Line Suppression State
Error (active) E0393 pointer to incomplete class type "struct timeval" is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 72
Error (active) E1696 cannot open source file "sys/time.h" SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 47
Error (active) E1696 cannot open source file "sys/times.h" SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 46
Error (active) E1696 cannot open source file "unistd.h" SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 48
Error (active) E0020 identifier "_SC_CLK_TCK" is undefined SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 58
Error (active) E3365 incomplete class type "struct tms" is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 61
Error (active) E3365 incomplete class type "struct tms" is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 62
Error (active) E0070 incomplete type is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 56
Error (active) E0070 incomplete type is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 79
Error (active) E0070 incomplete type is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 80
Error (active) E0393 pointer to incomplete class type "struct timeval" is not allowed SuperLU_MT C:\Installed-Libs\superlu_mt_3.1\SRC\dclock.c 71

@xiaoyeli
Copy link
Owner

xiaoyeli commented Feb 5, 2022 via email

@Ning-Li-Ambition
Copy link
Author

I added NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;__OPENMP;WIN32;UpCase; to property page->C/C++->Preprocessor->Preprocessor definitions. and build the library successfully. But when I linked the library SuperLU_MT.lib to my Fortran visual studio project, I got the linker error:
Severity Code Description Project File Line Suppression State
Error error LNK2019: unresolved external symbol PDGSSV referenced in function MAIN f77_main.obj

@xiaoyeli
Copy link
Owner

Can you take a look at README, the section discussing CDEFS. Some name mangling is needed between Fortran and C programs.

@Ning-Li-Ambition
Copy link
Author

Ning-Li-Ambition commented Apr 12, 2022

I read that section, and I also read the source file slu_mt_Cnames.h. That is why I added UpCase to Preprocessor definitions.
I think the problem is the library generated does not provide a linkage to those functions. and extern "C"
keyword might be necessary.

@xiaoyeli
Copy link
Owner

I suggest that you write a small program to test out the Fortran-C calling needs on your machine.

@Ning-Li-Ambition
Copy link
Author

Ning-Li-Ambition commented Apr 13, 2022

Hi, Sherry, this is my test result:

  1. I built a static library in c++ with visual studio, this is the source code
    1.1 Cpp_lib.h
    #pragma once
    extern "C" double add(double* a, double* b, double* c);
    1.2 Cpp_lib.cpp
    #include "Cpp_lib.h"

      double add(double* a, double* b, double* c) {
      *c = *a + *b;
      return *c;
       }
    
  2. my fortran code
    program main
    use, intrinsic :: ISO_C_Binding, only: C_DOUBLE
    implicit none
    double precision :: a, b, c

    interface
    subroutine add(a, b, c) bind(C,name="add")
    import
    real(C_DOUBLE) :: a, b, c
    end subroutine
    end interface

    a = 1.0D0
    b = 2.3D0
    call add(a, b, c)

    print*, 'c: ', c
    pause
    end program main

  3. result
    I run the fortran code with visual studio, there is no problem.
    then I tried to do the same thing with SuperLU_MT, but in your source code, I could not find the definition of c_bridge_dgssv

@xiaoyeli
Copy link
Owner

Are you using C++ compiler? If so, can you try add c_bridge_pdgssv in side extern "C" { ...} in SRC/slu_mt_ddefs.h ?

@Ning-Li-Ambition
Copy link
Author

Ning-Li-Ambition commented Apr 18, 2022

yes, visual studio 2019 uses C++ compiler.
what should be the definition of c_bridge_pdgssv? same as pdgssv?

@xiaoyeli
Copy link
Owner

I just pushed a commit, adding c_bridge_pdgssv_ in SRC/slu_mt_ddefs.h.
You can try the master branch.

@jschueller
Copy link
Contributor

it builds now with visual studio using cmake

@ChessMastery
Copy link

I think there might be a problem with current version (4.0.0) for Windows users. I know main developers does not use Windows, but I hope there might be some developers or users that support the package for Windows. So I built 4.0.0 yesterday this way: created C++ project and added all .c and .h source files, then liked Intel MKL (I use Intel C++ compiler 2024), set preprocessor definitions USE_VENDOR_BLAS and _OPENMP and built a .lib. I cannot build superlu_mt version 3.1 this way though, because of "Error: call to undeclared function 'ccopy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] superlu_v31_intel_build path\SuperLU\SuperLU_MT_3.1\SRC\clacon.c(159,5): 1". I don't know how easy it can be fixed but I do not really need this version. But I can build as well some intermediate code I downloaded in spring 2023 and it is different from the current 4.0.0 version (I attach the archive). The problem is the code (I also attach the code and a small matrix in another archive) works fine on an intermediate version (relative residual output 1.317e-12, info=0, nnz(L+U)=1192547) and works wrong on 4.0.0 version (relative residual output 2.338e+09, info=0, nnz(L+U)=1189830). Please tell me what can be the reason of such behaviour and whether someone built and used 4.0.0 version on Windows with MSBuild (Visual Studio) successfully.
superlu_mt-master.zip
superlu_test.zip

@ChessMastery
Copy link

Seems like I fixed it. First I tried to set [int nprocs = 1] instead of [int nprocs = 4] and itworked correctly. Then I tried turn off OpenMP support MSBuild option while building 9.0.0 version and it worked.

@ChessMastery
Copy link

I realized I just turned off OpenMP support and OpenMP directives were ignored. When I build like this, SuperLU_mt with sequential BLAS works a little bit slower than sequential SuperLU. When I build with OpenMP support, I get huge residual with both 4.0.0 and older versions, but when I set OpenMP threads number as 1 I get normal residual. Could you please tell what steps did you do in order to build correctly working SuperLU_mt with OpenMP and Visual Studio?

@jschueller
Copy link
Contributor

jschueller commented Oct 16, 2024

the infos on the website are outdated, as it can be built using cmake now that should set the right compilation options for you, here is an example using cmake + ninja:

git clone -b v4.0.1 --depth 1 https://github.com/xiaoyeli/superlu_mt.git
cmake -LAH -G "Ninja" -B build_slu -S superlu_mt -DPLAT="_OPENMP" -DBUILD_SHARED_LIBS=OFF -Denable_tests=OFF -Denable_examples=OFF
cmake --build build_slu

@ChessMastery
Copy link

ChessMastery commented Oct 16, 2024

These commands worked for me, thanks a lot!
P. S. I also added -DCMAKE_BUILD_TYPE=Release option in the 2nd command, or it can be specified in the root CMakeLists.txt file as set(CMAKE_BUILD_TYPE Release). Without this option, the solver works about 2 times slower on some matrices I tested (e. g. COLAMD permutation is calculated 2 times slower).

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