2012年6月3日 星期日

build parsec for ARM

reference document: http://www.cs.utexas.edu/~parsec_m5/TR-09-32.pdf
cross-compilation environment:
1. HOSTTYPE=arm
2. PATH=/path/to/fake/uname/bin:$PATH
content of /path/to/fake/uname/bin/uname:
===============================
$ cat ~/research/benchmarks/parsec-2.1-arm/fake-uname/uname
#!/bin/sh

/bin/uname $* | sed 's/i686/armv7l/g'
===============================
3. cross compilation tools: arm-linux-gnueabi-*
4. host machine is i686

Steps:
1. compile tools natively
$ parsecmgmt -a build -p tools
Note: for now, use native i686 compilation flags in gcc.bldconf

2. compile apps to ARM binary:
1. set BINARY_PREFIX options in gcc.bldconf
2.1 blackscholes : OK
2.2 bodytrack:
  2.2.1 In pkgs/apps/bodytrack/src/config.h.in, comment out #undef malloc
before change:
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
after change:
/* Define to rpl_malloc if the replacement function should be used. */
//#undef malloc

  2.2.2 In  pkgs/apps/bodytrack/parsec/gcc-pthread.bldconf, add --host and --build.
before:
# Arguments to pass to the configure script, if it exists
build_conf="--enable-threads --disable-openmp --disable-tbb"

after:
# Arguments to pass to the configure script, if it exists
build_conf="--enable-threads --disable-openmp --disable-tbb --build=i686-linux-gnu --host=arm-linux-gnueabi"

2.3: facesim: OK
2.4: ferret: depends on gsl and imagick, so build them first, see 2.5, and 2.6. OK
2.5: gsl: 
  2.5.1 In  pkgs/libs/gsl/parsec/gcc.bldconf, add --host and --build.
before:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared"

after:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared --build=i686-linux-gnu --host=arm-linux-gnueabi"

2.6: imagick: In  pkgs/libs/imagick/parsec/gcc.bldconf, add --host and --build.
before:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared --without-perl --without-magick-plus-plus --without-bzlib --without-dps --without-djvu --without-fpx --without-gslib --without-jbig --with-jpeg --without-jp2 --without-tiff --without-wmf --without-zlib --without-x --without-fontconfig --without-freetype --without-lcms --without-png --without-gvc --without-openexr --without-rsvg --without-xml"

after:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared --without-perl --without-magick-plus-plus --without-bzlib --without-dps --without-djvu --without-fpx --without-gslib --without-jbig --with-jpeg --without-jp2 --without-tiff --without-wmf --without-zlib --without-x --without-fontconfig --without-freetype --without-lcms --without-png --without-gvc --without-openexr --without-rsvg --without-xml  --build=i686-linux-gnu --host=arm-linux-gnueabi"

2.7: freqmine: OK
2.8: raytrace: SKIP. In order to compile raytrace, libX11 must be cross-compiled which requires cross-compiling the following libraries:
libX11
libXmu
libXext
libxcb
xproto
xextproto
xtrans
libpthread_stubs
libXau
kbproto
inputproto
jpeg

2.9: swaptions: OK
2.10: fluidanimate: OK
2.11: vips: depends on glib and libxml2. libxml2 and vips only need to add --build and --host.
  2.11.1: remove -L${CC_HOME}/lib in config/gcc.bldconf
before:

export LDFLAGS="$STATIC -pthread -L${CC_HOME}/lib"


after:

export LDFLAGS="$STATIC -pthread"


2.12: glib: add --host and --build in pkgs/libs/glib/parsec/gcc.bldconf.
  2.12.1
before:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared --enable-threads --with-threads=posix"

after:
# Arguments to pass to the configure script, if it exists
build_conf="--disable-shared --enable-threads --with-threads=posix --build=i686-linux-gnu --host=arm-linux-gnueabi"
  2.12.2 In pkgs/libs/glib/src/configure, add following line at line 43:

ac_cv_func_posix_getpwuid_r=no$
glib_cv_stack_grows=no$
glib_cv_uscore=no$

2.13: dedup: OK.  depends on ssl, see 2.14
2.14: ssl: OK.
  2.14.1change gcc to arm-linux-gnueabi-gcc in pkgs/libs/ssl/src/Configure.pl line 323
before:

"linux-generic32","gcc-:-DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",

after:
"linux-generic32","arm-linux-gnueabi-gcc-:-DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",


  2.14.2 comment out line 975
before:
$cflags .= " -m32 ";

after:
#$cflags .= " -m32 ";

2.15: streamcluster: OK.
2.16: canneal: OK. need pkgs/kernels/canneal/src/atomic/arm/atomic.h.
  2.16.1: pkgs/kernels/canneal/src/atomic/atomic.h, add following lines:
before:

#elif defined(__alpha__) || defined(__alpha) || defined(alpha) || defined(__ALPHA__)
#  include "alpha/atomic.h"
#else
#  error Architecture not supported by atomic.h
#endif

after
#elif defined(__alpha__) || defined(__alpha) || defined(alpha) || defined(__ALPHA__)
#  include "alpha/atomic.h"
#elif defined(__arm__) || defined(__arm) || defined(arm) || defined(__ARM__)
#  include "arm/atomic.h"
#else
#  error Architecture not supported by atomic.h
#endif
and put to pkgs/kernels/canneal/src/atomic/arm/atomic.h
  2.16.3: add following lines at line 49
before:
#ifndef _KERNEL
#include
#endif

#ifndef I32_bit
after:
#ifndef _KERNEL
#include
#endif

#define ARM_VECTORS_HIGH       0xffff0000U
#define ARM_TP_ADDRESS         (ARM_VECTORS_HIGH + 0x1000)
#define ARM_RAS_START          (ARM_TP_ADDRESS + 4)
#define ARM_RAS_END            (ARM_TP_ADDRESS + 8)

#ifndef I32_bit
  2.16.4: add following lines at line 353
before:
#define atomic_store_rel_ptr            atomic_store_ptr

after:
#define atomic_store_rel_ptr            atomic_store_ptr
#define atomic_load_acq_ptr             atomic_load_acq_long

conlusion:
12 of 13 benchmarks built successfully.
fail applications:
1. raytrace, depends on several libX libraries, which need to be compiled in ARM.
native run: ferret failed
canneal: segfault
dedup: malloc fail





4 則留言:

  1. 你好,我想把parsec3.0交叉编译到arm平台到手机上,可是我看你这篇文档不是很明白。能不能教教我怎么做

    回覆刪除
  2. Here is a working cross compilation port: https://github.com/cirosantilli/parsec-benchmark with a Buildroot package.

    回覆刪除
  3. 您好,按照您的方法来交叉编译parsec3.0,仍然有一些benchmarks失败了。想请问具体该怎么做呢?

    回覆刪除