Unrecognized function or variable 'gcp' in compiled stand alone application

Hi,
Compiling via mcc i get the following error at runtime (m2022a).
Is there a specific options or compile directive to ensure the paralell toolbox is included in the standalone application?
Unrecognized function or variable 'gcp'.
Error in MatlabThreads.Helper.StartThreadPool (line 28)
'gcp' may have been excluded from the MATLAB search path at compilation due to misuse of the path related mcc flags (-N, -p, -I).
Have the application owner verify that these flags were correctly used.
Contact the application owner for more details.
Thanks

1 件のコメント

LP
LP 2022 年 8 月 24 日
I note parpool is also "not found" in the standalone compiled application

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2022 年 8 月 24 日
移動済み: Walter Roberson 2022 年 8 月 24 日

0 投票

Notice that the documentation for gcp does not have any Extended Capabilities section. It might not be available in compiled executables.
Instead record the output of the call that creates the pool and use that variable.

4 件のコメント

LP
LP 2022 年 8 月 24 日
Thanks Walter,
I'm trying to avoid using a persistent variable, or global variable, to allow many different components access to the same pool without passing around the parpool object.
If this is correct, then i ahve no other way of implementing a general pool for all modules without use of one of the methods above. Just a bit annoying given that Matlab actually suggests using gcp interactively
>> x = parpool('local')
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).
x =
ProcessPool with properties:
Connected: true
NumWorkers: 6
Busy: false
Cluster: local
AttachedFiles: {}
AutoAddClientPath: true
FileStore: [1x1 parallel.FileStore]
ValueStore: [1x1 parallel.ValueStore]
IdleTimeout: 30 minutes (30 minutes remaining)
SpmdEnabled: true
>>
>> x = parpool('local')
Error using parpool
Found an interactive session. You cannot have multiple interactive sessions open simultaneously. To terminate the existing session, use delete(gcp('nocreate')).
Thanks, Lyle
Walter Roberson
Walter Roberson 2022 年 8 月 24 日
You could attach the pool as UserData to a figure, but that is effectively the same as a global variable.
You could create a static member of a handle class, but that is effectively the same as a persistent variable.
LP
LP 2022 年 8 月 24 日
1/ Code is backend server so no figures but nice idea.
2/ I avoid handle classes ( and "try catch" ) at all costs because of exactly this reason, it leads to poor code.
Parpool is a handle class but if you loose the ptr you loose the object, yet the object "lives on" and throws errors if you try construct a new object.
Without gcp, there is no way to get the old pointer back to my knowledge.
I've implemented a persistent variable
function myPool = StartThreadPool( method , pooltimeout)
% myPool = StartThreadPool( method , pooltimeout )
% Start a pool or use the existing one
persistent pool_cache
if nargin < 1 || isempty( method )
method = 'localpool';
end
if nargin < 2 || isempty( pooltimeout )
pooltimeout = 120;
end
%% Use Cache if we can
if ~isempty( pool_cache ) && pool_cache.myPool.Connected
if strcmp( pool_cache.method, method)
myPool = pool_cache.myPool;
return
else
pool_cache.myPool.delete;
end
end
pool_cache = [];
%% New Pool Required
switch(method)
case 'threads'
myPool = parpool('threads');
case 'localpool'
myPool = parpool('local', 'IdleTimeout', pooltimeout );
otherwise
logInLiger( sprintf( '%-25s :: Unrecognized method = %s',mfuncname, method) );
end
% Cache For Later
pool_cache.method = method ;
pool_cache.myPool = myPool ;
end
Walter Roberson
Walter Roberson 2022 年 8 月 24 日
Well if a persistent or global variable is not acceptable then I guess your next option would be to reimplement in a different programming language.

サインインしてコメントする。

Ed Mitchell
Ed Mitchell 2022 年 8 月 24 日

0 投票

I would not expect you to need a specific flag to include gcp. I put together a super simple code example:
if(isempty(gcp('nocreate')))
parpool('threads')
end
parfor i=1:10
disp(rand(10))
end
delete(gcp);
and compiled it with:
mcc -m SimpleThreadPoolCompiler.m
When I run it from the command prompt, it works without issue. If you compile this simple example and attempt to run it, do you hit the same error?

カテゴリ

ヘルプ センター および File ExchangeParallel Computing Fundamentals についてさらに検索

製品

リリース

R2022a

質問済み:

LP
2022 年 8 月 24 日

回答済み:

2022 年 8 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by