Skip to content

Commit

Permalink
Updated to use coroutines instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Jul 2, 2023
1 parent 432b077 commit 45e64a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vcl/buffer.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn (b &Buffer) load(size int, ptr voidptr) chan IError {
ch <- vcl_error(ret)
return ch
}
spawn fn (event &ClEvent, ch chan IError) {
go fn (event &ClEvent, ch chan IError) {
defer {
cl_release_event(event)
}
Expand Down
2 changes: 1 addition & 1 deletion vcl/kernel.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn (k &Kernel) call(work_sizes []int, lokal_sizes []int) chan IError {
ch <- err
return ch
}
spawn fn (ch chan IError, event ClEvent) {
go fn (ch chan IError, event ClEvent) {
defer {
cl_release_event(event)
}
Expand Down
10 changes: 5 additions & 5 deletions vlas/internal/vblas/dgemm.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module vblas

// import runtime
import runtime
import sync
import vsl.float.float64
import math
Expand Down Expand Up @@ -143,7 +143,7 @@ fn dgemm_parallel(a_trans bool, b_trans bool, m int, n int, k int, a []f64, lda

// worker_limit acts a number of maximum concurrent workers,
// with the limit set to the number of procs available.
// worker_limit := chan int{cap: runtime.nr_jobs()}
worker_limit := chan int{cap: runtime.nr_jobs()}

// wg is used to wait for all
mut wg := sync.new_waitgroup()
Expand All @@ -154,11 +154,11 @@ fn dgemm_parallel(a_trans bool, b_trans bool, m int, n int, k int, a []f64, lda

for i := 0; i < m; i += block_size {
for j := 0; j < n; j += block_size {
// worker_limit <- 0
spawn fn (a_trans bool, b_trans bool, m int, n int, max_k_len int, a []f64, lda int, b []f64, ldb int, mut c []f64, ldc int, alpha f64, i int, j int, mut wg sync.WaitGroup) {
worker_limit <- 0
go fn [worker_limit] (a_trans bool, b_trans bool, m int, n int, max_k_len int, a []f64, lda int, b []f64, ldb int, mut c []f64, ldc int, alpha f64, i int, j int, mut wg sync.WaitGroup) {
defer {
wg.done()
// <-worker_limit
_ := <-worker_limit
}

mut leni := block_size
Expand Down

0 comments on commit 45e64a9

Please sign in to comment.