views:

58

answers:

3

I'm trying to show instruction level parallelism at work. What I was originally doing was using python (willing to change) and doing the following:

def test():
    for i in range(5000):
        j = 0
        k = 0
        l = 0

def test2():
    for i in range(5000):
        j = i * i
        k = j * 2
        l = k * i

if __name__=='__main__':
    from timeit import Timer
    t = Timer("test()", "from __main__ import test")
    print t.timeit()
    t2 = Timer("test2()", "from __main__ import test2")
    print t2.timeit()

However a professor tells me that this doesn't demonstrate ILP, rather it shows whether the python interpreter is optimized or not.

What is it that I can do to demonstrate working ILP?

+2  A: 

Your professor is correct. I think an acceptable demonstration would have to be written in assembler, or at most C/C++, possibly using something like the MMX instruction set.

pjc50
+1  A: 

There is a chance that your professor might be correct -- you might prove him wrong if you could show that cpython is actually using ILP to do that, but I don't think it's worth it.

On the other hand, ILP is fairly hardware-bound and it is rarely, if ever, actually done by the programmer explicitly, so if you did it in C++ or ASM the best you could show is that the compiler (or the assembler) is optimized. My bet is that the snippet you've written is the kind of thing he's looking for, but he just doesn't agree to your language.

Like pjc50 above, I don't think this is actually an acceptable example of ILP but it might just cut it and get your grade right. If you are not actually looking only for the grade, perhaps this might be of assistance: http://developer.apple.com/hardwaredrivers/ve/software_pipelining.html .

donkey_lz
A: 

mingw by default doesn't add any optimizations. so what i did was use some C code and because there are no loop optimizations, it showed ILP working

tipu