Why do I receive an error "Problem creating Accelerator MEX file for model 'X'." when I try to run accelerator mode for a model containing s-function (Simulink 2019b)?

25 views (last 30 days)
I have a model which includes some S-function blocks that requires certain libraries. This libraries are included in the "Code Generation > Custom Code" section and also in Simulation Target section.
When I try to run a simulation in Accelerator mode I obtain the following error:
-### Build procedure for model: 'SimApplSw' aborted due to an error.
Problem creating Accelerator MEX file for model 'SimApplSw'.
Caused by:
C:\Users\roccag\Desktop\AggregationModel_3_0\slprj\accel\SimApplSw\mathlib.c not found; check that you are in the correct current folder, and check the spelling of 'C:\Users\roccag\Desktop\AggregationModel_3_0\slprj\accel\SimApplSw\mathlib.c'.
Normal simulation runs correctly.
Thanks,
Giuseppe

Answers (1)

Shivani
Shivani on 4 Mar 2024
I understand that you’re currently facing an error while running a simulation in accelerator mode
The error you're experiencing is due to an attempt to optimize an accelerated Simulink model while the "UseParallel" flag is enabled in the optimization function. Since the model needs to be compiled for acceleration, any changes to the model will require the compiled code to be deleted and recompiled before the next simulation. When operating in parallel, multiple workers may try to delete and compile the same files at the same time, which can lead to the "Invalid argument" error you're seeing.
The following workarounds can get around this issue:
  1. Configure the model to operate in "Normal" mode rather than "Accelerated" mode.
  2. Avoid setting the "UseParallel" flag to true within the optimizer's settings.
Hope this helps!

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!