필터 지우기
필터 지우기

Conversion of argument from "real_T *" to "int" not possible error in matlab

조회 수: 1 (최근 30일)
Hi,
I am working on integrating GPU coder into simulink. For the entry point function I am using state space equation.Next I am generating the dll using codegen and I have defined coder.externalDependancy API to link dll. Next I created a simulink model for state space equation. When I run the Simulink model, I am getting following error:
Conversion of argument from "real_T *" to "int" not possible error in matlab
The code for generating dll is :-
a = coder.typeof(zeros(10000,10000),[]);
b = coder.typeof(zeros(10000,10000),[]);
c = coder.typeof(zeros(10000,10000),[]);
d = coder.typeof(zeros(10000,10000),[]);
x = coder.typeof(zeros(10000,1),[]);
u = coder.typeof(zeros(10000,1),[]);
Ts = double(TS);
Tr = double(TR);
cfg = coder.gpuConfig('dll');
codegen -args {a,b,c,d,x,u,Ts,Tr} -config cfg State_Space_Eqn
TS and TR are user defined inputs.
For the conversion of TS and TR , I am getting this error. I think I am defining Ts and Tr wrong for the code generation.
Can you please help me with it?
Thank You
  댓글 수: 3
James Tursa
James Tursa 2020년 4월 24일
편집: James Tursa 2020년 4월 24일
I still don't see TS and TR defined anywhere. Are these supposed to be the same as Ts and Tr?

댓글을 달려면 로그인하십시오.

채택된 답변

Ram Kokku
Ram Kokku 2020년 4월 25일
Hi Bhushan,
Can you provide sequence of steps that you followed to arrive at this point ?
From your question,
  1. It looks like code generation worked and you are able to generate DLL.
  2. to call this code from Simulink , you created a coder.externaldependency
  3. when you try to play the model, you see this error ?
Is my interpretation correct ? If so, lot me ask you few questions,
  1. How many inputs your S-function block expected to take 6 or 8 ?
  2. You mentioned TS and TR are in MATLAB workspace, are you trying to access these MATLAB variables from Simulink as well or you are creating inputs for these
  3. Error seems to be coming from some type conversion real_T * to int. this would have happen if S-function block is fed with wrong types, or a type of variable is not declared in advance and compiler made an assumption on the type
it would make solving your issue much easier if you could share your code - just the external dependency implementation and how you're using this block in Simulink.
  댓글 수: 2
Ram Kokku
Ram Kokku 2020년 4월 25일
Hello Bhushan,
thanks for sharing the code. The problem is with your coder.ceval call. GPU Coder generated function takes 9 argumements - 8 inputs and 1 output. However, you are calling the function with 7 argumements. You have to pass TS and TR to coder.ceval in the same order you generated code with.
Current code :
coder.ceval('State_Space_Equation', coder.rref(A), coder.rref(B),coder.rref(C),coder.rref(D),coder.rref(X),coder.rref(U), coder.wref(c));
change this to:
coder.ceval('State_Space_Equation', coder.rref(A), coder.rref(B),coder.rref(C),coder.rref(D),coder.rref(X),coder.rref(U), TS, TR, coder.wref(c));
This should resolve this issue.
I also notice you have following code in your function. what is the intension of it ?
c = coder.nullcopy(A);
c = coder.nullcopy(B);
c = coder.nullcopy(C);
c = coder.nullcopy(D);
c = coder.nullcopy(X);
c = coder.nullcopy(U);
I think just first statement should be enough.
For this example to work correctly, you need to change your simulation language to C++. If you have not done that already, take a look at this gug report for more information.
Bhushan Ravindra Attarde
Bhushan Ravindra Attarde 2020년 4월 25일
Hello, I will try this solution. I was calling the function with Coder.ceval(coder.rref(A), coder.rref(B),coder.rref(C),coder.rref(D),coder.rref(X),coder.rref(U), coder.rref(TS),coder.rref(TR), coder.wref(c)); I was using coder.rref for TS and TR too. I will check with your code.
Yes the first statement should be enough. But just to be more sure, I took other inputs too. I will remove other statements.
Also I have also changed the language of my simulation to c++. Unfortunately, I cannot check the solution right now, becuase i dont have system with me. I would be able to check it on monday morning once I go to university again.
I will check and let you know if my issue got resolved. Thank you for your time and valuable response.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by