computer chips have stopped getting faster: the regular performance improvements we've come to expect are now the result of chipmakers' adding more cores, or processing units, to their chips, rather than increasing their clock speed. in theory, doubling the number of cores doubles the chip's efficiency, but splitting up computations so that they run
1 in parallel isn't easy. on the other hand, say a trio of computer scientists from mit, israel's technion, and microsoft research, neither is it as hard as had been feared.
commercial software developers writing programs for multicore chips frequently use so-called "lock-free" parallel algorithms, which are
2 easy to generate from standard sequential code. in fact, in many cases the
3 can be done automatically.
yet lock-free algorithms don't come with very satisfying theoretical guarantees: all they promise is that at least one core will make progress on its computational task in a
4 span of time. but if they don't exceed that standard, they
5(浪费) all the additional computational power that multiple cores provide.
in recent years, theoretical computer scientists have demonstrated ingenious alternatives called "wait-free" algorithms, which guarantee that all cores will make progress in a fixed span of time. but
6 them from sequential code is extremely complicated, and commercial developers have largely neglected them.
in a paper to be presented at the association for
7 machinery's annual
8 on the theory of computing in may, nir shavit, a professor in mit's department of electrical engineering and computer science; his former student dan alistarh, who's now at microsoft research; and keren censor-hillel of the technion demonstrate a new
9 technique suggesting that, in a wide range of real-world cases, lock-free algorithms actually give wait-free performance.
"in practice, programmers program as if everything is wait-free," shavit says. "this is a kind of mystery. what we are exposing in the paper is this little-talked-about intuition that programmers have about how [chip] schedulers work, that they are actually
10(仁慈的)."
the researchers' key insight was that the chip's performance as a whole could be characterized more simply than the performance of the individual cores. that's because the allocation of different "threads," or
11 of code executed in parallel, is symmetric. "it doesn't matter whether thread 1 is in state a and thread 2 is in state b or if you just
12 the states around," says alistarh, who contributed to the work while at mit. "what we noticed is that by
13 symmetric states, you can simplify this a lot."
in a real chip, the allocation of threads to cores is "a complex interplay of latencies and scheduling policies," alistarh says. in practice, however, the decisions arrived at through that complex interplay end up looking a lot like
15. so the researchers modeled the scheduling of threads as a process that has at least a little randomness in it: at any time, there's some probability that a new thread will be
16 on any given core.
the researchers found that even with a
14 scheduler, a wide range of lock-free algorithms offered performance guarantees that were as good as those offered by wait-free algorithms.
that analysis held, no matter how the probability of thread assignment
17 from core to core. but the researchers also performed a more specific analysis, asking what would happen when multiple cores were trying to write data to the same location in memory and one of them kept getting there ahead of the others. that's the situation that results in a lock-free algorithm's worst performance, when only one core is making progress.
for that case, they considered a particular set of probabilities, in which every core had the same chance of being assigned a thread at any given time. "this is kind of a worst-case random scheduler," alistarh says. even then, however, the number of cores that made progress never dipped below the square root of the number of cores assigned threads, which is still better than the minimum performance guarantee of lock-free algorithms.