java - Automatic parallelization -
what opinion regarding project try take code , split threads automatically(maybe compile time, in runtime).
take @ code below:
for(int i=0;i<100;i++) sum1 += rand(100) for(int j=0;j<100;j++) sum2 += rand(100)/2
this kind of code can automatically split 2 different threads run in parallel. think it's possible? have feeling theoretically it's impossible (it reminds me halting problem) can't justify thought.
do think it's useful project? there it?
whether it's possible in general case know whether piece of code can parallelized not matter, because if algorithm cannot detect cases can parallelized, maybe can detect of them.
that not mean useful. consider following:
- first of all, @ compile-time, have inspect code paths can potentially reach inside construct want parallelize. may tricky computations.
- second, have somehow decide parallelizable , not. cannot trivially break loop modifies same state several threads, example. difficult task , in many cases end not being sure - 2 variables might in fact reference same object.
- even if achieve this, end confusing user. difficult explain why code not parallelizable , how should changed.
i think if want achieve in java, need write more library, , let user decide parallelize (library functions annotations? thinking aloud). functional languages more suited this.
as piece of trivia: during parallel programming course, had inspect code , decide whether parallelizable or not. cannot remember specifics (something "at-most-once" property? fill me in?), moral of story extremely difficult appeared trivial cases.
Comments
Post a Comment