Parallel Computing Toolbox very Slow After Compilation

1 Ansicht (letzte 30 Tage)
Yaniv
Yaniv am 13 Nov. 2013
Bearbeitet: Prateekshya am 9 Okt. 2024
Hi There Matlab team,
I have a code using parfor (PCT). It runs very efficiently when ran from within matlab (each thread uses 20% of cpu) but very slow when ran after compilation using matlab compiler (each thread uses 1% of cpu)
any ideas what might be the problem
thanks in advance yaniv

Antworten (1)

Prateekshya
Prateekshya am 9 Okt. 2024
Bearbeitet: Prateekshya am 9 Okt. 2024
Hello Yaniv,
The issue you are experiencing with the compiled MATLAB code using parfor (Parallel Computing Toolbox) and MATLAB Compiler might be due to several factors. Here are some potential causes and solutions to consider:
  • Parallel Pool Configuration: When running in MATLAB, the parallel pool is automatically managed. However, in a compiled application, you need to ensure that the parallel pool is correctly configured and started. Check if the compiled application is starting the parallel pool with the desired number of workers. You can explicitly specify the number of workers using parpool.
if isempty(gcp('nocreate'))
parpool('local', numWorkers); % Specify the number of workers
end
  • MATLAB Runtime Environment: Ensure that the MATLAB Runtime (MCR) is correctly installed and configured on the machine where you are running the compiled application. The MCR must match the version used for compilation.
  • Data Transfer Overhead: In a compiled application, there might be additional overhead in data transfer between the client and workers, especially if large data sets are involved. Ensure that data is efficiently partitioned and transferred.
  • Resource Allocation: Check if the compiled application has sufficient system resources (CPU, memory) allocated. The behavior might differ from the MATLAB environment, where resource allocation is typically more straightforward.
  • Code Optimization: Review your code for any operations that might behave differently or less efficiently in a compiled environment. Ensure that the code inside the parfor loop is optimized for parallel execution.
  • Licensing Issues: Verify that the necessary licenses for Parallel Computing Toolbox and MATLAB Compiler are available and correctly configured on the deployment machine.
  • Profiling and Debugging: Use MATLAB’s profiling tools to identify bottlenecks in the compiled code. You can also add logging to understand where the slowdown occurs.
  • Environment Variables: Check if there are any environment variables or system settings that might affect performance, such as thread affinity or power management settings on the deployment machine.
I hope this helps!

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by