Code generation from matlab function using my own BLAS function
이전 댓글 표시
codegen is by default replacing multiplication with cblas_sgemm though the header file have fun definition with different name.
What is the correct approach. I want to replace maths operators with BLAS?
classdef ifxcallback < coder.BLASCallback
methods (Static)
function updateBuildInfo(buildInfo, ~)
buildInfo.addSourceFiles(fullfile(pwd,'BLAS','src.c'))
buildInfo.addIncludePaths(fullfile(pwd,'BLAS'));
end
function headerName = getHeaderFilename()
headerName = 'inc.h';
end
function intTypeName = getBLASIntTypeName()
intTypeName = 'int';
end
end
end
function p = useEnumNameRatherThanTypedef()
p = true;
end
댓글 수: 12
Ryan Livingston
2021년 3월 26일
MATLAB Coder expects to call a BLAS library with a CBLAS interface. Which BLAS library are you using and what is the name of the cblas_sgemm analog in that library?
anamika kumari
2021년 3월 26일
편집: anamika kumari
2021년 3월 26일
Ryan Livingston
2021년 3월 26일
Ah. Coder isn't going to find the updated name as it is expecting to find a standard CBLAS library which doesn't contain cblas_sgemm_f32. Can you update the name in your library to be cblas_sgemm or add a wrapper to provide the standard CBLAS interface:
http://www.netlib.org/blas/cblas.h
anamika kumari
2021년 3월 26일
anamika kumari
2021년 3월 30일
Ryan Livingston
2021년 3월 30일
MATLAB Coder may decide to use either cblas_sgemv or cblas_sgemm (I think it currently favors _sgemm) so the BLAS library would need to have both routines available.
anamika kumari
2021년 3월 31일
편집: anamika kumari
2021년 3월 31일
Ryan Livingston
2021년 4월 1일
We don't have an explicit list anywhere. The code that produces the BLAS calls is all under:
fullfile(matlabroot,'toolbox','eml','eml','+coder','+internal','+blas')
You'll see a bunch of MATLAB functions named similar to BLAS functions. Inside each you'll find the calls being used:
% Select BLAS function.
if isreal(C)
if isa(C, 'single')
fun = 'sgemm';
else
fun = 'dgemm';
end
else
if isa(C, 'single')
fun = 'cgemm';
else
fun = 'zgemm';
end
end
So using that, you should be able to extract the list.
Can I ask why you're developing the BLAS library and what hardware/target it's for? My expectation was that most hardware would have an existing BLAS library so I'm interested to hear what your team is working on.
anamika kumari
2021년 4월 5일
Ryan Livingston
2021년 4월 5일
Good to know. Thanks for the info.
Those are the BLAS functions being called via the CustomBLASCallback interface as of right now. I cannot confirm that if a new one is introduced it will also appear there. Being an internal directory, we assume that we're free to refactor at will. So that code may be moved, split, etc. in future releases.
If it would be helpful for you to have a curated list, I can put in an internal request to see if the teams would consider documenting such a list in the future. I can't promise it will be agreed to, but we could at least ask.
anamika kumari
2021년 4월 6일
anamika kumari
2021년 4월 20일
편집: anamika kumari
2021년 4월 21일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Algorithm Design Basics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!