Hello Everyone, This attached patch is for the Cilk Plus branch affecting the Cilk Runtime. This patch should potentially allow the Cilk runtime library build for non-x86 targets. We have tested this on ARM (trimslice machine) and it seem to work on our test case. We encourage all the GCC target developers to help us expand Cilk on other targets.
Thanks, Balaji V. Iyer.
Index: libcilkrts/runtime/sysdep-unix.c =================================================================== --- libcilkrts/runtime/sysdep-unix.c (revision 196638) +++ libcilkrts/runtime/sysdep-unix.c (working copy) @@ -309,11 +309,15 @@ void __cilkrts_stop_workers(global_state_t *g) * spawn. This should be called each time a frame is resumed. */ static inline void restore_fp_state (__cilkrts_stack_frame *sf) { +#if defined __i386__ || defined __x86_64 __asm__ ( "ldmxcsr %0\n\t" "fnclex\n\t" "fldcw %1" : : "m" (sf->mxcsr), "m" (sf->fpcsr)); +#else +# warning "unimplemented: code to restore the floating point state" +#endif } /* Resume user code after a spawn or sync, possibly on a different stack. Index: libcilkrts/runtime/os-unix.c =================================================================== --- libcilkrts/runtime/os-unix.c (revision 196638) +++ libcilkrts/runtime/os-unix.c (working copy) @@ -344,7 +344,8 @@ COMMON_SYSDEP unsigned long long __cilkrts_gettick __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); return ((unsigned long long)a) | (((unsigned long long)d) << 32); #else -# error "unimplemented cycle counter" +# warning "unimplemented cycle counter" + return 0; #endif } @@ -359,7 +360,7 @@ COMMON_SYSDEP void __cilkrts_short_pause(void) #elif defined __i386__ || defined __x86_64 __asm__("pause"); #else -# error __cilkrts_short_pause undefined +# warning __cilkrts_short_pause undefined #endif } @@ -369,7 +370,7 @@ COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr /* asm statement here works around icc bugs */ __asm__("xchgl %0,%a1" :"=r" (x) : "r" (ptr), "0" (x) :"memory"); #else -# error __cilkrts_xchg undefined + x = __sync_lock_test_and_set(ptr, x); #endif return x; } Index: libcilkrts/ChangeLog.cilkplus =================================================================== --- libcilkrts/ChangeLog.cilkplus (revision 196638) +++ libcilkrts/ChangeLog.cilkplus (working copy) @@ -1,3 +1,13 @@ +2013-03-13 Balaji V. Iyer <balaji.v.i...@intel.com> + + * runtime/sysdep-unix.c (__cilkrts_stop_workers): Inserted inline + assembly inside a #if which is only invoked when compiled for i386. + Otherwise, output a warning. + * runtime/os-unix.c (__cilkrts_gettick): Replaced #error with #warning. + (__cilkrts_short_pause): Likewise. + (__cilkrts_xchg): Likewise. + + 2013-02-05 Balaji V. Iyer <balaji.v.i...@intel.com> * Makefile.in (am_libcilkrts_la_OBJECTS): Removed symbol_test. Index: configure =================================================================== --- configure (revision 196638) +++ configure (working copy) @@ -3159,17 +3159,6 @@ if test x$enable_libgomp = x ; then esac fi -# Disable libcilkrts on non x86 machines... for now. -if test x$enable_libcilkrts = x ; then - # Enable libcilkrts by default on x86 machines. - case "${target}" in - i[3456789]86-*-* | x86_64-*-*) - ;; - *) - noconfigdirs="$noconfigdirs target-libcilkrts" - esac -fi - # Disable libatomic on unsupported systems. if test -d ${srcdir}/libatomic; then if test x$enable_libatomic = x; then Index: ChangeLog.cilkplus =================================================================== --- ChangeLog.cilkplus (revision 0) +++ ChangeLog.cilkplus (revision 0) @@ -0,0 +1,4 @@ +2013-03-13 Balaji V. Iyer <balaji.v.i...@intel.com> + + * configure.ac (enable_libcilkrts): Made libcilkrts unconditional. + * configure (enable_libcilkrts): Likewise. Index: configure.ac =================================================================== --- configure.ac (revision 196638) +++ configure.ac (working copy) @@ -507,17 +507,6 @@ if test x$enable_libgomp = x ; then esac fi -# Disable libcilkrts on non x86 machines... for now. -if test x$enable_libcilkrts = x ; then - # Enable libcilkrts by default on x86 machines. - case "${target}" in - i[3456789]86-*-* | x86_64-*-*) - ;; - *) - noconfigdirs="$noconfigdirs target-libcilkrts" - esac -fi - # Disable libatomic on unsupported systems. if test -d ${srcdir}/libatomic; then if test x$enable_libatomic = x; then