Replies: 12 comments 6 replies
-
You would have to change Suppose that the function fg can be expressed as the sum of functions that can be evaluated on different threads. Then you should be able to tape them on separate threads and express the derivatives as a sum of derivatives that are evaluated on different threads. |
Beta Was this translation helpful? Give feedback.
-
For example, suppose that the objective function is the log likelihood for independent data samples. Then the object might be huge sum where the only difference between elements of the sum is the data value. You might spit the sum up into different threads. After the threads complete, you would then sum the result for each thread. |
Beta Was this translation helpful? Give feedback.
-
Have you looked at the following documentaiton ? For openmp, you may find the following helpful: |
Beta Was this translation helpful? Give feedback.
-
I am trying to parallelize IPOPT optimization tasks using OpenMP and CppAD. I have set up the parallel environment according to the CppAD OpenMP example, but when I replace the worker function with an IPOPT model, I get the following error:
The problem seems to occur when I use an IPOPT model in the worker function. If I replace the IPOPT model with a simple CppAD model, the parallelization works fine. So it seems that the issue is specifically with IPOPT when used in a parallel context. Here's the function I'm using as my worker function (replacing the worker function from the CppAD OpenMP example):
Many thanks! |
Beta Was this translation helpful? Give feedback.
-
@Mingze-Li128 It looks like this is a short example. Would you please include the other code so that I can try and reproduce the error. |
Beta Was this translation helpful? Give feedback.
-
I replaced the worker function in with the code above and got the following error when I tried to compile it:
I could try to just fix this, but I want to be sure I have the exact same code as you. What should I do ? |
Beta Was this translation helpful? Give feedback.
-
OK, I put the
and the definition of FG_eval in before the problem_specific definition. I also added
to the target link libraries in Now the program compiles and links, but I get the following error when I try to run
When I run in the debugger I get
|
Beta Was this translation helpful? Give feedback.
-
It looks to me like we have some work to do to get this example to work. I am busy with other things right now. Perhaps you can strip out the CppAD stuff and see if you can get a multi-threading ipopt example to work. Then we can work on adding the CppAD stuff to it. P.S. |
Beta Was this translation helpful? Give feedback.
-
Have there been any updates on this bug? Based on your previous recommendation, I tested a multi-threaded Ipopt example, and it functioned correctly. However, upon examining solve_callback.hpp, I noticed the presence of a Dependent function. According to your documentation at https://coin-or.github.io/CppAD/doc/multi_thread.htm, this function might not be thread-safe. Could this be the cause of the bug I previously mentioned? If so, does this imply that cppad::ipopt cannot be utilized in a multi-threaded environment? Are there any potential workarounds or solutions to this issue? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the heads up. I am going to check all of the FIRST_CALL_NOT_PARALLEL cases and make sure they are called by |
Beta Was this translation helpful? Give feedback.
-
I fixed ad_parallel so that it initializes all the routines with FIRST_CALL_NOT_PARALLEL and has better documentation; see the changes to parallel_ad in I tested the case above with the new master and got the same error:
|
Beta Was this translation helpful? Give feedback.
-
I had to change two of the includes above as follows:
I then compiled the program with debugging. Here is the script I used:
This script used the version of ipopt retrieved by I got some Ipopt trace output mixed in with the following error messages:
The error messages were not consistent, in fact one time the script ran without detecting an error. It looks to me like there is something special that needs to be done to use MUMPS with openmp. I think you are using a different solver, so perhaps it does not have this problem. Perhaps you can reproduce the error message I got above ? |
Beta Was this translation helpful? Give feedback.
-
I noticed a page in the CPPAD guide introducing how to use cppad in openmp environment (https://cppad.readthedocs.io/en/latest/simple_ad_openmp.cpp.html). I wonder if this multi threading technique can also be applied in the ipopt solve example, to accelerate the solving speed? How can I do that?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions