Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:

- name: CUDA info
run: |
cmake --version
echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}"
echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}"
nvcc -V
Expand Down Expand Up @@ -89,15 +90,21 @@ jobs:
- name: Install build deps
run: |
apt-get install -y --no-install-recommends \
cmake ninja-build zlib1g-dev \
ninja-build zlib1g-dev \
hipblas-dev hipsparse-dev hipcub-dev rocprim-dev rocthrust-dev

- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.23.5'

# The ROCm apt packages don't add /opt/rocm/bin to PATH for non-interactive shells.
- name: Add ROCm to PATH
run: echo "/opt/rocm/bin" >> "$GITHUB_PATH"

- name: HIP info
run: |
cmake --version
hipcc --version

- name: Configure
Expand Down
65 changes: 46 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------------------------------------------------------------------
# ROOT CMakeLists.txt for cuPDLPx (Unified Build System)
# -----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.23)

# HIP/ROCm support option (must be set before project() to influence language detection)
option(USE_HIP "Build with HIP for AMD GPUs" OFF)
Expand Down Expand Up @@ -57,14 +57,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(USE_HIP)
# HIP architecture configuration
# Default to gfx90a if not specified; can override with -DCMAKE_HIP_ARCHITECTURES=gfx1100, etc.
if(NOT DEFINED CMAKE_HIP_ARCHITECTURES OR CMAKE_HIP_ARCHITECTURES STREQUAL "")
set(CMAKE_HIP_ARCHITECTURES "gfx90a")
endif()
endif()

# -----------------------------------------------------------------------------
# [ELEGANT DESIGN] Target-based Compile Flags
# -----------------------------------------------------------------------------
Expand All @@ -77,19 +69,26 @@ endif()

if(MSVC)
target_compile_options(cupdlpx_compile_flags INTERFACE
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/O2 /W4 /Zi>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/O2>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/W4 /Zi>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/W4>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zi>
)
if(NOT USE_HIP AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA"
AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
# Newer CUDA 13 CCCL headers require the conforming MSVC preprocessor.
# Keep CUDA 12 on its existing mode to avoid CUB/Thrust macro errors.
target_compile_options(cupdlpx_compile_flags INTERFACE
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>
)
endif()
target_compile_definitions(cupdlpx_compile_flags INTERFACE
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_DEPRECATE
strtok_r=strtok_s
strdup=_strdup
)
else()
target_compile_options(cupdlpx_compile_flags INTERFACE -O3 -Wall -Wextra -g)
target_compile_options(cupdlpx_compile_flags INTERFACE -Wall -Wextra -g)
if(NOT WIN32)
target_compile_options(cupdlpx_compile_flags INTERFACE -fPIC)
endif()
Expand All @@ -108,6 +107,7 @@ endif()
# CONTROL OPTIONS
# -----------------------------------------------------------------------------
include(CMakeDependentOption)
include(GNUInstallDirs)

option(CUPDLPX_BUILD_STATIC_LIB "Build the cuPDLPx static library" ON)
option(CUPDLPX_BUILD_SHARED_LIB "Build the cuPDLPx shared library" ON)
Expand Down Expand Up @@ -196,8 +196,18 @@ target_compile_definitions(cupdlpx_compile_flags INTERFACE PSLP_VERSION="${PSLP_
# -----------------------------------------------------------------------------
# TARGET DEFINITIONS
# -----------------------------------------------------------------------------
file(GLOB C_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
file(GLOB CU_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cu")
if(UNIX)
if(APPLE)
set(CUPDLPX_RPATH_ORIGIN "@loader_path")
else()
set(CUPDLPX_RPATH_ORIGIN "$ORIGIN")
endif()
file(RELATIVE_PATH CUPDLPX_LIBDIR_FROM_BINDIR
"${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

file(GLOB C_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
file(GLOB CU_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cu")
list(REMOVE_ITEM C_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/cli.c")

set(CORE_INCLUDE_DIRS
Expand Down Expand Up @@ -267,6 +277,9 @@ if(CUPDLPX_BUILD_SHARED_LIB)
OUTPUT_NAME "cupdlpx"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
if(UNIX)
set_target_properties(cupdlpx_shared PROPERTIES INSTALL_RPATH "${CUPDLPX_RPATH_ORIGIN}")
endif()
if(USE_HIP)
set_target_properties(cupdlpx_shared PROPERTIES
HIP_ARCHITECTURES "${CMAKE_HIP_ARCHITECTURES}"
Expand All @@ -292,6 +305,10 @@ if(CUPDLPX_BUILD_CLI)
OUTPUT_NAME "cupdlpx"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
if(UNIX)
set_target_properties(cupdlpx_cli PROPERTIES
INSTALL_RPATH "${CUPDLPX_RPATH_ORIGIN}/${CUPDLPX_LIBDIR_FROM_BINDIR}")
endif()
if(NOT USE_HIP)
set_target_properties(cupdlpx_cli PROPERTIES
CUDA_RESOLVE_DEVICE_SYMBOLS ON
Expand Down Expand Up @@ -336,17 +353,27 @@ if (CUPDLPX_BUILD_PYTHON)
endif()

# 6. Install Targets
# PSLP v0.0.11 installs only PSLP_API.h, but the public cuPDLPx types expose
# PresolveStats and PSLP_API.h includes PSLP_status.h.
install(DIRECTORY "${pslp_SOURCE_DIR}/include/PSLP/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/PSLP
FILES_MATCHING PATTERN "*.h"
)

if (CUPDLPX_BUILD_PYTHON)
install(DIRECTORY include/ DESTINATION include/ FILES_MATCHING PATTERN "*.h")
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
else()
if(TARGET cupdlpx_core)
install(TARGETS cupdlpx_core ARCHIVE DESTINATION lib)
install(TARGETS cupdlpx_core ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(TARGET cupdlpx_shared)
install(TARGETS cupdlpx_shared LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
install(TARGETS cupdlpx_shared
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(TARGET cupdlpx_cli)
install(TARGETS cupdlpx_cli RUNTIME DESTINATION bin)
install(TARGETS cupdlpx_cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(DIRECTORY include/ DESTINATION include/ FILES_MATCHING PATTERN "*.h")
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
endif()
2 changes: 1 addition & 1 deletion docs/guides/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Build it from source with the C libraries.
| Component | CUDA build | ROCm build |
| --- | --- | --- |
| Compiler | GCC and NVCC | GCC and `hipcc` |
| Build system | CMake 3.20+ | CMake 3.20+ |
| Build system | CMake 3.23+ | CMake 3.23+ |

See [hardware requirements](../getting-started/index.md#hardware-requirements)
for supported GPUs and required CUDA or ROCm versions.
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cd cuPDLPx
python -m pip install .
```

Building from source requires CMake 3.21+ and a
Building from source requires CMake 3.23+ and a
[CUDA or ROCm toolchain](command-line.md#build-requirements). Pip may build
the package locally if no compatible wheel is available.

Expand Down
4 changes: 2 additions & 2 deletions docs/implementation/gpu-backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ GPU.

### ROCm

HIP builds require a target architecture. The default is `gfx90a`; override it
for other devices:
HIP builds use CMake's GPU architecture detection by default. Set the target
architecture explicitly for headless builds or when targeting another device:

```bash
cmake -B build \
Expand Down
2 changes: 1 addition & 1 deletion include/cupdlpx_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

#pragma once

#include "PSLP_stats.h"
#include "PSLP/PSLP_stats.h"
#include <stdbool.h>
#include <stdlib.h>

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = ["numpy>=1.21", "scipy>=1.8"]

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.version = ">=3.21"
cmake.version = ">=3.23"
cmake.build-type = "Release"
wheel.packages = ["python/cupdlpx"]
sdist.include = [
Expand Down Expand Up @@ -77,4 +77,4 @@ source = ["cupdlpx"]
[tool.coverage.report]
fail_under = 80
show_missing = true
skip_covered = true
skip_covered = true
6 changes: 3 additions & 3 deletions python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# python_bindings/CMakeLists.txt

cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.23)

# sources
set(PYBIND_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/_core_bindings.cpp)
Expand Down Expand Up @@ -38,8 +38,8 @@ install(TARGETS _cupdlpx_core
)

if(WIN32)
# Install runtime DLL dependencies next to the extension module so Python can
# resolve them without additional os.add_dll_directory(...) calls.
# Copy runtime DLLs known to CMake, such as PSLP. CUDA's imported targets are
# UNKNOWN libraries, so CUDA DLLs are provided by the user's toolkit/environment.
install(FILES $<TARGET_RUNTIME_DLLS:_cupdlpx_core>
DESTINATION cupdlpx
OPTIONAL
Expand Down
Loading