Thread callback for OpenMP backend
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with the test.c reproducer, the omp_cb callback, and the openblas_set_threads_callback_function entry point. Read the callback example in pull request #4577 and trace the callback arguments used during cblas_dgemm. Done means the reproducer completes without a segmentation fault, including when the callback uses the OpenMP loop.
由索引模型根據 Issue 內容生成。
描述
Hi,
I'm trying to leverage #4577 in a project (scikit-learn) that has a mix of OpenMP and OpenBLAS built with the pthreads threading layer to make OpenBLAS use the OpenMP threadpool. Ideally we'd use an OpenBLAS built with the OpenMP threading layer but it's outside of our control because it comes from a dependency.
I naively tried the example callback presented in https://github.com/OpenMathLib/OpenBLAS/pull/4577#issue-2204960832, but I can't make it work. Here's a simple reproducer, just a gemm:
test.c
# include <stdio.h>
# include <stdlib.h>
# include <stddef.h>
# include <omp.h>
# include <cblas.h>
void omp_cb (int sync, openblas_dojob_callback dojob, int numjobs, size_t jobdata_elsize, void *jobdata, int dojob_data)
{
#pragma omp parallel for
for(int i = 0; i < numjobs; i++)
{
printf("thread: %d, i: %d\n", omp_get_thread_num(), i);
void *element_adrr = (void *) (((char *)jobdata) + ((unsigned) i)*jobdata_elsize);
dojob(i, element_adrr, dojob_data);
}
return;
}
void test()
{
int n = 100;
double *A = (double *)malloc(n * n * sizeof(double));
double *B = (double *)malloc(n * n * sizeof(double));
double *C = (double *)malloc(n * n * sizeof(double));
for(int i = 0; i < n * n; i++)
{
A[i] = 1.0;
B[i] = 1.0;
C[i] = 0.0;
}
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.0, A, n, B, n, 0.0, C, n);
free(A);
free(B);
free(C);
}
int main()
{
openblas_set_threads_callback_function(omp_cb);
test();
}
Compile command:
gcc -o test test.c -fopenmp -I/home/jeremie/R/installs/OpenBLAS/include -Wl,-rpath,/home/jeremie/R/installs/OpenBLAS/lib -L/home/jeremie/R/installs/OpenBLAS/lib -lopenblas
It just results in a segfault at the first step of the loop. Note that it still segfaults if I remove the omp pragma and just use a sequential loop in the callback.
Any help would be greatly appreciated.
- 主要語言
- C
- 星號
- 7.6k
- 分支
- 1.7k
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 48
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
OpenMathLib/OpenBLAS 的其他 Issue
-
難度 5/5 一週以上 新手友好度 35/100
OpenMathLib/OpenBLAS#6073 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
OpenMathLib/OpenBLAS#6069 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 52/100
OpenMathLib/OpenBLAS#6059 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
OpenMathLib/OpenBLAS#6029 · 21 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
OpenMathLib/OpenBLAS#6028 · 1 則留言 ·
維護者通常 1 天內回覆
查看 OpenMathLib/OpenBLAS 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
fastfetch-cli/fastfetch#2628 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
FujiNetWIFI/fujinet-firmware#1736 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 86/100