Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xsyrk vs xxsyrk vs dsyrk (in netlib LAPACK) #2405

Open
ajay-fuji opened this issue Jun 5, 2023 · 5 comments
Open

xsyrk vs xxsyrk vs dsyrk (in netlib LAPACK) #2405

ajay-fuji opened this issue Jun 5, 2023 · 5 comments

Comments

@ajay-fuji
Copy link
Contributor

Hi,

In the mkl function call, I have seen two types of call of same basic function, prefixed with x and xx .e.g, xsyrk and xxsyrk.
What is difference between these two type of functions and how is it different from function implementation in netlib LAPACK or OpenBLAS.

@Alexsandruss
Copy link
Contributor

Reading MklLapack code you can find xx functions set number of threads to 1 locally:

template <CpuType cpu>
struct MklLapack<double, cpu>
{
    typedef DAAL_INT SizeType;

    static void xgetrf(DAAL_INT * m, DAAL_INT * n, double * a, DAAL_INT * lda, DAAL_INT * ipiv, DAAL_INT * info)
    {
        __DAAL_MKLFN_CALL(lapack_, dgetrf, (m, n, a, lda, ipiv, info));
    }

    static void xxgetrf(DAAL_INT * m, DAAL_INT * n, double * a, DAAL_INT * lda, DAAL_INT * ipiv, DAAL_INT * info)
    {
        int old_threads = fpk_serv_set_num_threads_local(1);
        __DAAL_MKLFN_CALL(lapack_, dgetrf, (m, n, a, lda, ipiv, info));
        fpk_serv_set_num_threads_local(old_threads);
    }
...
}

@ajay-fuji
Copy link
Contributor Author

ajay-fuji commented Jun 8, 2023

Thankyou @Alexsandruss for your response.
I still have two questions,

  1. Why xx.. version of function set number of local thread to 1. What are the cases when this function will be used?
  2. I can see xxgemm function call
    static void xxgemm(const char * transa, const char * transb, const DAAL_INT * p, const DAAL_INT * ny, const DAAL_INT * n, const double * alpha,
    doesn't set thread number to 1 but instead call a different function xdgemm. Please comment on this.

Thanks!

@Braza
Copy link

Braza commented Feb 19, 2024

@ajay-fuji is this still a pressing issue?

@ajay-fuji
Copy link
Contributor Author

I still want to understand reason behind setting local threads to 1 in one case (xx) not in other case.

@icfaust
Copy link
Contributor

icfaust commented Oct 1, 2024

@ajay-fuji Sorry for answering this almost a year later:

It looks like to me that in cases that routines are already multithreaded, they want to limit the number of threads taken by the blas/lapack calls to match the thread that called it. An example is: in svd there is
https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/svd/svd_dense_default_batch_impl.i#L347
which in the multithread calls compute_QR_on_one_node_seq:
https://github.com/oneapi-src/oneDAL/blob/main/cpp/daal/src/algorithms/qr/qr_dense_default_impl.i#L110
which uses xx* calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants