I'd like to be able to compile ISPC programs to generic LLVM bitcode so I can instrument the code using a bitcode-based performance-analysis tool I'm developing (Byfl, in case anyone cares). However, when trying the mandelbrot test program I'm winding up with a bunch of undefined __movmsk symbols that I don't know how to handle:--$ ispc --versionIntel(r) SPMD Program Compiler (ispc), 1.3.0 (build commit b69d783e096e2294 @ 20120628, LLVM 3.2)$ mkdir objs$ ispc -O2 --arch=x86-64 --target=generic-32 --emit-llvm mandelbrot.ispc -o objs/mandelbrot_ispc.bc -h objs/mandelbrot_ispc.hWARNING: Linking two modules of different data layouts!$ g++ mandelbrot.cpp -Iobjs/ -O2 -m64 -c -o objs/mandelbrot.o$ g++ mandelbrot_serial.cpp -Iobjs/ -O2 -m64 -c -o objs/mandelbrot_serial.o$ g++ ../tasksys.cpp -Iobjs/ -O2 -m64 -c -o objs/tasksys.o../tasksys.cpp: In function ‘void InitTaskSystem()’:../tasksys.cpp:734:90: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]$ clang++ -Iobjs/ -O2 -m64 -o mandelbrot objs/mandelbrot.o objs/mandelbrot_serial.o objs/tasksys.o objs/mandelbrot_ispc.bc -lm -lpthread -lstdc++/tmp/mandelbrot_ispc-IWtDvg.o: In function `mandelbrot_ispc___unfunfunfunfuniuniuniun_3C_uni_3E_':objs/mandelbrot_ispc.bc:(.text+0x93f): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x1ea0): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x2de7): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x4527): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x4c02): undefined reference to `__masked_store_i32'objs/mandelbrot_ispc.bc:(.text+0x5af0): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x7238): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x7913): undefined reference to `__masked_store_i32'/tmp/mandelbrot_ispc-IWtDvg.o: In function `mandelbrot_ispc':objs/mandelbrot_ispc.bc:(.text+0x8294): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0x97ea): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0xa6d6): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0xbef4): undefined reference to `__movmsk'objs/mandelbrot_ispc.bc:(.text+0xc5df): undefined reference to `__masked_store_i32'clang: error: linker command failed with exit code 1 (use -v to see invocation)Any hints? Is this even a supported workflow?Thanks,—Scott
You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ispc-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Using genric-* targets with --emit-llvm is not really supported model. ISPC has a number of intrinsics, which are defined in target specific library. This library is linked to object file / llvm bitcode for targets, which support object generation (i.e. sse4, avx and etc), and for generic targets (the targets assuming C++ output) a header file is supplied, which provides implementation of these intrinsics (see $ISPC_DIR/examples/intrinsics).
Is there a reson for you to use generic-32 target? What hardware are you targeting?
—Scott
You can supply header file for generic target with --c++-include-file=<name>, but it won't work for --emit-llvm target. Generic targets are designed for c++ output. Could you try --emit-c++ and use clang to obtain desired bitcode file? It may work for you.
I'm not sure if completely "generic" vector representation of the code (i.e. without assumptions about target hardware) has any practical value. What kind of conclusions are you going to do by analyzing this generic code?
—Scott--
Thanks for explaining the purpose of the experiment. This makes sense to me, but be aware that some vectorization may not happen in real world because it's not profitable on particular hardware. And this may make your estimation inaccurate.
—Scott--
Generic target + --emit-llvm still looks tricky to me, though you only need to provide ISPC standard library implementation to make it work. Mandelbrot has only two functions it needs, but there are many more that you will meet with other examples. But the good news is that some of them are already implemanted, as LLVM optimizer needs to see them for better optimization. You may notice than ISPC build has the follwoing command:m4 -Ibuiltins/ -DLLVM_VERSION=LLVM_3_3 builtins/target-generic-16.ll | python bitcode2cpp.py builtins/target-generic-16.ll > objs/builtins-target-generic-16.cppSo if you dom4 -Ibuiltins/ -DLLVM_VERSION=LLVM_3_3 builtins/target-generic-16.ll > generic16.llyou'll see what is passed to ISPC as a standard library with generic-16 target. Note that many functions are only declared, but not defined. But you may play with generation scripts to actually enable / implement more stuff.
The problem with your generic-16.c is that you are implementing function with incorrect signature. In LLVM terms it is:declare void @__masked_store_i32(<16 x i32>* nocapture, <16 x i32>, <16 x i1>) nounwindNote that first argument is vector.