背景
我們一直在努力失敗,以使用新GCC 5.1版本卸載OpenMP的塊英特爾MIC(即至強融核)。在GCC Offloading頁面之後,我們將build.sh
腳本放在一起,爲「intelmic」和主機編譯器構建「accel」目標編譯器。編譯似乎成功完成。如何使用GCC 5.1和OpenMP卸載工作至強融核
使用env.sh
腳本,我們然後嘗試編譯下面列出的簡單的hello.c
程序。但是,該程序似乎只能在主機上運行,而不能在目標設備上運行。
由於我們是一般的卸載新手,也是編譯GCC的時候,有很多事情我們可能做得不正確。然而,在我們完成調查已經提到加上資源如下(我沒有足夠的代表處發佈的鏈接):
- 卸油的至強融核
- 至強融核教程
- 英特爾至強融核卸載程序型號
最大的問題是他們通常會參考英特爾編譯器。雖然我們計劃購買副本,但我們目前沒有副本。另外,我們的大部分開發流程已經與GCC集成,我們希望保持這種狀態(如果可能的話)。
我們已經安裝了最新的MPSS 3.5發行版,進行必要的修改以便在Ubuntu下運行。我們可以在我們的系統中成功傳達和檢查Xeon Phis的狀態。
在我們的努力中,我們從未看到任何跡象表明代碼在麥克風模擬模式下運行。
問題
- 有沒有人成功地構建實際卸載到至強融核主機/目標GCC編譯器的組合?如果是這樣,你使用了什麼資源?
- 我們是否遺漏了構建腳本中的任何內容?
- 測試源代碼有什麼問題嗎?它們在沒有錯誤的情況下進行編譯(除了下面提到的內容)並且使用48個線程(即主機系統中的邏輯線程數)運行。
- 由於谷歌搜索不透露很多,有沒有人有下一步的建議(除了放棄GCC卸載)?這是一個錯誤?
謝謝!
build.sh
#!/usr/bin/env bash
set -e -x
unset LIBRARY_PATH
GCC_DIST=$PWD/gcc-5.1.0
# Modify these to control where the compilers are installed
TARGET_PREFIX=$HOME/gcc
HOST_PREFIX=$HOME/gcc
TARGET_BUILD=/tmp/gcc-build-mic
HOST_BUILD=/tmp/gcc-build-host
# i dropped the emul since we are not planning to emulate!
TARGET=x86_64-intelmic-linux-gnu
# should this be a quad (i.e. pc)?? default (Ubuntu) build seems to be x86_64-linux-gnu
HOST=x86_64-pc-linux-gnu
# check for the GCC distribution
if [ ! -d $GCC_DIST ]; then
echo "gcc-5.1.0 distribution should be here $PWD"
exit 0
fi
#sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev libisl-dev dejagnu autogen sysvbanner
# prepare and configure the target compiler
mkdir -p $TARGET_BUILD
pushd $TARGET_BUILD
$GCC_DIST/configure \
--prefix=$TARGET_PREFIX \
--enable-languages=c,c++,fortran,lto \
--enable-liboffloadmic=target \
--disable-multilib \
--build=$TARGET \
--host=$TARGET \
--target=$TARGET \
--enable-as-accelerator-for=$HOST \
--program-prefix="${TARGET}-"
#--program-prefix="$HOST-accel-$TARGET-" \
# try adding the program prefix as HINTED in the https://gcc.gnu.org/wiki/Offloading
# do we need to specify a sysroot??? Wiki says we don't need one... but it also says "better to configure as cross compiler....
# build and install
make -j48 && make install
popd
# prepare and build the host compiler
mkdir -p $HOST_BUILD
pushd $HOST_BUILD
$GCC_DIST/configure \
--prefix=$HOST_PREFIX \
--enable-languages=c,c++,fortran,lto \
--enable-liboffloadmic=host \
--disable-multilib \
--build=$HOST \
--host=$HOST \
--target=$HOST \
--enable-offload-targets=$TARGET=$TARGET_PREFIX
make -j48 && make install
popd
env.sh
#!/usr/bin/env bash
TARGET_PREFIX=$HOME/gcc
HOST_PREFIX=$HOME/gcc
HOST=x86_64-pc-linux-gnu
VERSION=5.1.0
export LD_LIBRARY_PATH=/opt/intel/mic/coi/host-linux-release/lib:/opt/mpss/3.4.3/sysroots/k1om-mpss-linux/usr/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$HOST_PREFIX/lib:$HOST_PREFIX/lib64:$HOST_PREFIX/lib/gcc/$HOST/$VERSION:$LD_LIBRARY_PATH
export PATH=$HOST_PREFIX/bin:$PATH
打招呼。C(1版)
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int nthreads, tid;
/* Fork a team of threads giving them their own copies of variables */
#pragma offload target (mic)
{
#pragma omp parallel private(nthreads,tid)
{
/* Obtain thread number */
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);
/* Only master thread does this */
if (tid == 0) {
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
#ifdef __MIC__
printf("on target...\n");
#else
printf("on host...\n");
#endif
}
}
}
我們編譯此代碼:
gcc -fopenmp -foffload=x86_64-intelmic-linux-gnu hello.c -o hello
hello_omp.c(第2版)
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int nthreads, tid;
/* Fork a team of threads giving them their own copies of variables */
#pragma omp target device(mic)
{
#pragma omp parallel private(nthreads,tid)
{
/* Obtain thread number */
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);
/* Only master thread does this */
if (tid == 0) {
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
#ifdef __MIC__
printf("on target...\n");
#else
printf("on host...\n");
#endif
}
}
}
幾乎同樣的事情,而是我們嘗試了
#pragma omp target device
語法。實際上,它在mic
中抱怨,但使用任何設備編號(即0)編譯並在主機上運行。該代碼以相同的方式編譯。
雖然英特爾員工監控此網站,但您可能在英特爾論壇上發佈此更好的運氣。 – Jeff
爲什麼英特爾而不是GCC? –
根據GCC [卸載](https://gcc.gnu.org/wiki/Offloading)頁面:「GCC 5支持兩種類型的卸載:OpenMP到英特爾MIC目標(**即將發佈**英特爾至強融核產品代號* * ** KNL)」。因此,不支持卸載到當代英特爾至強融核(KNC)。 –