Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Boris_Sunik
Beginner
358 Views

mkl_progress with parallely running calculations

I have many matrixes to solve. My  intention is to do it in a multithreading application where every matrix is solved by its dedicated thread. 

As I understand, the mkl library has to support the parallel calculations, because each matrix has its own handle. 

My quesion is how can I differ between different threads in the  mkl_progress()  ?

Thanks in advance

Boris

 .

0 Kudos
10 Replies
Boris_Sunik
Beginner
358 Views

Hello all,

I didn't get the answer during the past week, probably my question wasn't understood, hence I try to explain it in other words.

I have several matrix, which I want to solve with PARDISO linear solver. My intent is to start the solving process simultaneously, each invocation of . PARDISO solver in its own thread, which I start in the calling application. As I understand, it has to be possible, because each matrix has its own _MKL_DSS_HANDLE_t handler.

Furhtermore, I want to use mkl_progress() for interrupting the calculation of a particular matrix. In order to do it, I need to find out, with which matrix this function is just invocated. It seems that the ithr pointer is irrelevant in this issue.  My questions are:

  • It is possible to to solve many matrixes simultaneously?
  • Can mkl library start further threads for a single matrix solved in such a way?
  • If parallel solution of several matrix is possible, how can I differ between different invocations of the PARDISO solver?    

I hope on your answer?

Boris

 

Ying_H_Intel
Employee
358 Views

Hi Boris,

The first question seems easy to answer.

Yes, it is possible to solve many matrixes simultaneously.  

But the second question regarding mkl_progress() is a little complex as the thread schedule is not controled by developers, so it is hard to differ the invocation. But i guess,  it is still doable as  generally, thread should be able to provide the interface to return itself status, then we may add such status into mkl_progress().

How do you thread your application? could you provide a exact implementation, then we may try to add such information to mkl_progress()?

Best Regards,

Ying

P.S Here is one discussion on call dss in pthread for your reference   

http://software.intel.com/en-us/forums/topic/404629

Boris_Sunik
Beginner
358 Views

I start the normal window thread with AfxBeginThread(). Currently I start calculation threads  from a non-main thread , but I can change the starting thread to the main thread wenn necessary. All calls of mkl routines occur in the same calculation thread. 

I see that if ithr pointer in mkl_progress is null this routine is called from the same thread. What have I to do when lhtr pointer gets non-zero value?

Ying_H_Intel
Employee
358 Views

Hi Boris,

Could you please attach one test case so we can investigate it specifically?   

Best Regards,

Ying

Boris_Sunik
Beginner
358 Views

I uploaded the file fragment.

startCalculation() starts start_calculation_task() for a single matrix. Other code is your standard example

 

358 Views

Hi Boris,

Let me answer your questions in some more details:

1) As Ying mentioned, it's Ok to solve a few matrices simultaneously by MKL PARDISO/DSS. You only need own data structures for PARDISO in each thread.

2) Indeed, this question is tricky. You call MKL from different Windows threads. So, you may force MKL to not generate more threads if:

     - link with sequential version of MKL library.

     - set MKL_NUM_THREADS or OMP_NUM_THREADS variables to 1.

     Otherwise, MKL will create as much threads as possible per your own thread (the number of threads will be equal to the number of physical cores or equal to the values of variables specified above).

3) Unfortunately, there's no way to distinguish from which Windows thread MKL PARDISO is called. It will always return ithr equal to 0 (it's so because MKL does not understand from which Windows thread you called it. It only knows the number of OpenMP threads inside MKL. And MKL PARDISO always reports progress from OpenMP thread number 0 ).

Best regards,

Konstantin

Boris_Sunik
Beginner
358 Views

MKL PARDISO always report progress from OpenMP thread number 0. If this is the same thread from which I call mkl then I can get it  in mkl_progress() with GetCurrentThread()? Am I right?

If above assumpiton is wrong then two further questions:

  • Do you plan to extend mkl_progress in future releases?
  • If not, can I call certain threads with MKL_NUM_THREADS==1 and other thread(s) with other values  of this variable?

 

Zhang_Z_Intel
Employee
358 Views

Note that OpenMP threads are different than Windows threads. Function GetCurrentThread() gives you the thread ID of the calling Windows thread, which has nothing to do with OpenMP threads. It is not clear how you plan to use PARDISO. For example, do you call PARDISO from each Windows thread? Or, do you call PARDISO from only one Windows thread? Also, do you intend to use sequential PARDISO or parallel PARDISO? If it's parallel PARDISO then MKL will spawn OpenMP threads, in addition to existing Windows threads. Depends on your situation, this may or may not be what you want.

We will extend mkl_progress if there are reasonable customer requirements and if we believe it can bring value to our customers.Please be specific about what kind of extension you have in mind.

It is possible to set different values of MKL_NUM_THREADS for different user threads, by using the function "mkl_set_num_threads_local". See the documentation of it here: http://software.intel.com/en-us/node/471138

Boris_Sunik
Beginner
358 Views

I start calculation by producing a thread with the handler-function "caclulate()". This function consequently invokes

dss_create(), dss_define_structure() etc.

the next matrix will start yet further thread.

My idea ist that if have a set of calculate()'s  thread  handlers I can identifiy the thread in mkl_progress()  by calling GetCurrentThread() and finding its hundler in my set. 

Am I right?

Zhang_Z_Intel
Employee
358 Views

My idea ist that if have a set of calculate()'s  thread  handlers I can identifiy the thread in mkl_progress()  by calling GetCurrentThread() and finding its hundler in my set. 

Am I right?

You can give it a try. It may work.

Reply