使用并行计算工具箱在已部署应用程序中
使用并行计算工具箱™的应用程序可以使用MATLAB中的集群概要文件®选择文件夹。要找到此文件夹,请使用prefdir
.
例如,当您创建一个独立的应用程序时,您的集群配置文件管理器将在应用程序中可用。
应用程序还可以使用外部文件中给出的集群配置文件。为了让你的应用程序使用这个文件,你可以:
链接到代码中的文件。
在运行时传递文件的位置。
导出集群配置文件
使用实例导出集群配置文件到外部文件。
在“Home”选项卡中环境部分中,选择平行>创建和管理集群.
在集群配置文件管理器对话框,选择一个概要文件,然后在管理部分中,点击出口.
链接到并行计算工具箱代码中的配置文件
要使应用程序能够使用外部文件中给出的集群配置文件,可以从代码中链接到该文件。在本例中,您将使用绝对路径、相对路径和MATLAB搜索路径链接到集群概要文件。注意,由于每个链接都是在编译之前指定的,所以必须确保每个链接都不会更改。
要为应用程序设置集群配置文件,可以使用setmcruserdata
函数。
由于MATLAB首选项文件夹是与应用程序捆绑在一起的,因此到文件夹内文件的任何相对链接都将始终有效。在应用程序代码中,可以使用myClusterProfile.mlsettings
在MATLAB首选项文件夹中找到的文件。
mpSettingsPath = fullfile(predir,“myClusterProfile.mlsettings”);setmcruserdata (“ParallelProfile”, mpSettingsPath);
fullfile
给出外部文件的绝对路径。给出的论证mpSettingsPath
必须为绝对路径。如果你的应用程序的用户在他们的文件系统上有一个绝对路径不会改变的集群配置文件,直接链接到它:mpSettingsPath =“/道路/ / myClusterProfile.mlsettings”;setmcruserdata (“ParallelProfile”, mpSettingsPath);
mpSettingsPath = fullfile(pwd,“. . / rel /道路/ / myClusterProfile.mlsettings ');setmcruserdata (“ParallelProfile”, mpSettingsPath);
哪一个
获取集群配置文件的绝对路径。然后,链接到它。mpSettingsPath = which(“myClusterProfile.mlsettings”);setmcruserdata (“ParallelProfile”, mpSettingsPath);
世纪挑战集团——一个/ / myClusterProfile.mlSettings /路径- mmyApp.m;
/ /路径
到你的MATLAB搜索路径。
通过并行计算工具箱运行时的概要
如果您的应用程序的用户myApp
具有在运行时选择的集群配置文件,您可以在命令行中指定此配置文件。
myApp -mcruserdata ParallelProfile:/path/to/myClusterProfile.mlsettings |
注意,当您使用setmcruserdata
函数的使用,则重写-mcruserdata
国旗。
在部署的应用程序中切换集群概要文件
当你使用setmcruserdata
功能,则删除了使用集群配置文件管理器中可用的任何配置文件的能力。中配置文件的使用集群配置文件管理器,使用parallel.mlSettings
文件。
mpSettingsPath =“/道路/ / myClusterProfile.mlsettings”;setmcruserdata (“ParallelProfile”, mpSettingsPath);%一些应用程序代码origSettingsPath = fullfile(predir,“parallel.mlsettings”);setmcruserdata (“ParallelProfile”, origSettingsPath);%更多应用程序代码
加载集群配置文件的C代码示例
你可以致电mcruserdata
函数在C和c++应用程序中生成MATLAB编译SDK™.
mxArray *key = mxCreateString("ParallelProfile");mxArray *value = mxCreateString("/path/to/myClusterProfile.mlsettings");如果(!setmcruserdata(key, value)) {fprintf(stderr, "无法设置MCR用户数据:\n %s ", mclGetLastErrorMessage());返回1;} |
另请参阅
相关的话题
- 使用MATLAB运行时用户数据接口
- 在.NET应用程序中指定并行计算工具箱配置文件(MATLAB编译器SDK)
- 在Java应用程序中指定并行计算工具箱配置文件(MATLAB编译器SDK)