At the Python level, we’re dealing with high-level algorithms that we don’t want to logically split up and stitch back together using the orchestration layer; it’s important for the readability and maintainability of the code that we express the parallelization in the algorithm implementation itself.
(Emphasis mine.) This is well expressed, and I think it should be put down as a requirement. This is what I’ve attempted to communicate before by saying that we need to be passing python variables to python functions and receiving back python variables: the parallelisation must be integral to the algorithm implementation (in python). We can’t have this written as separate shell commands. I would like to see this written as something more like:
gatheredData = task.processScatter(scatteredData)
newScatterData = task.crunchGathered(gatheredData)
task.processScatterAgain(newScatterData)
rather than the decorator magic suggested in the document (under Sensors in Visit; but note that Jim explicitly said the examples he’s given aren’t to be taken as suggesting a design) or by creating a DAG object and adding nodes to it. The code should, as much as possible, express the writer’s intent rather than the implementation details.
I don’t think I agree with the position of the boundary between the orchestration layer and the algorithms layer. I think that the boundary needs to be higher (perhaps even at the tippy-top). It’s not very clear, but the idea expressed seems to be much like we have done with reduceFrames.py in HSC where the algorithms layer is allocated by the orchestration layer so many cores for its scatter/gather operations on one element (e.g., visit or tract), but I have argued that this is inefficient – some pieces end up waiting for others, and because they’re tied to cores those cores sit idle. I would like to see us use some system where a core that is waiting for input be used for some other process. But that means that the algorithm layer needs to operate on multiple elements (e.g., visits, tracts) at a time, rather than just one.
A very big open question is whether this mode of parallelization would need to control work beyond a single node (I don’t think it does).
I was surprised by this statement, but perhaps I just don’t know what kind of memory you’re expecting nodes to have. I would have thought that 189 CCDs is going to be a bit much to keep in memory on a single node: the images are “only” 30 GB (10 B/pix), but I think catalogs, work space and inefficiencies will mean you’re going to need at least a few times that. Maybe that’s small potatoes in a few years?
Another question is how effectively we can use true threading in Python in the presence of the Global Interpreter Lock; if we end up spending most of our time in C++ anyway we should be able to release the GIL at the language boundary.
This statement surprised and scared me. We’ve spent the last few years pulling things from C++ into python, and now everyone is in the mode of writing stuff in python whenever it’s feasible, and C++ only when necessary. I think that’s the right thing to do, because it speeds development. But the GIL means that threading is only worth doing for operations that involve a lot of blocking (network I/O is the classic example), and I don’t think we spend nearly enough time in C++ to put us in that regime. For example, I recently cleaned up a few of the dependencies in ci_hsc so we could get some more parallelism, but the parts I managed to make more parallel were all python code (reading data from the butler) and SCons parallelises with threads, and so I ended up getting the process up to something like 150% CPU usage on top, while running with 8 threads. Maybe we haven’t told SWIG to give up the GIL and so my example doesn’t really count, but if we want to go this way we need to lean back towards putting more functionality in C++, which scares me. But, it shouldn’t really be a concern because processes are just as easy to use as threads (and I see concurrent.futures is going to make them interchangeable). So let’s not even mention python threading at all, OK?
At the C++ level, I think we’ll at least occasionally want to use OpenMP to utilize multiple threads in C++; how much may depend on the hardware architecture and memory/CPU.
This really scares me. I’ve heard that we’re expecting the memory-to-CPU ratio to be such as to encourage the use of low-level parallelisation (like OpenMP) so that we need to get multiple cores working on the same data in memory. If you want to use low-level parallelisation and you want to use your cores efficiently, then you need to have that low-level parallelisation built into everything. If the low-level parallelisation is not built into everything, then you either need to let cores sit idle while you’re not doing low-level parallelisation, or you load up those cores using higher-level parallelisation, contrary to the operational model. So either we need to adopt the operational model of using low-level parallelisation everywhere, or we need to get out of thinking that we’re going to be operating with a low memory-to-CPU ratio (and reflect that thinking in our cluster node design and by dropping talk about OpenMP). There may be some operations in our pipeline where the data forces us into a low memory-to-CPU ratio and it’s worth always using OpenMP (e.g., jointcal; but I’m basing this on meas_mosaic which is an awful memory hog and maybe jointcal does better), but I don’t see how we can build low-level parallelism into much else in a complete fashion.