Skip to content

Commit

Permalink
Gpu fix (#199)
Browse files Browse the repository at this point in the history
* fix gpu

* add gpu action

* workflow namings
  • Loading branch information
bodono committed Jan 11, 2022
1 parent 5a40b44 commit 515c905
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Build
name: Build and Test

on: [push, pull_request]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Cmake
name: CMake

on: [push, pull_request]

Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: GPU

on: [push, pull_request]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Jimver/cuda-toolkit@v0.2.5
- run: sudo apt-get install libopenblas-dev liblapack-dev
- run: make gpu
- run: make test_gpu
# - run: out/run_tests_gpu_indirect # gpus not available yet

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ $(LINSYS)/gpu/gpu.o: $(LINSYS)/gpu/gpu.c
# $(CUCC) -c -o $(GPUDIR)/private.o $^ $(CUDAFLAGS)

$(GPUINDIR)/private.o: $(GPUINDIR)/private.c
$(CUCC) -c -o $(GPUINDIR)/private.o $^ $(CUDAFLAGS)
$(CUCC) -c -o $@ $^ $(CUDAFLAGS)

# $(OUT)/libscsgpudir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/gpu/gpu.o
# mkdir -p $(OUT)
Expand Down Expand Up @@ -143,7 +143,7 @@ $(OUT)/demo_socp_gpu_indirect: test/random_socp_prob.c $(OUT)/libscsgpuindir.a

.PHONY: clean purge
clean:
@rm -rf $(TARGETS) $(SCS_O) $(SCS_INDIR_O) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o
@rm -rf $(TARGETS) $(SCS_O) $(SCS_INDIR_O) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o $(LINSYS)/gpu/*.o
@rm -rf $(OUT)/*.dSYM
@rm -rf matlab/*.mex*
@rm -rf .idea
Expand Down
4 changes: 2 additions & 2 deletions linsys/gpu/gpu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SCSGPU_H_GUARD
#define SCSGPU_H_GUARD
#ifndef SCS_GPU_H_GUARD
#define SCS_GPU_H_GUARD

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions linsys/gpu/indirect/private.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ ScsLinSysWork *SCS(init_lin_sys_work)(const ScsMatrix *A, const ScsMatrix *P,
p = (ScsLinSysWork *)scs_calloc(1, sizeof(ScsLinSysWork));
Ag = (ScsGpuMatrix *)scs_calloc(1, sizeof(ScsGpuMatrix));

p->inv_r_y = (scs_float *)scs_calloc(A->m * sizeof(scs_float));
p->M = (scs_float *)scs_calloc(A->n * sizeof(scs_float));
p->inv_r_y = (scs_float *)scs_calloc(A->m, sizeof(scs_float));
p->M = (scs_float *)scs_calloc(A->n, sizeof(scs_float));

p->A = A;
p->P = P;
Expand Down
3 changes: 2 additions & 1 deletion linsys/gpu/indirect/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ struct SCS_LIN_SYS_WORK {
scs_int n, m; /* linear system dimensions */
/* reporting */
scs_int tot_cg_its;
scs_float *M; /* preconditioner on cpu */
/* ALL BELOW HOSTED ON THE GPU */
scs_float *p; /* cg iterate, n */
scs_float *r; /* cg residual, n */
scs_float *Gp; /* G * p, n */
scs_float *bg; /* b, n */
scs_float *tmp_m; /* m, used in mat_vec */
scs_float *z; /* preconditioned */
scs_float *M; /* preconditioner */
scs_float *M_gpu; /* preconditioner */
const ScsMatrix *A; /* does *not* own this memory */
const ScsMatrix *P; /* does *not* own this memory */
ScsGpuMatrix *Ag; /* A matrix on GPU */
Expand Down

0 comments on commit 515c905

Please sign in to comment.