This example shows how to perform concurrent execution of a model on xPC Target. It displays the execution of each model thread using the xPC Target profiling tool.
Boot the target computer with the xPC Target™ real-time kernel.
At the MATLAB command prompt, type dxpcmdsdemo to download and run the model on the target computer.
Open the model dxpcmds6tdxpcmds6t (see Figure 1). The model is mapped to 7 threads (Model1_R1, Model1_R2, Model1_R3, Model1_R4, Model2_R1, Model2_R3, and Model2_R4) running at sample times of 0.001s, 2*0.001s, 3*0.001s, 4*0.001s, 0.001s, 3*0.001s and 4*0.001s respectively.
Figure 1: A Model Comprised of Six Tasks
Figure 2: Three Tasks in Model1
Figure 3: Three Tasks in Model2
xpctargetping; set_param(mdl,'RTWVerbose','off'); rtwbuild(mdl); tg = xpc; tg.load(mdl); tg.SampleTime = 0.01; tg.StopTime = 0.2; tg.start; pause(2); tg.stop;
The profiling data shows the execution time of each thread on a 4 core xPC target
profileInfo.modelname = 'dxpcmds6t.mdl'; profileInfo.noreport = 0; profData = profile_xpc(profileInfo);
Copying data from target machine, please wait ... Processing data, please wait ...
Figure 5: Plot of Recorded Profiling Data
close_system(mdl,0); close_system('dxpcmds_ref1',0); close_system('dxpcmds_ref2',0);