Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
45

I used to implement everything myself, but lately have begun using libraries much more. I think there are several very important advantages of using a library, beyond just the issue of whether you have to write a routine yourself or not. If you use a library, you get Code that has been tested by hundreds/thousands/more users Code that will continue to be ...


34

There is substantial programmer overhead involved in linking to a library function, especially if that library is new to the programmer. It is often simpler to just rewrite simple algorithms rather than figure out the specifics of a particular library. As the algorithms become more complex this behavior switches. Python has excelled at reducing this ...


29

There are many more out there, all with different goals and views of the problems. It really depends on what you are trying to solve. Here is an incomplete list of packages out there. Feel free to add more details. Large Distributed Iterative Solver Packages PETSc — packages focused around Krylov subspace methods and easy switching between linear ...


26

First of all I wish to thanks Aron Ahmadia for pointing me to this thread. As for OpenCL in scientific code: OpenCL is meant to be a low-level API, thus it is crucial to wrap this functionality in some way in order to reach a reasonable productivity. Moreover, as soon as several compute kernels are involved, code can get VERY dirty if OpenCL kernel and ...


19

One of the projects I'm involved in right now is writing a flexible simulation and analysis package for a class of particle physics detectors. One of the goals of this project is to provide the code base to be used in these things for decades to come. At this point point we already have two dozen dependencies, making the build process such a nightmare that ...


18

MKL (from Intel) is optimized for Intel processors, and probably has the "upper hand" there in many cases. But it is also "famous" for choosing the "worst" code-paths for AMD processors, as described here.


15

You should probably start with the LAPACK implementation, ?gtsv, e.g., dgtsv. If you want a distributed-memory version, then you might want to start with ScaLAPACK's p?gtsv. EDIT: Since your matrix does not change very often, you can avoid redundantly factoring the tridiagonal matrix by breaking up the LAPACK routine ?gtsv into the factorization step, ?...


15

If you're doing celestial mechanics over long time scales, using a classical Runge-Kutta integrator will not preserve energy. In that case, using a symplectic integrator would probably be better. Boost.odeint also implements a 4th-order symplectic Runge-Kutta scheme that would work better for long time intervals. GSL does not implement any symplectic methods,...


14

I would aim to get the best of both worlds and code the "user interface" (that is, the framework of functions that the user of your library will call to describe the geometry and other properties of the problem) in Python to get the quick turnaround time, then write the simulation run time in C++. In fact, I would probably mock even the simulation run time ...


14

One library to consider is BoxLib. Its key features (from the website) are: Support for block-structured AMR with optional subcycling in time Support for cell-centered, face-centered and node-centered data Support for hyperbolic, parabolic and elliptic solves on hierarchical grid structure C++ and Fortran90 versions Supports hybrid programming model with ...


12

I think it is quite common, with some algorithms more likely to be re-implemented than others. There's a tricky trade-off between how annoying a library is to install, how hard it is to implement the algorithm yourself, how hard it is to optimize it, and how well the library fits your needs. Also, sometimes using a library is just overkill: I used the slow ...


12

BLAS is not monlithic. BLAS1 and BLAS2 are memory bandwidth limited, and there is not much you can do to speed them up beyond the obvious (loop unrolling, cache blocking for level 2). BLAS3 is more interesting and the prototypical benchmark here is matrix-matrix multiplication. To my knowledge GOTOBlas has always been the clear winner here, see for example ...


11

PETSc multigrid (as a preconditioner) is quite mature and may be used with any of the KSP (iterative Krylov method) solvers in PETSc by typing: -pc_type mg However, this requires that you have some way of generating your coarse levels, such as having structured grids defined by PETSc DA objects, which will be coarsened automatically. Or, if you want to ...


11

OPT++ is used internally by Dakota (Sandia), which is much more than an optimization library and is released under the LGPL. You should also take a look at TAO (ANL), released under a BSD-like license. An introduction to both OPT++ and TAO can be found here. Other alternatives are MOOCHO, NOMAD, and HOPSPACK, which are, as far as I know, also LGPL licensed. ...


11

Boost Graph Library and LEMON As Daniel mentions in his comprehensive answer, the most full-featured general C++ library is the Boost Graph Library. There is a new distributed-memory extension capable of doing some basic algorithms such as breadth-first and depth-first search, minimum spanning trees, and connected components search, but I am not very ...


10

I think that implementing an algorithm instead of using a library can sometimes give a better understanding and control of the model. When I am coding some program for scientific computations, it's important for me to understand what I am doing. Implementing the important algorithms helps me to get a better knowledge of the problem and achieve better control ...


9

MKL does not do distributed parallelism (e.g. MPI), and the support for sparse solvers is rudimentary, definitely not at the level of the other two. Currently, there is only one meaningful benchmark: scalable performance of Sparse Matrix-Vector product (SpMV). Since this is memory bandwidth limited, you can only screw it up. Both PETSc and Trilinos do fine ...


9

You should also look at libMesh. It's targeted at finite element methods, but other than that, I think it checks most of your boxes. Unlike BoxLib, it's a fully unstructured, mixed element type library, which is to stay that it supports tets, pyramids, prisms, and hexahedra in the same mesh. It also has one of the largest sets of integration rules for high-...


9

Whatever site is better will depend on your own appreciation of it. Although it might be tempting to promote whatever system I prefer personally, I believe that the correct choice has more to do with your personal preferences and style of working... How many developers work on your project? How often will you be updating it? How likely is it that somebody ...


9

FTensor is a lightweight, header only, fully templated library that includes ergonomic summation notation. It has been tested extensively in 2, 3, and 4 dimensions, but should work fine for any number of dimensions.


8

One answer is that there are so many slight variations to numerical code that it is really hard to encapsulate that in a library. Take this in comparison to web software, which is often easy to install and has a clear set of inputs and outputs. I think more common is people grabbing a framework, or big library that acts like a framework (Trilinos/PETSc), ...


8

deal.II uses the Threading Building Blocks throughout the library and by and large we're reasonably happy with it. We've looked at a few alternatives, in particular OpenMP since everyone seems to be using that for simpler codes, but found them lacking. In particular, OpenMP has the huge disadvantage that its task model does not allow you to get a handle for ...


8

Both GNU Scientific Library (GSL) (C) and Boost Odeint (C++) feature 8th order Runge-Kutta methods. Both are opensource, and under linux and mac they should be directly available from the package manager. Under windows, it will probably be easier for you to use Boost rather than GSL. GSL is published under the GPL license, and Boost Odeint under the ...


7

Before deciding whether or not to use libraries, I think you'd also want to figure out how much the use of a library will help your code. If you're going to be using a well-optimized library for a key computational kernel, then it's probably a lot more efficient than trying to write your own. However, if you're writing a specialized routine that's only ...


7

Both PETSc and Trilinos have good algebraic multigrid methods. deal.II implements geometric multigrid methods for finite element discretizations, see for example the step-16 tutorial program.


7

I'm not a big user of OOP in general, and this has its reasons. My thoughts on some of the features you mention: Templates: Convenient when they work, a massive nightmare to debug when they don't. Furthermore, you don't really know what's going on "behind the scenes", which can be a source of errors or inefficiencies. Virtual functions: Can be very ...


7

I would suggest to exactly duplicate the Lapack interface to the function that you need, most probably you just need dgesv. That way people that have Lapack installed can simply link to it and it will just work. For people that don't have Lapack installed, you provide your own simple implementation of this function, or possibly implement it using Eigen or ...


7

While there are some books on the implementation of finite element methods (e.g., Mark Gockenbach's Understanding and Implementing the Finite Element Method and Yair Shapiro's Solving PDEs in C++: Numerical Methods in a Unified Object-Oriented Approach), I think it would indeed be most useful to look at (and compare!) actual large-scale libraries: There are ...


6

Profile, don't speculate! (also works as “Benchmark, don't speculate!”) There's nothing generic one can say, it depends heavily on the tasks you want to perform (BLAS 1/2/3, for example) and the hardware you're on (obviously, the Intel MKL doesn't run on ARM processors, for example; but even among Intel processors, you can expect performance differences). ...


6

Prior answers to this question have covered most of the salient points, but I want to add one comment with respect to this: does MKL have the upper hand for some tasks? The MKL team is in a unique position to know about future Intel instruction sets and their implementations in specific processors. Furthermore, they have access to proprietary processor ...


Only top voted, non community-wiki answers of a minimum length are eligible