Bug 242995 - [patch] cad/calculix-ccx: Enable multithreading with spooles
Summary: [patch] cad/calculix-ccx: Enable multithreading with spooles
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Pedro F. Giffuni
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-30 22:04 UTC by rsmith
Modified: 2020-01-04 20:36 UTC (History)
1 user (show)

See Also:
pfg: maintainer-feedback+


Attachments
Patch to enable multithreading in ccx when using spooles. (715 bytes, patch)
2019-12-30 22:04 UTC, rsmith
no flags Details | Diff
Enable multithreading + pkg-descr note (1.46 KB, patch)
2019-12-31 01:15 UTC, Pedro F. Giffuni
no flags Details | Diff
Disable taucs but enable multithreading (2.26 KB, patch)
2019-12-31 16:26 UTC, Pedro F. Giffuni
no flags Details | Diff
Disable taucs but enable multithreading (2.85 KB, patch)
2020-01-04 19:25 UTC, Pedro F. Giffuni
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rsmith 2019-12-30 22:04:33 UTC
Created attachment 210340 [details]
Patch to enable multithreading in ccx when using spooles.

Up to now, ccx uses only one core when factoring the systems of equations using the spooles solver.                                                                              
                                                                                                        
For spooles to use multiple threads, -DUSE_MT=1 needs to be added to CFLAGS when building calculix-ccx.

The included patch adds -DUSE_MT=1 to CFLAGS in the Makefile for ccx.

For a system of 161448 equations, this reduces the runtime from 25.76 s to 22.54 s on a Core i7-7700 CPU. (This is with the environment variable 
OMP_NUM_THREADS set to 4, since this CPU has 4 physical cores and I have 
disabled hyperthreading.)

Record of the tests as per the porters handbook:

    > make stage
    ...
    <build output removed for brevity>
    ...
    ===>  Staging for CalculiX-ccx-2.16
    ===>   CalculiX-ccx-2.16 depends on executable: gfortran9 - found
    ===>   CalculiX-ccx-2.16 depends on executable: gcc9 - found
    ===>   Generating temporary packing list
    <build output removed for brevity>
    ====> Compressing man pages (compress-man)

    > make stage-qa
    ====> Running Q/A tests (stage-qa)

    > make package
    ===>  Building package for CalculiX-ccx-2.16

    # make install
    ===>  Installing for CalculiX-ccx-2.16
    ===>  Checking if CalculiX-ccx is already installed
    ===>   Registering installation for CalculiX-ccx-2.16
    Installing CalculiX-ccx-2.16...

    # make deinstall
    ===>  Deinstalling for CalculiX-ccx
    ===>   Deinstalling CalculiX-ccx-2.16
    Updating database digests format: 100%
    Checking integrity... done (0 conflicting)
    Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

    Installed packages to be REMOVED:
        CalculiX-ccx-2.16

    Number of packages to be removed: 1

    The operation will free 78 MiB.
    [1/1] Deinstalling CalculiX-ccx-2.16...
    [1/1] Deleting files for CalculiX-ccx-2.16: 100%

The port builds, installs and runs fine.
I've seen no significant difference in the calculated results compared to the current port and 2.15.
Tests performed on FreeBSD 12.1-STABLE r354569 GENERIC amd64.
Comment 1 Pedro F. Giffuni freebsd_committer 2019-12-31 01:15:28 UTC
Created attachment 210344 [details]
Enable multithreading + pkg-descr note
Comment 2 Pedro F. Giffuni freebsd_committer 2019-12-31 01:17:23 UTC
Approved as maintainer: I made some other minor enhancements too.
CC mentor
Comment 3 Pedro F. Giffuni freebsd_committer 2019-12-31 16:26:40 UTC
Created attachment 210358 [details]
Disable taucs but enable multithreading

Since there are bugs reported with the taucs option I will drop it for this release. It makes the ccx package lighter.
Comment 4 rsmith 2019-12-31 23:33:29 UTC
(In reply to Pedro F. Giffuni from comment #3)

I just tested CalculiX-ccx-2.16_1 on several of my FEA calculations, and it works fine.

As expected, the output is functionally identical to that of the previous version.
Comment 5 Thierry Thomas freebsd_committer 2020-01-04 17:44:33 UTC
Approved (as mentor), excepted that I think that the message

"Spooles option: by default the single-threaded solver is used unless you
set the CCX_NPROC_EQUATION_SOLVER environment variable with the number of
cores you want to use."

would be better as a pkg-message. Do not write in pkg-descr after the WWW line.
Comment 6 Pedro F. Giffuni freebsd_committer 2020-01-04 19:25:08 UTC
Created attachment 210451 [details]
Disable taucs but enable multithreading

Hmm .. I had forgotten about pkg-message. Thanks!
Comment 7 commit-hook freebsd_committer 2020-01-04 20:34:15 UTC
A commit references this bug:

Author: pfg
Date: Sat Jan  4 20:34:10 UTC 2020
New revision: 522059
URL: https://svnweb.freebsd.org/changeset/ports/522059

Log:
  cad/calculix-ccx: Enable multithreading with spooles.

  Enabling the multithreaded version of Spooles can bring some modest, but
  significant, improvements of around 12% for 4 CPUs.

  Also disable (again) the Taucs slover as it is causing coredumps and
  requires more investigation.

  PR:	242995
  Approved by:	thierry (mentor)

Changes:
  head/cad/calculix-ccx/Makefile
  head/cad/calculix-ccx/files/patch-Makefile
  head/cad/calculix-ccx/pkg-descr
  head/cad/calculix-ccx/pkg-message