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

CHOLMOD GPU: Fix qsort #366

Merged
merged 3 commits into from
Aug 30, 2023

Conversation

whuaegeanse
Copy link
Contributor

No __compar_fn_t defined in windows when building with msvc.

@mmuetzel
Copy link
Contributor

mmuetzel commented Aug 30, 2023

I believe there should be some sort of preprocessor condition guarding that definition.
Maybe, #if ! defined(__GLIBC__)? But there might be other libc implementations that also declare it...

@mmuetzel
Copy link
Contributor

mmuetzel commented Aug 30, 2023

Does it work if you apply the following change?

diff --git "a/CHOLMOD/GPU/CMakeLists.txt" "b/CHOLMOD/GPU/CMakeLists.txt"
index 8c4fccc13..491ca3895 100644
--- "a/CHOLMOD/GPU/CMakeLists.txt"
+++ "b/CHOLMOD/GPU/CMakeLists.txt"
@@ -100,6 +100,19 @@ if ( SUITESPARSE_CUDA )
     endif ( )
 endif ( )
 
+include ( CheckTypeSize )
+set ( old_CMAKE_EXTRA_INCLUDE_FILES CMAKE_EXTRA_INCLUDE_FILES )
+list ( APPEND CMAKE_EXTRA_INCLUDE_FILES "stdlib.h" )
+check_type_size ( "__compar_fn_t" COMPAR_FN_T )
+set ( CMAKE_EXTRA_INCLUDE_FILES old_CMAKE_EXTRA_INCLUDE_FILES )
+
+if ( NOT HAVE_COMPAR_FN_T )
+    target_compile_definitions ( CHOLMOD_CUDA PRIVATE NCOMPAR_FN_T )
+    if ( NOT NSTATIC )
+        target_compile_definitions ( CHOLMOD_CUDA_static PRIVATE NCOMPAR_FN_T )
+    endif ( )
+endif ( )
+
 #-------------------------------------------------------------------------------
 # installation location
 #-------------------------------------------------------------------------------

And then guard the definition with #if ! defined (NCOMPAR_FN_T).

@mmuetzel
Copy link
Contributor

Could you please update this PR with that change?

Copy link
Contributor

@mmuetzel mmuetzel left a comment

Choose a reason for hiding this comment

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

Please check your editor settings. It looks like you are using CRLF instead of LF for line endings.

@@ -188,6 +188,9 @@ int TEMPLATE2 (CHOLMOD (gpu_init))

}

#if !defined(NCOMPAR_FN_T)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry. I meant #if defined(NCOMPAR_FN_T).

Suggested change
#if !defined(NCOMPAR_FN_T)
#if defined(NCOMPAR_FN_T)

CHOLMOD/GPU/t_cholmod_gpu.c Outdated Show resolved Hide resolved
@mmuetzel
Copy link
Contributor

mmuetzel commented Aug 30, 2023

Sorry, I realized now that that file isn't part of CHOLMOD_CUDA (even if it is in the GPU subfolder).
It's included in Supernodal\cholmod_super_numeric.c which is part of the CHOLMOD library.

Could you please revert the change in CHOLMOD/GPU/CMakeLists.txt and test the following change instead?

diff --git "a/CHOLMOD/CMakeLists.txt" "b/CHOLMOD/CMakeLists.txt"
index 45d623fa0..629994224 100644
--- "a/CHOLMOD/CMakeLists.txt"
+++ "b/CHOLMOD/CMakeLists.txt"
@@ -480,6 +480,20 @@ if ( SUITESPARSE_CUDA )
         target_link_libraries ( CHOLMOD_static PUBLIC CUDA::nvrtc CUDA::cudart_static
             CUDA::nvToolsExt CUDA::cublas )
     endif ( )
+
+    include ( CheckTypeSize )
+    set ( old_CMAKE_EXTRA_INCLUDE_FILES CMAKE_EXTRA_INCLUDE_FILES )
+    list ( APPEND CMAKE_EXTRA_INCLUDE_FILES "stdlib.h" )
+    check_type_size ( "__compar_fn_t" COMPAR_FN_T )
+    set ( CMAKE_EXTRA_INCLUDE_FILES old_CMAKE_EXTRA_INCLUDE_FILES )
+
+    if ( NOT HAVE_COMPAR_FN_T )
+        target_compile_definitions ( CHOLMOD PRIVATE NCOMPAR_FN_T )
+        if ( NOT NSTATIC )
+            target_compile_definitions ( CHOLMOD_static PRIVATE NCOMPAR_FN_T )
+        endif ( )
+    endif ( )
+
 endif ( )
 
 #-------------------------------------------------------------------------------

Edit: Fixed the target names in the code snippet.

@whuaegeanse
Copy link
Contributor Author

Sorry, I realized now that that file isn't part of CHOLMOD_CUDA (even if it is in the GPU subfolder). It's included in Supernodal\cholmod_super_numeric.c which is part of the CHOLMOD library.

Could you please revert the change in CHOLMOD/GPU/CMakeLists.txt and test the following change instead?

diff --git "a/CHOLMOD/CMakeLists.txt" "b/CHOLMOD/CMakeLists.txt"
index 45d623fa0..629994224 100644
--- "a/CHOLMOD/CMakeLists.txt"
+++ "b/CHOLMOD/CMakeLists.txt"
@@ -480,6 +480,20 @@ if ( SUITESPARSE_CUDA )
         target_link_libraries ( CHOLMOD_static PUBLIC CUDA::nvrtc CUDA::cudart_static
             CUDA::nvToolsExt CUDA::cublas )
     endif ( )
+
+    include ( CheckTypeSize )
+    set ( old_CMAKE_EXTRA_INCLUDE_FILES CMAKE_EXTRA_INCLUDE_FILES )
+    list ( APPEND CMAKE_EXTRA_INCLUDE_FILES "stdlib.h" )
+    check_type_size ( "__compar_fn_t" COMPAR_FN_T )
+    set ( CMAKE_EXTRA_INCLUDE_FILES old_CMAKE_EXTRA_INCLUDE_FILES )
+
+    if ( NOT HAVE_COMPAR_FN_T )
+        target_compile_definitions ( CHOLMOD_CUDA PRIVATE NCOMPAR_FN_T )
+        if ( NOT NSTATIC )
+            target_compile_definitions ( CHOLMOD_CUDA_static PRIVATE NCOMPAR_FN_T )
+        endif ( )
+    endif ( )
+
 endif ( )
 
 #-------------------------------------------------------------------------------

The previous version does not work.
1>D:\zgh\Libs\suitesparse\SuiteSparse\CHOLMOD\Supernodal\../GPU/t_cholmod_gpu.c(279,27): error C2065: '__compar_fn_t': undeclared identifier
I will try this verion.

@mmuetzel
Copy link
Contributor

Please note that I fixed a copy-paste error in the target names after the original post.
The diff in your reply still contains the wrong target names.

@whuaegeanse
Copy link
Contributor Author

Please note that I fixed a copy-paste error in the target names after the original post. The diff in your reply still contains the wrong target names.

Errors gone.
CholmodGPU

@mmuetzel
Copy link
Contributor

I don't understand that screenshot. But if it working for you, please update the PR.

@whuaegeanse
Copy link
Contributor Author

I don't understand that screenshot. But if it working for you, please update the PR.

Done. Thanks.

@mmuetzel
Copy link
Contributor

Looks good to me now, too. 👍

@DrTimothyAldenDavis DrTimothyAldenDavis merged commit 1ec38a5 into DrTimothyAldenDavis:dev2 Aug 30, 2023
13 checks passed
@DrTimothyAldenDavis
Copy link
Owner

Thanks for the update!

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.

3 participants