Thread callback for OpenMP backend
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C
- Sterne
- 7.6k
- Forks
- 1.7k
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 54
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus OpenMathLib/OpenBLAS
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
OpenMathLib/OpenBLAS#6073 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
OpenMathLib/OpenBLAS#6069 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Missing cgroup awarenessOffen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
OpenMathLib/OpenBLAS#6059 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
OpenMathLib/OpenBLAS#6029 · 21 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
OpenMathLib/OpenBLAS#6028 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in OpenMathLib/OpenBLAS
Ähnliche Issues
-
documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
github/copilot-sdk#2804 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Zenmap
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 5 Tagen
-
hfile_s3: reading to EOF fails with EINVAL when object size is a multiple of the read part sizeOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 3 Tagen