-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b93c328
Showing
11 changed files
with
1,307 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Build | ||
|
||
on: | ||
- pull_request | ||
- push | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
build_type: [Release] | ||
|
||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
|
||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- if: runner.os == 'Linux' | ||
name: Install CUDA toolkit on Linux | ||
uses: Jimver/cuda-toolkit@v0.2.16 | ||
with: | ||
method: network | ||
sub-packages: '["nvcc", "nvml-dev"]' | ||
|
||
- if: runner.os == 'Windows' | ||
name: Install CUDA toolkit on Windows | ||
uses: Jimver/cuda-toolkit@v0.2.16 | ||
with: | ||
method: network | ||
sub-packages: '["cudart", "nvcc", "nvml_dev"]' | ||
|
||
- if: runner.os == 'Linux' | ||
name: Install NVAPI headers on Linux | ||
run: ./nvapi.sh | ||
|
||
- if: runner.os == 'Windows' | ||
name: Install NVAPI headers on Windows | ||
run: .\nvapi.ps1 | ||
|
||
- name: Configure project | ||
run: > | ||
cmake | ||
-B ${{ github.workspace }}/build | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-S ${{ github.workspace }} | ||
- name: Build project | ||
run: > | ||
cmake | ||
--build ${{ github.workspace }}/build | ||
--config ${{ matrix.build_type }} | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ matrix.os }} | ||
path: | | ||
build/Release/nvidia-pstated.exe | ||
build/nvidia-pstated | ||
publish: | ||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
|
||
- name: Create release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: | | ||
*/Release/nvidia-pstated.exe | ||
*/nvidia-pstated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
nvapi/ | ||
nvapi.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Specify the minimum required version of CMake | ||
cmake_minimum_required(VERSION 3.17) | ||
|
||
# Define the project name and programming language | ||
project(nvidia-pstated C) | ||
|
||
# Find the CUDAToolkit package | ||
find_package(CUDAToolkit REQUIRED COMPONENTS nvml) | ||
|
||
# Define the executable target | ||
add_executable(nvidia-pstated | ||
src/main.c | ||
src/nvapi.c | ||
) | ||
|
||
# Include directories for the target | ||
target_include_directories(nvidia-pstated SYSTEM PRIVATE | ||
nvapi | ||
) | ||
|
||
# Link libraries | ||
target_link_libraries(nvidia-pstated PRIVATE | ||
CUDA::nvml | ||
) | ||
|
||
# Conditional linking for Linux platform | ||
if(UNIX AND NOT APPLE) | ||
target_link_libraries(nvidia-pstated PRIVATE | ||
dl | ||
) | ||
endif() |
Oops, something went wrong.