Hello everyone, I'm having problems grasping some concepts of parallel programming; to be more precise, given some pieces of code, I have to determine which of them can be parallel and which cannot(this was in a test in a parallel programming class):
a) a=2; b=3; //yes-variables are independently initialised b) a=3;b=a; //depends on the synchronisation c) a=3;b=a;c=b; //depends on which gets executed first d) b=a;c=b;a=4; //no-because some variables might get init to the new value while other to the old value e) a=2;b=a+3;a=3; //no-it's not clear to which value of 'a' the var. 'b' wil get calculated f) for(i=0;i<100;i++) b[i]=i; //yes- variable depends solely on the index g) for(i=0;i<100;i++) b[i]=f(b[i]); //yes-variable doesn't depend on another variable h) for(i=0;i<100;i++) for(j=0;j<100;j++) b[i][j]= f(b[i][j-1]); //no-current variable depends on previous i) a=f(x); b=g(x); //variables get initialised independently j) for(i=0;i<100;i++) b[i] = f(b[index[i]]); //same as i)
so my question is how far off am I from the correct answers ?
PS: if you like, you can contribute to the thread by posting questions(test questions, interviews etc.) of this type here as it might also help others