Earlier quoted context omitted.
Computational fluid dynamics is actually a problem where parallelization doesn't get you much. It is primarily limited by memory bandwidth.
I am not sure where you get this information. Parallelization is everything in this space, hence why we have highly interconnected supercomputers to model the most difficult engineering problems. Typical runs use 30k+ cores for a single problem for weeks on end [0]. There are some special cases, such as Boltzmann/dvm [1] where invididual partitions of cells have millions of degrees of freedom, where memory bandwidth…
Is parallel programming hard, and, if so, what can you do about it?
191–199 of 199 posts
Re: Is parallel programming hard, and, if so, what can you do about it?
#192Previous discussions:-
https://news.ycombinator.com/item?id=22030928 (2020)
https://news.ycombinator.com/item?id=34859102 HN discussion (2023)
Re: Is parallel programming hard, and, if so, what can you do about it?
#193Earlier quoted context omitted.
Both I (and apparently the author of TFA) disagree with your definition of parallel programming. TFA gives an example of "embarrassingly parallel" programs as one way to make parallel programming simple. The distinction I learned was: any time you have multiple logical threads of execution you have concurrency, any time you have multiple computations happening simultaneously, you have parallelism. Multithreaded progr…
Vector processing is not parallelism, but rather non-scalar. Specifically, it's a single operation that is able to do work on multiple data items, rather than parallel processors doing work at the same time.
Re: Is parallel programming hard, and, if so, what can you do about it?
#194Earlier quoted context omitted.
Yes, concurrency on a single core CPU is simply not possible. That's why multitasking OS's didn't exist until multicore CPUs became a thing. If only these "Gophers" knew anything about computing history!
So before 2001 your OS didn't have a scheduler and was incapable of handling more than one process at the same time? The user interface was simply hanging when you told your CPU to do something?
Even in modern times, we have something like the first generation raspberry pi zero, it has a single ARM core, and it multitasks fine.
Re: Is parallel programming hard, and, if so, what can you do about it?
#195Earlier quoted context omitted.
yet physical hardware has a finite amount of memory, so at some point you either stop your program of you have to modify a cell you already touched.
Mutation isn't confusing. On its own. Multiple references isn't confusing. On its own. The observation, which I don't think I saw being made twenty years ago (I could be wrong) is that you shouldn't mix these two things. No multiple references with mutation. In theory you can safely do so in serial programs if you were careful enough, in practice you won't be careful enough and we should write fewer serial programs t…
Regarding your point, shared xor mutable is nice, but databases are an example of a shared mutable (and even concurrent!) yet safe resource, so other models are possible.
Re: Is parallel programming hard, and, if so, what can you do about it?
#196Earlier quoted context omitted.
I am not sure where you get this information. Parallelization is everything in this space, hence why we have highly interconnected supercomputers to model the most difficult engineering problems. Typical runs use 30k+ cores for a single problem for weeks on end [0]. There are some special cases, such as Boltzmann/dvm [1] where invididual partitions of cells have millions of degrees of freedom, where memory bandwidth…
Those large number of cores come with a diminishing return (see this benchmark, for example: https://nusit.nus.edu.sg/services/hpc-newsletter/cfd-simulat... )
It is common knowledge in the field to optimize a simulation for the largest number of cores it can efficiently use, so simulation cases are not just blindly thrown more cores without a justification given by the scalability. Your initial claim that parallelization doesn't get you much is flawed, parallelization is the only thing that enables scalable engineering analysis.
Re: Is parallel programming hard, and, if so, what can you do about it?
#197Earlier quoted context omitted.
You only ever need this if you're trying to have hundreds of thousands to millions of threads. It's a very niche problem to have
It's a niche problem to have because our current programming paradigm treats concurrency as a second-class citizen. The invariants of most languages do not include those required for mass concurrency. Functional programming better aligns with the requirements, which is how you arrive at Erlang and Elixir. Every map() function can be trivially replaced with the concurrent cmap(), because the side effects that would ma…
So that again keeps green threads (and thus mass concurrency without parallelism) in the niche category.
Re: Is parallel programming hard, and, if so, what can you do about it?
#198Earlier quoted context omitted.
Mutation isn't confusing. On its own. Multiple references isn't confusing. On its own. The observation, which I don't think I saw being made twenty years ago (I could be wrong) is that you shouldn't mix these two things. No multiple references with mutation. In theory you can safely do so in serial programs if you were careful enough, in practice you won't be careful enough and we should write fewer serial programs t…
My point was simply that at some point the buck stops and someone has to write the code to mutate a memory cell. Regarding your point, shared xor mutable is nice, but databases are an example of a shared mutable (and even concurrent!) yet safe resource, so other models are possible.
Yes, it is possible because programmers have accepted the bargain that they must write purely-functional SQL.
Then the db is able to decide how best to optimise/apply/retry/copy-on-write/abort as necessary.
If SQL allowed you to directly mutate things, it would break everything. You couldn't 'LIMIT 10' if your loop might want to increment some data in row 40082.
Re: Is parallel programming hard, and, if so, what can you do about it?
#199Earlier quoted context omitted.
That’s only safety. It still does not guarantee that performance would improve.
A built-in parallel foreach can't guarantee better performance because the hardware isn't there. The parallel part is scheduled on normal threads by the kernel and this is too unpredictable. But if each OS-scheduled CPU was really a cluster of for instance 1 fast + 64 slow cores then it could have special instructions to split a low-level loop on these slow cores and to facilitate blocking and rejoining back into a s…
Still, deciding where to run such things are not trivial, the time it takes to decide what would be faster could actually be more than the time it takes to just run it.