← Back to team overview

dolfin team mailing list archive

[noreply@xxxxxxxxxxxxx: [Branch ~dolfin-core/dolfin/main] Rev 5282: Add PETScLUSolver option for number of threads to use.]

 

Nice!

--
Anders
--- Begin Message ---
------------------------------------------------------------
revno: 5282
committer: Garth N. Wells <gnw20@xxxxxxxxx>
branch nick: dolfin-all
timestamp: Wed 2010-11-17 15:49:02 +0000
message:
  Add PETScLUSolver option for number of threads to use.
  
  Number of threads can be specified. Defaults to number of threads set in global parameters.
  
  This work for the PaStiX LU solver, which can run multi-threaded. I see a good speed up on my pc using multiple threads.
modified:
  demo/undocumented/elasticity/cpp/main.cpp
  dolfin/la/PETScLUSolver.cpp
  dolfin/la/PETScPreconditioner.cpp


--
lp:dolfin
https://code.launchpad.net/~dolfin-core/dolfin/main

Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
To unsubscribe from this branch go to https://code.launchpad.net/~dolfin-core/dolfin/main/+edit-subscription
=== modified file 'demo/undocumented/elasticity/cpp/main.cpp'
--- demo/undocumented/elasticity/cpp/main.cpp	2010-09-01 22:16:43 +0000
+++ demo/undocumented/elasticity/cpp/main.cpp	2010-11-17 15:49:02 +0000
@@ -84,6 +84,7 @@
 
   // Read mesh and create function space
   Mesh mesh("gear.xml.gz");
+  //mesh = refine(mesh);
   Elasticity::FunctionSpace V(mesh);
 
   // Create right-hand side
@@ -136,11 +137,11 @@
   vtk_file << u;
 
   // Plot solution
-  plot(u, "Displacement", "displacement");
+  //plot(u, "Displacement", "displacement");
 
   // Displace mesh and plot displaced mesh
-  mesh.move(u);
-  plot(mesh, "Deformed mesh");
+  //mesh.move(u);
+  //plot(mesh, "Deformed mesh");
 
   return 0;
 }

=== modified file 'dolfin/la/PETScLUSolver.cpp'
--- dolfin/la/PETScLUSolver.cpp	2010-11-17 15:05:56 +0000
+++ dolfin/la/PETScLUSolver.cpp	2010-11-17 15:49:02 +0000
@@ -16,6 +16,7 @@
 #include <dolfin/common/NoDeleter.h>
 #include <dolfin/log/dolfin_log.h>
 #include <dolfin/main/MPI.h>
+#include <dolfin/parameter/GlobalParameters.h>
 #include "LUSolver.h"
 #include "PETScMatrix.h"
 #include "PETScVector.h"
@@ -52,6 +53,10 @@
 {
   Parameters p(LUSolver::default_parameters());
   p.rename("petsc_lu_solver");
+
+  // Number of threads per process for multi-threaded solvers
+  p.add<uint>("num_threads");
+
   return p;
 }
 //-----------------------------------------------------------------------------
@@ -130,16 +135,24 @@
   // Write a pre-solve message
   pre_report(A->down_cast<PETScMatrix>());
 
+  // FIXME: Check for solver type
   // Set number of threads if using PaStiX
-  //if (solver_type == "pastix" )
-  //  PetscOptionsSetValue("-mat_pastix_threadnbr", "8");
-
+  if (parameters["num_threads"].is_set())
+  {
+    // Use number of threads specified for LU solver
+    PetscOptionsSetValue("-mat_pastix_threadnbr", parameters["num_threads"].value_str().c_str());
+  }
+  else
+  {
+    // Use global number of threads
+    PetscOptionsSetValue("-mat_pastix_threadnbr", dolfin::parameters["num_threads"].value_str().c_str());
+  }
   //PetscOptionsSetValue("-mat_pastix_verbose", "2");
 
   // Solve linear system
-  tic();
+  //tic();
   KSPSolve(*_ksp, *_b.vec(), *_x.vec());
-  std::cout << "Time to solve linear system: " <<  toc() << std::endl;;
+  //std::cout << "Time to solve linear system: " <<  toc() << std::endl;;
 
   return 1;
 }
@@ -188,9 +201,9 @@
   if (lu_package == "default")
   {
     if (MPI::num_processes() == 1)
-      lu_package = "umfpack";
+      //lu_package = "umfpack";
       //lu_package = "mumps";
-      //lu_package = "pastix";
+      lu_package = "pastix";
     else
     {
       #if PETSC_HAVE_MUMPS

=== modified file 'dolfin/la/PETScPreconditioner.cpp'
--- dolfin/la/PETScPreconditioner.cpp	2010-08-25 20:18:59 +0000
+++ dolfin/la/PETScPreconditioner.cpp	2010-11-17 15:49:02 +0000
@@ -30,7 +30,7 @@
                               ("jacobi",           PCJACOBI)
                               ("sor",              PCSOR)
                               ("icc",              PCICC)
-                              ("hypre_amg",     PCHYPRE)
+                              ("hypre_amg",        PCHYPRE)
                               ("hypre_euclid",     PCHYPRE)
                               ("hypre_parasails",  PCHYPRE)
                               ("hypre_pilut",      PCHYPRE)


--- End Message ---