1
$\begingroup$

Let's consider the following functions (in $Version: 12.3.0 for Linux x86 (64-bit) (May 10, 2021))

f1=Compile[{{arg,_Integer}},Module[{output=0},output+=arg*10;output],CompilationTarget->"C"];
f2=FunctionCompile[Function[{Typed[arg,"Integer64"]},Module[{output=0},output+=arg*10;output]]];
f3=FunctionCompile[Function[{Typed[arg,TypeSpecifier["NumericArray"]["Integer64",1]]}, 
    Module[{output=0},output+=Length[arg]*10;output]]];

I want write new functions with above functions as external definitions (as below)

g1=FunctionCompile[Function[{Typed[arg,"Integer64"]},Module[{output=0},output+=f1[arg]*10;output]]];
g2=FunctionCompile[Function[{Typed[arg,"Integer64"]},Module[{output=0},output+=f2[arg]*10;output]]];
g3=Compile[{{arg,_Integer,1}},Module[{arg1,output=0},arg1=NumericArray[arg,"Integer64"]; 
    output+=f3[arg1]*10;output],CompilationTarget->"C"];

The g functions are giving compilation error

Compile::err: TypeError. Cannot find a definition for the function CompiledFunction[Argument count: 1
Argument types: {_Integer}

] that takes an argument with the type Integer64.

Compile::err: TypeError. Cannot find a definition for the function CompiledCodeFunction[Signature: {Integer64}->Integer64] that takes an argument with the type Integer64.

Compile::cset: Variable output of type {_Integer,0} encountered in assignment of type {_Integer,1}.

Compile::cset: Variable output of type {_Integer,0} encountered in assignment of type {_Integer,1}.

However, the following function, is working fine.

g4=Compile[{{arg,_Integer}},Module[{output=0},output+=f2[arg]*10;output],CompilationTarget->"C"];

Could anyone let me know if there is any particular way, this (external call) could be achieved?

$\endgroup$
1
  • $\begingroup$ If you guarantee that f1 and f2 are present in the kernel when you evaluate g1 and g2 respectively, you can use KernelFunction. $\endgroup$
    – Ben Izd
    Jan 13, 2023 at 16:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.