Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Jul 26, 2024
0 parents commit b93c328
Show file tree
Hide file tree
Showing 11 changed files with 1,307 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
nvapi/
nvapi.tar
31 changes: 31 additions & 0 deletions CMakeLists.txt
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()
Loading

0 comments on commit b93c328

Please sign in to comment.