Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Thread callback for OpenMP backend

Đang mở
#4,770 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c
Lĩnh vực
hpc

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C
Star
7.6k
Fork
1.7k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
46

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenMathLib/OpenBLAS

Tất cả issue của OpenMathLib/OpenBLAS

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.