Difference between revisions of "GPU621/Intel oneMKL - Math Kernel Library"
(→MKL Testing) |
|||
Line 41: | Line 41: | ||
MKL version<br /> | MKL version<br /> | ||
+ | Used to set the number of threads that MKL runs, mkl_set_num_threads(). <br /> | ||
max_threads = mkl_get_max_threads(); | max_threads = mkl_get_max_threads(); | ||
Line 64: | Line 65: | ||
https://raw.githubusercontent.com/MenglinWu9527/m3u/main/Snipaste_2021-12-01_00-20-37.jpeg | https://raw.githubusercontent.com/MenglinWu9527/m3u/main/Snipaste_2021-12-01_00-20-37.jpeg | ||
− | {| | + | {| border="1" cellspacing="0" cellpadding="5" align="center" |
! serial | ! serial | ||
! 1 | ! 1 | ||
Line 95: | Line 96: | ||
|} | |} | ||
− | Here is my computer's number of logical processors.</ | + | Here is my computer's number of logical processors.<br /> |
− | wmic:root\cli>cpu get numberoflogicalprocessors | + | wmic:root\cli>cpu get numberoflogicalprocessors |
NumberOfLogicalProcessors | NumberOfLogicalProcessors | ||
− | 6 | + | 6 <br /> |
+ | |||
+ | When mkl_get_max_threads is equal to the number of physical cores, the performance is the best, not the number of threads, which is the following 3 instead of 6. <br /> | ||
+ | |||
==References== | ==References== | ||
references | references |
Revision as of 00:35, 1 December 2021
Contents
Intel® oneAPI Math Kernel Library
Group Members
- Menglin Wu
- Syed Muhammad Saad Bukhari
- Lin Xu
Introduction
Intel Math Kernel Library, or now known as oneMKL (as part of Intel’s oneAPI), is a library of highly optimized and extensively parallelized routines, that was built to provide maximum performance across a variety of CPUs and accelerators.
There are many functions included in domains such as sparse and dense linear algebra, sparse solvers, fast Fourier transforms, random number generation, basic statistics etc., and there are many routines supported by the DPC++ Interface on CPU and GPU.
Progress Report
progress 100%
Setting up MKL
First, you need to download the mkl library from the intel official website through the URL: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html
Then you need to set additional include directories and additional library directories on visual studio, don’t forget to change the configuration and platform.
Finally, modify the additional dependencies with the help of the URL https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
MKL Testing
In this project I want to compare the running time of the serial version and the optimized version of MKL under multithreading.
serial version
clock_t startTime = clock();
for (r = 0; r < LOOP_COUNT; r++) { for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { sum = 0.0; for (k = 0; k < p; k++) sum += A[p * i + k] * B[n * k + j]; C[n * i + j] = sum; } } }
clock_t endTime = clock();
MKL version
Used to set the number of threads that MKL runs, mkl_set_num_threads().
max_threads = mkl_get_max_threads();
printf(" Finding max number %d of threads Intel(R) MKL can use for parallel runs \n\n", max_threads);
printf(" Running Intel(R) MKL from 1 to %i threads \n\n", max_threads * 2); for (i = 1; i <= max_threads * 2; i++) { for (j = 0; j < (m * n); j++) C[j] = 0.0;
mkl_set_num_threads(i);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p, alpha, A, p, B, n, beta, C, n);
s_initial = dsecnd(); for (r = 0; r < LOOP_COUNT; r++) { cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p, alpha, A, p, B, n, beta, C, n); } s_elapsed = (dsecnd() - s_initial) / LOOP_COUNT;
https://raw.githubusercontent.com/MenglinWu9527/m3u/main/Snipaste_2021-12-01_00-20-37.jpeg
serial | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1500 | 15.7 | 7.7 | 6.4 | 8.1 | 7.4 | 7.5 | 8.0 | 7.9 | 7.2 | 7.5 | 7.2 | 8.0 | 8.0 |
Here is my computer's number of logical processors.
wmic:root\cli>cpu get numberoflogicalprocessors
NumberOfLogicalProcessors
6
When mkl_get_max_threads is equal to the number of physical cores, the performance is the best, not the number of threads, which is the following 3 instead of 6.
References
references