Avoiding loading .mat files every time standalone exe is called
1 view (last 30 days)
Show older comments
I have a standalone exe (compiled using mcc) that loads a number of .mat files at the beginning of its execution and then does some work analzying data. I've placed this exe on a server to create a web service out of the program. The issue is that I start the exe for each request and each time the program has to load these .mat files, which is a significant amount of the total execution time.
Is there a good way to avoid this? My initial thought was to call the exe at server boot time and having it always running and waiting for new requests that it would get via continuously checking a log file (as it's tough to pass args to the standalone exe once it's already started running). The problem is that the work done on each request could take a number of minutes and would be blocking the web service during that time, so I'd like to spawn a new process each time that could do the work yet refer to those loaded .mat files.
Is this something that can be done using Matlab's Parallel Computing Toolbox? Can the features provided in the toolbox be used easily in a standalone application?
Thanks for your help.
0 Comments
Answers (2)
Walter Roberson
on 4 Apr 2014
Edited: Walter Roberson
on 4 Apr 2014
Consider having it get the requests via tcp or udp.
The Parallel Computing Toolbox is not able to spawn new processes in the form you want. You could, though, have a pool of processes in the form of SPMD labs, with the inactive labs waiting to be broadcast a message that told them what work to do.
I have never been clear as to what I/O is possible in the labs.
Image Analyst
on 4 Apr 2014
To determine if the app is running in the development environment or as a standalone app you check isdeployed :
if isdeployed
% It's a stand alone executable.
% Skip loading mat file.
else
% It's the MATLAB development environment
% Load the mat files
storedStructure = load(fullMatFileName1); %etc. for other mat files.
end
2 Comments
Image Analyst
on 5 Apr 2014
OK fine. So load the mat files when and where you want to. Just avoid loading them in the OpeningFcn function which gets run on startup because you said you don't want to load them upon startup. For example, load them when the user clicks a button or something.
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!