Remove support for Intel MIC offloading
... after its deprecation in GCC 12. * Makefile.def: Remove module 'liboffloadmic'. * Makefile.in: Regenerate. * configure.ac: Remove 'liboffloadmic' handling. * configure: Regenerate. contrib/ * gcc-changelog/git_commit.py (default_changelog_locations): Remove 'liboffloadmic'. * gcc_update (files_and_dependencies): Remove 'liboffloadmic' files. * update-copyright.py (GCCCmdLine): Remove 'liboffloadmic' comment. gcc/ * config.gcc [target *-intelmic-* | *-intelmicemul-*]: Remove. * config/i386/i386-options.cc (ix86_omp_device_kind_arch_isa) [ACCEL_COMPILER]: Remove. * config/i386/intelmic-mkoffload.cc: Remove. * config/i386/intelmic-offload.h: Likewise. * config/i386/t-intelmic: Likewise. * config/i386/t-omp-device: Likewise. * configure.ac [target *-intelmic-* | *-intelmicemul-*]: Remove. * configure: Regenerate. * doc/install.texi (--enable-offload-targets=[...]): Update. * doc/sourcebuild.texi: Remove 'liboffloadmic' documentation. include/ * gomp-constants.h (GOMP_DEVICE_INTEL_MIC): Comment out. (GOMP_VERSION_INTEL_MIC): Remove. libgomp/ * libgomp-plugin.h (OFFLOAD_TARGET_TYPE_INTEL_MIC): Remove. * libgomp.texi (OpenMP Context Selectors): Remove Intel MIC documentation. * plugin/configfrag.ac <enable_offload_targets> [*-intelmic-* | *-intelmicemul-*]: Remove. * configure: Regenerate. * testsuite/lib/libgomp.exp (libgomp_init): Remove 'liboffloadmic' handling. (offload_target_to_openacc_device_type) [$offload_target = *-intelmic*]: Remove. (check_effective_target_offload_device_intel_mic) (check_effective_target_offload_device_any_intel_mic): Remove. * testsuite/libgomp.c-c++-common/on_device_arch.h (device_arch_intel_mic, on_device_arch_intel_mic, any_device_arch) (any_device_arch_intel_mic): Remove. * testsuite/libgomp.c-c++-common/target-45.c: Remove 'offload_device_any_intel_mic' XFAIL. * testsuite/libgomp.fortran/target10.f90: Likewise. liboffloadmic/ * ChangeLog: Remove. * Makefile.am: Likewise. * Makefile.in: Likewise. * aclocal.m4: Likewise. * configure: Likewise. * configure.ac: Likewise. * configure.tgt: Likewise. * doc/doxygen/config: Likewise. * doc/doxygen/header.tex: Likewise. * include/coi/common/COIEngine_common.h: Likewise. * include/coi/common/COIEvent_common.h: Likewise. * include/coi/common/COIMacros_common.h: Likewise. * include/coi/common/COIPerf_common.h: Likewise. * include/coi/common/COIResult_common.h: Likewise. * include/coi/common/COISysInfo_common.h: Likewise. * include/coi/common/COITypes_common.h: Likewise. * include/coi/sink/COIBuffer_sink.h: Likewise. * include/coi/sink/COIPipeline_sink.h: Likewise. * include/coi/sink/COIProcess_sink.h: Likewise. * include/coi/source/COIBuffer_source.h: Likewise. * include/coi/source/COIEngine_source.h: Likewise. * include/coi/source/COIEvent_source.h: Likewise. * include/coi/source/COIPipeline_source.h: Likewise. * include/coi/source/COIProcess_source.h: Likewise. * liboffloadmic_host.spec.in: Likewise. * liboffloadmic_target.spec.in: Likewise. * plugin/Makefile.am: Likewise. * plugin/Makefile.in: Likewise. * plugin/aclocal.m4: Likewise. * plugin/configure: Likewise. * plugin/configure.ac: Likewise. * plugin/libgomp-plugin-intelmic.cpp: Likewise. * plugin/offload_target_main.cpp: Likewise. * runtime/cean_util.cpp: Likewise. * runtime/cean_util.h: Likewise. * runtime/coi/coi_client.cpp: Likewise. * runtime/coi/coi_client.h: Likewise. * runtime/coi/coi_server.cpp: Likewise. * runtime/coi/coi_server.h: Likewise. * runtime/compiler_if_host.cpp: Likewise. * runtime/compiler_if_host.h: Likewise. * runtime/compiler_if_target.cpp: Likewise. * runtime/compiler_if_target.h: Likewise. * runtime/dv_util.cpp: Likewise. * runtime/dv_util.h: Likewise. * runtime/emulator/coi_common.h: Likewise. * runtime/emulator/coi_device.cpp: Likewise. * runtime/emulator/coi_device.h: Likewise. * runtime/emulator/coi_host.cpp: Likewise. * runtime/emulator/coi_host.h: Likewise. * runtime/emulator/coi_version_asm.h: Likewise. * runtime/emulator/coi_version_linker_script.map: Likewise. * runtime/liboffload_error.c: Likewise. * runtime/liboffload_error_codes.h: Likewise. * runtime/liboffload_msg.c: Likewise. * runtime/liboffload_msg.h: Likewise. * runtime/mic_lib.f90: Likewise. * runtime/offload.h: Likewise. * runtime/offload_common.cpp: Likewise. * runtime/offload_common.h: Likewise. * runtime/offload_engine.cpp: Likewise. * runtime/offload_engine.h: Likewise. * runtime/offload_env.cpp: Likewise. * runtime/offload_env.h: Likewise. * runtime/offload_host.cpp: Likewise. * runtime/offload_host.h: Likewise. * runtime/offload_iterator.h: Likewise. * runtime/offload_omp_host.cpp: Likewise. * runtime/offload_omp_target.cpp: Likewise. * runtime/offload_orsl.cpp: Likewise. * runtime/offload_orsl.h: Likewise. * runtime/offload_table.cpp: Likewise. * runtime/offload_table.h: Likewise. * runtime/offload_target.cpp: Likewise. * runtime/offload_target.h: Likewise. * runtime/offload_target_main.cpp: Likewise. * runtime/offload_timer.h: Likewise. * runtime/offload_timer_host.cpp: Likewise. * runtime/offload_timer_target.cpp: Likewise. * runtime/offload_trace.cpp: Likewise. * runtime/offload_trace.h: Likewise. * runtime/offload_util.cpp: Likewise. * runtime/offload_util.h: Likewise. * runtime/ofldbegin.cpp: Likewise. * runtime/ofldend.cpp: Likewise. * runtime/orsl-lite/include/orsl-lite.h: Likewise. * runtime/orsl-lite/lib/orsl-lite.c: Likewise. * runtime/orsl-lite/version.txt: Likewise.
This commit is contained in:
parent
e724b0480b
commit
e4cba49413
114 changed files with 10 additions and 75949 deletions
|
@ -158,9 +158,6 @@ target_modules = { module= libvtv;
|
|||
bootstrap=true;
|
||||
lib_path=.libs;
|
||||
raw_cxx=true; };
|
||||
target_modules = { module= liboffloadmic;
|
||||
lib_path=.libs;
|
||||
extra_configure_flags='@extra_liboffloadmic_configure_flags@'; };
|
||||
target_modules = { module= libssp; lib_path=.libs; };
|
||||
target_modules = { module= newlib; };
|
||||
target_modules = { module= libgcc; bootstrap=true; no_check=true;
|
||||
|
@ -603,7 +600,6 @@ dependencies = { module=all-m4; on=all-build-texinfo; };
|
|||
// on libgcc and newlib/libgloss.
|
||||
lang_env_dependencies = { module=libitm; cxx=true; };
|
||||
lang_env_dependencies = { module=libffi; cxx=true; };
|
||||
lang_env_dependencies = { module=liboffloadmic; cxx=true; };
|
||||
lang_env_dependencies = { module=newlib; no_c=true; };
|
||||
lang_env_dependencies = { module=libgloss; no_c=true; };
|
||||
lang_env_dependencies = { module=libgcc; no_gcc=true; no_c=true; };
|
||||
|
@ -625,14 +621,12 @@ dependencies = { module=all-target-libphobos; on=all-target-libbacktrace; };
|
|||
dependencies = { module=all-target-libphobos; on=all-target-zlib; };
|
||||
dependencies = { module=all-target-libphobos; on=all-target-libatomic; };
|
||||
dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
|
||||
dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; };
|
||||
dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; };
|
||||
dependencies = { module=configure-target-libvtv; on=all-target-libstdc++-v3; };
|
||||
// parallel_list.o and parallel_settings.o depend on omp.h, which is
|
||||
// generated by the libgomp configure. Unfortunately, due to the use of
|
||||
// recursive make, we can't be that specific.
|
||||
dependencies = { module=all-target-libstdc++-v3; on=configure-target-libgomp; };
|
||||
dependencies = { module=all-target-liboffloadmic; on=all-target-libgomp; };
|
||||
|
||||
dependencies = { module=install-target-libgo; on=install-target-libatomic; };
|
||||
dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; };
|
||||
|
@ -642,8 +636,6 @@ dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++
|
|||
dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
|
||||
dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
|
||||
dependencies = { module=install-target-libvtv; on=install-target-libgcc; };
|
||||
dependencies = { module=install-target-liboffloadmic; on=install-target-libstdc++-v3; };
|
||||
dependencies = { module=install-target-liboffloadmic; on=install-target-libgcc; };
|
||||
dependencies = { module=install-target-libitm; on=install-target-libgcc; };
|
||||
dependencies = { module=install-target-libobjc; on=install-target-libgcc; };
|
||||
dependencies = { module=install-target-libstdc++-v3; on=install-target-libgcc; };
|
||||
|
|
520
Makefile.in
520
Makefile.in
|
@ -706,7 +706,7 @@ all:
|
|||
|
||||
# This is the list of directories that may be needed in RPATH_ENVVAR
|
||||
# so that programs built for the target machine work.
|
||||
TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libsanitizer)$(TARGET_LIB_PATH_libvtv)$(TARGET_LIB_PATH_liboffloadmic)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libphobos)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
|
||||
TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libsanitizer)$(TARGET_LIB_PATH_libvtv)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libphobos)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
|
||||
|
||||
@if target-libstdc++-v3
|
||||
TARGET_LIB_PATH_libstdc++-v3 = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:
|
||||
|
@ -720,10 +720,6 @@ TARGET_LIB_PATH_libsanitizer = $$r/$(TARGET_SUBDIR)/libsanitizer/.libs:
|
|||
TARGET_LIB_PATH_libvtv = $$r/$(TARGET_SUBDIR)/libvtv/.libs:
|
||||
@endif target-libvtv
|
||||
|
||||
@if target-liboffloadmic
|
||||
TARGET_LIB_PATH_liboffloadmic = $$r/$(TARGET_SUBDIR)/liboffloadmic/.libs:
|
||||
@endif target-liboffloadmic
|
||||
|
||||
@if target-libssp
|
||||
TARGET_LIB_PATH_libssp = $$r/$(TARGET_SUBDIR)/libssp/.libs:
|
||||
@endif target-libssp
|
||||
|
@ -1107,7 +1103,6 @@ configure-target: \
|
|||
maybe-configure-target-libstdc++-v3 \
|
||||
maybe-configure-target-libsanitizer \
|
||||
maybe-configure-target-libvtv \
|
||||
maybe-configure-target-liboffloadmic \
|
||||
maybe-configure-target-libssp \
|
||||
maybe-configure-target-newlib \
|
||||
maybe-configure-target-libgcc \
|
||||
|
@ -1290,7 +1285,6 @@ all-target: maybe-all-target-libsanitizer
|
|||
@if target-libvtv-no-bootstrap
|
||||
all-target: maybe-all-target-libvtv
|
||||
@endif target-libvtv-no-bootstrap
|
||||
all-target: maybe-all-target-liboffloadmic
|
||||
all-target: maybe-all-target-libssp
|
||||
all-target: maybe-all-target-newlib
|
||||
@if target-libgcc-no-bootstrap
|
||||
|
@ -1396,7 +1390,6 @@ info-host: maybe-info-libctf
|
|||
info-target: maybe-info-target-libstdc++-v3
|
||||
info-target: maybe-info-target-libsanitizer
|
||||
info-target: maybe-info-target-libvtv
|
||||
info-target: maybe-info-target-liboffloadmic
|
||||
info-target: maybe-info-target-libssp
|
||||
info-target: maybe-info-target-newlib
|
||||
info-target: maybe-info-target-libgcc
|
||||
|
@ -1485,7 +1478,6 @@ dvi-host: maybe-dvi-libctf
|
|||
dvi-target: maybe-dvi-target-libstdc++-v3
|
||||
dvi-target: maybe-dvi-target-libsanitizer
|
||||
dvi-target: maybe-dvi-target-libvtv
|
||||
dvi-target: maybe-dvi-target-liboffloadmic
|
||||
dvi-target: maybe-dvi-target-libssp
|
||||
dvi-target: maybe-dvi-target-newlib
|
||||
dvi-target: maybe-dvi-target-libgcc
|
||||
|
@ -1574,7 +1566,6 @@ pdf-host: maybe-pdf-libctf
|
|||
pdf-target: maybe-pdf-target-libstdc++-v3
|
||||
pdf-target: maybe-pdf-target-libsanitizer
|
||||
pdf-target: maybe-pdf-target-libvtv
|
||||
pdf-target: maybe-pdf-target-liboffloadmic
|
||||
pdf-target: maybe-pdf-target-libssp
|
||||
pdf-target: maybe-pdf-target-newlib
|
||||
pdf-target: maybe-pdf-target-libgcc
|
||||
|
@ -1663,7 +1654,6 @@ html-host: maybe-html-libctf
|
|||
html-target: maybe-html-target-libstdc++-v3
|
||||
html-target: maybe-html-target-libsanitizer
|
||||
html-target: maybe-html-target-libvtv
|
||||
html-target: maybe-html-target-liboffloadmic
|
||||
html-target: maybe-html-target-libssp
|
||||
html-target: maybe-html-target-newlib
|
||||
html-target: maybe-html-target-libgcc
|
||||
|
@ -1752,7 +1742,6 @@ TAGS-host: maybe-TAGS-libctf
|
|||
TAGS-target: maybe-TAGS-target-libstdc++-v3
|
||||
TAGS-target: maybe-TAGS-target-libsanitizer
|
||||
TAGS-target: maybe-TAGS-target-libvtv
|
||||
TAGS-target: maybe-TAGS-target-liboffloadmic
|
||||
TAGS-target: maybe-TAGS-target-libssp
|
||||
TAGS-target: maybe-TAGS-target-newlib
|
||||
TAGS-target: maybe-TAGS-target-libgcc
|
||||
|
@ -1841,7 +1830,6 @@ install-info-host: maybe-install-info-libctf
|
|||
install-info-target: maybe-install-info-target-libstdc++-v3
|
||||
install-info-target: maybe-install-info-target-libsanitizer
|
||||
install-info-target: maybe-install-info-target-libvtv
|
||||
install-info-target: maybe-install-info-target-liboffloadmic
|
||||
install-info-target: maybe-install-info-target-libssp
|
||||
install-info-target: maybe-install-info-target-newlib
|
||||
install-info-target: maybe-install-info-target-libgcc
|
||||
|
@ -1930,7 +1918,6 @@ install-dvi-host: maybe-install-dvi-libctf
|
|||
install-dvi-target: maybe-install-dvi-target-libstdc++-v3
|
||||
install-dvi-target: maybe-install-dvi-target-libsanitizer
|
||||
install-dvi-target: maybe-install-dvi-target-libvtv
|
||||
install-dvi-target: maybe-install-dvi-target-liboffloadmic
|
||||
install-dvi-target: maybe-install-dvi-target-libssp
|
||||
install-dvi-target: maybe-install-dvi-target-newlib
|
||||
install-dvi-target: maybe-install-dvi-target-libgcc
|
||||
|
@ -2019,7 +2006,6 @@ install-pdf-host: maybe-install-pdf-libctf
|
|||
install-pdf-target: maybe-install-pdf-target-libstdc++-v3
|
||||
install-pdf-target: maybe-install-pdf-target-libsanitizer
|
||||
install-pdf-target: maybe-install-pdf-target-libvtv
|
||||
install-pdf-target: maybe-install-pdf-target-liboffloadmic
|
||||
install-pdf-target: maybe-install-pdf-target-libssp
|
||||
install-pdf-target: maybe-install-pdf-target-newlib
|
||||
install-pdf-target: maybe-install-pdf-target-libgcc
|
||||
|
@ -2108,7 +2094,6 @@ install-html-host: maybe-install-html-libctf
|
|||
install-html-target: maybe-install-html-target-libstdc++-v3
|
||||
install-html-target: maybe-install-html-target-libsanitizer
|
||||
install-html-target: maybe-install-html-target-libvtv
|
||||
install-html-target: maybe-install-html-target-liboffloadmic
|
||||
install-html-target: maybe-install-html-target-libssp
|
||||
install-html-target: maybe-install-html-target-newlib
|
||||
install-html-target: maybe-install-html-target-libgcc
|
||||
|
@ -2197,7 +2182,6 @@ installcheck-host: maybe-installcheck-libctf
|
|||
installcheck-target: maybe-installcheck-target-libstdc++-v3
|
||||
installcheck-target: maybe-installcheck-target-libsanitizer
|
||||
installcheck-target: maybe-installcheck-target-libvtv
|
||||
installcheck-target: maybe-installcheck-target-liboffloadmic
|
||||
installcheck-target: maybe-installcheck-target-libssp
|
||||
installcheck-target: maybe-installcheck-target-newlib
|
||||
installcheck-target: maybe-installcheck-target-libgcc
|
||||
|
@ -2286,7 +2270,6 @@ mostlyclean-host: maybe-mostlyclean-libctf
|
|||
mostlyclean-target: maybe-mostlyclean-target-libstdc++-v3
|
||||
mostlyclean-target: maybe-mostlyclean-target-libsanitizer
|
||||
mostlyclean-target: maybe-mostlyclean-target-libvtv
|
||||
mostlyclean-target: maybe-mostlyclean-target-liboffloadmic
|
||||
mostlyclean-target: maybe-mostlyclean-target-libssp
|
||||
mostlyclean-target: maybe-mostlyclean-target-newlib
|
||||
mostlyclean-target: maybe-mostlyclean-target-libgcc
|
||||
|
@ -2375,7 +2358,6 @@ clean-host: maybe-clean-libctf
|
|||
clean-target: maybe-clean-target-libstdc++-v3
|
||||
clean-target: maybe-clean-target-libsanitizer
|
||||
clean-target: maybe-clean-target-libvtv
|
||||
clean-target: maybe-clean-target-liboffloadmic
|
||||
clean-target: maybe-clean-target-libssp
|
||||
clean-target: maybe-clean-target-newlib
|
||||
clean-target: maybe-clean-target-libgcc
|
||||
|
@ -2464,7 +2446,6 @@ distclean-host: maybe-distclean-libctf
|
|||
distclean-target: maybe-distclean-target-libstdc++-v3
|
||||
distclean-target: maybe-distclean-target-libsanitizer
|
||||
distclean-target: maybe-distclean-target-libvtv
|
||||
distclean-target: maybe-distclean-target-liboffloadmic
|
||||
distclean-target: maybe-distclean-target-libssp
|
||||
distclean-target: maybe-distclean-target-newlib
|
||||
distclean-target: maybe-distclean-target-libgcc
|
||||
|
@ -2553,7 +2534,6 @@ maintainer-clean-host: maybe-maintainer-clean-libctf
|
|||
maintainer-clean-target: maybe-maintainer-clean-target-libstdc++-v3
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libsanitizer
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libvtv
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-liboffloadmic
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libssp
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-newlib
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libgcc
|
||||
|
@ -2700,7 +2680,6 @@ check-target: \
|
|||
maybe-check-target-libstdc++-v3 \
|
||||
maybe-check-target-libsanitizer \
|
||||
maybe-check-target-libvtv \
|
||||
maybe-check-target-liboffloadmic \
|
||||
maybe-check-target-libssp \
|
||||
maybe-check-target-newlib \
|
||||
maybe-check-target-libgcc \
|
||||
|
@ -2890,7 +2869,6 @@ install-target: \
|
|||
maybe-install-target-libstdc++-v3 \
|
||||
maybe-install-target-libsanitizer \
|
||||
maybe-install-target-libvtv \
|
||||
maybe-install-target-liboffloadmic \
|
||||
maybe-install-target-libssp \
|
||||
maybe-install-target-newlib \
|
||||
maybe-install-target-libgcc \
|
||||
|
@ -2999,7 +2977,6 @@ install-strip-target: \
|
|||
maybe-install-strip-target-libstdc++-v3 \
|
||||
maybe-install-strip-target-libsanitizer \
|
||||
maybe-install-strip-target-libvtv \
|
||||
maybe-install-strip-target-liboffloadmic \
|
||||
maybe-install-strip-target-libssp \
|
||||
maybe-install-strip-target-newlib \
|
||||
maybe-install-strip-target-libgcc \
|
||||
|
@ -46216,491 +46193,6 @@ maintainer-clean-target-libvtv:
|
|||
|
||||
|
||||
|
||||
.PHONY: configure-target-liboffloadmic maybe-configure-target-liboffloadmic
|
||||
maybe-configure-target-liboffloadmic:
|
||||
@if gcc-bootstrap
|
||||
configure-target-liboffloadmic: stage_current
|
||||
@endif gcc-bootstrap
|
||||
@if target-liboffloadmic
|
||||
maybe-configure-target-liboffloadmic: configure-target-liboffloadmic
|
||||
configure-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
echo "Checking multilib configuration for liboffloadmic..."; \
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/liboffloadmic; \
|
||||
$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/liboffloadmic/multilib.tmp 2> /dev/null; \
|
||||
if test -r $(TARGET_SUBDIR)/liboffloadmic/multilib.out; then \
|
||||
if cmp -s $(TARGET_SUBDIR)/liboffloadmic/multilib.tmp $(TARGET_SUBDIR)/liboffloadmic/multilib.out; then \
|
||||
rm -f $(TARGET_SUBDIR)/liboffloadmic/multilib.tmp; \
|
||||
else \
|
||||
rm -f $(TARGET_SUBDIR)/liboffloadmic/Makefile; \
|
||||
mv $(TARGET_SUBDIR)/liboffloadmic/multilib.tmp $(TARGET_SUBDIR)/liboffloadmic/multilib.out; \
|
||||
fi; \
|
||||
else \
|
||||
mv $(TARGET_SUBDIR)/liboffloadmic/multilib.tmp $(TARGET_SUBDIR)/liboffloadmic/multilib.out; \
|
||||
fi; \
|
||||
test ! -f $(TARGET_SUBDIR)/liboffloadmic/Makefile || exit 0; \
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/liboffloadmic; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo Configuring in $(TARGET_SUBDIR)/liboffloadmic; \
|
||||
cd "$(TARGET_SUBDIR)/liboffloadmic" || exit 1; \
|
||||
case $(srcdir) in \
|
||||
/* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
|
||||
*) topdir=`echo $(TARGET_SUBDIR)/liboffloadmic/ | \
|
||||
sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
|
||||
esac; \
|
||||
module_srcdir=liboffloadmic; \
|
||||
rm -f no-such-file || : ; \
|
||||
CONFIG_SITE=no-such-file $(SHELL) \
|
||||
$$s/$$module_srcdir/configure \
|
||||
--srcdir=$${topdir}/$$module_srcdir \
|
||||
$(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
|
||||
--target=${target_alias} @extra_liboffloadmic_configure_flags@ \
|
||||
|| exit 1
|
||||
@endif target-liboffloadmic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: all-target-liboffloadmic maybe-all-target-liboffloadmic
|
||||
maybe-all-target-liboffloadmic:
|
||||
@if gcc-bootstrap
|
||||
all-target-liboffloadmic: stage_current
|
||||
@endif gcc-bootstrap
|
||||
@if target-liboffloadmic
|
||||
TARGET-target-liboffloadmic=all
|
||||
maybe-all-target-liboffloadmic: all-target-liboffloadmic
|
||||
all-target-liboffloadmic: configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) \
|
||||
$(TARGET-target-liboffloadmic))
|
||||
@endif target-liboffloadmic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: check-target-liboffloadmic maybe-check-target-liboffloadmic
|
||||
maybe-check-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-check-target-liboffloadmic: check-target-liboffloadmic
|
||||
|
||||
check-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) check)
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: install-target-liboffloadmic maybe-install-target-liboffloadmic
|
||||
maybe-install-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-target-liboffloadmic: install-target-liboffloadmic
|
||||
|
||||
install-target-liboffloadmic: installdirs
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) install)
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: install-strip-target-liboffloadmic maybe-install-strip-target-liboffloadmic
|
||||
maybe-install-strip-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-strip-target-liboffloadmic: install-strip-target-liboffloadmic
|
||||
|
||||
install-strip-target-liboffloadmic: installdirs
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) install-strip)
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
# Other targets (info, dvi, pdf, etc.)
|
||||
|
||||
.PHONY: maybe-info-target-liboffloadmic info-target-liboffloadmic
|
||||
maybe-info-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-info-target-liboffloadmic: info-target-liboffloadmic
|
||||
|
||||
info-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing info in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
info) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-dvi-target-liboffloadmic dvi-target-liboffloadmic
|
||||
maybe-dvi-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-dvi-target-liboffloadmic: dvi-target-liboffloadmic
|
||||
|
||||
dvi-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing dvi in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
dvi) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-pdf-target-liboffloadmic pdf-target-liboffloadmic
|
||||
maybe-pdf-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-pdf-target-liboffloadmic: pdf-target-liboffloadmic
|
||||
|
||||
pdf-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing pdf in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
pdf) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-html-target-liboffloadmic html-target-liboffloadmic
|
||||
maybe-html-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-html-target-liboffloadmic: html-target-liboffloadmic
|
||||
|
||||
html-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing html in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
html) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-TAGS-target-liboffloadmic TAGS-target-liboffloadmic
|
||||
maybe-TAGS-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-TAGS-target-liboffloadmic: TAGS-target-liboffloadmic
|
||||
|
||||
TAGS-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing TAGS in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
TAGS) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-install-info-target-liboffloadmic install-info-target-liboffloadmic
|
||||
maybe-install-info-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-info-target-liboffloadmic: install-info-target-liboffloadmic
|
||||
|
||||
install-info-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic \
|
||||
info-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-info in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-info) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-install-dvi-target-liboffloadmic install-dvi-target-liboffloadmic
|
||||
maybe-install-dvi-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-dvi-target-liboffloadmic: install-dvi-target-liboffloadmic
|
||||
|
||||
install-dvi-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic \
|
||||
dvi-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-dvi in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-dvi) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-install-pdf-target-liboffloadmic install-pdf-target-liboffloadmic
|
||||
maybe-install-pdf-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-pdf-target-liboffloadmic: install-pdf-target-liboffloadmic
|
||||
|
||||
install-pdf-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic \
|
||||
pdf-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-pdf in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-pdf) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-install-html-target-liboffloadmic install-html-target-liboffloadmic
|
||||
maybe-install-html-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-install-html-target-liboffloadmic: install-html-target-liboffloadmic
|
||||
|
||||
install-html-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic \
|
||||
html-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-html in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-html) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-installcheck-target-liboffloadmic installcheck-target-liboffloadmic
|
||||
maybe-installcheck-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-installcheck-target-liboffloadmic: installcheck-target-liboffloadmic
|
||||
|
||||
installcheck-target-liboffloadmic: \
|
||||
configure-target-liboffloadmic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing installcheck in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
installcheck) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-mostlyclean-target-liboffloadmic mostlyclean-target-liboffloadmic
|
||||
maybe-mostlyclean-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-mostlyclean-target-liboffloadmic: mostlyclean-target-liboffloadmic
|
||||
|
||||
mostlyclean-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing mostlyclean in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
mostlyclean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-clean-target-liboffloadmic clean-target-liboffloadmic
|
||||
maybe-clean-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-clean-target-liboffloadmic: clean-target-liboffloadmic
|
||||
|
||||
clean-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing clean in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
clean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-distclean-target-liboffloadmic distclean-target-liboffloadmic
|
||||
maybe-distclean-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-distclean-target-liboffloadmic: distclean-target-liboffloadmic
|
||||
|
||||
distclean-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing distclean in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
distclean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
.PHONY: maybe-maintainer-clean-target-liboffloadmic maintainer-clean-target-liboffloadmic
|
||||
maybe-maintainer-clean-target-liboffloadmic:
|
||||
@if target-liboffloadmic
|
||||
maybe-maintainer-clean-target-liboffloadmic: maintainer-clean-target-liboffloadmic
|
||||
|
||||
maintainer-clean-target-liboffloadmic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/liboffloadmic/Makefile ] || exit 0; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing maintainer-clean in $(TARGET_SUBDIR)/liboffloadmic"; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/liboffloadmic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
maintainer-clean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-liboffloadmic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: configure-target-libssp maybe-configure-target-libssp
|
||||
maybe-configure-target-libssp:
|
||||
@if gcc-bootstrap
|
||||
|
@ -63863,7 +63355,6 @@ configure-stagetrain-target-libvtv: maybe-all-stagetrain-gcc
|
|||
configure-stagefeedback-target-libvtv: maybe-all-stagefeedback-gcc
|
||||
configure-stageautoprofile-target-libvtv: maybe-all-stageautoprofile-gcc
|
||||
configure-stageautofeedback-target-libvtv: maybe-all-stageautofeedback-gcc
|
||||
configure-target-liboffloadmic: stage_last
|
||||
configure-target-libssp: stage_last
|
||||
configure-target-newlib: stage_last
|
||||
configure-stage1-target-libgcc: maybe-all-stage1-gcc
|
||||
|
@ -63937,7 +63428,6 @@ configure-stageautofeedback-target-libatomic: maybe-all-stageautofeedback-gcc
|
|||
configure-target-libstdc++-v3: maybe-all-gcc
|
||||
configure-target-libsanitizer: maybe-all-gcc
|
||||
configure-target-libvtv: maybe-all-gcc
|
||||
configure-target-liboffloadmic: maybe-all-gcc
|
||||
configure-target-libssp: maybe-all-gcc
|
||||
configure-target-newlib: maybe-all-gcc
|
||||
configure-target-libgcc: maybe-all-gcc
|
||||
|
@ -65163,8 +64653,6 @@ install-target-libsanitizer: maybe-install-target-libstdc++-v3
|
|||
install-target-libsanitizer: maybe-install-target-libgcc
|
||||
install-target-libvtv: maybe-install-target-libstdc++-v3
|
||||
install-target-libvtv: maybe-install-target-libgcc
|
||||
install-target-liboffloadmic: maybe-install-target-libstdc++-v3
|
||||
install-target-liboffloadmic: maybe-install-target-libgcc
|
||||
install-target-libitm: maybe-install-target-libgcc
|
||||
install-target-libobjc: maybe-install-target-libgcc
|
||||
install-target-libstdc++-v3: maybe-install-target-libgcc
|
||||
|
@ -65232,8 +64720,6 @@ all-target-fastjar: maybe-all-target-zlib
|
|||
configure-target-libgo: maybe-all-target-libstdc++-v3
|
||||
all-target-libgo: maybe-all-target-libbacktrace
|
||||
all-target-libgo: maybe-all-target-libatomic
|
||||
configure-target-liboffloadmic: maybe-configure-target-libgomp
|
||||
all-target-liboffloadmic: maybe-all-target-libgomp
|
||||
configure-target-newlib: maybe-all-binutils
|
||||
configure-target-newlib: maybe-all-ld
|
||||
configure-target-libgfortran: maybe-all-target-libbacktrace
|
||||
|
@ -65324,7 +64810,6 @@ configure-stageautofeedback-target-libatomic: maybe-all-stageautofeedback-target
|
|||
configure-target-libstdc++-v3: maybe-all-target-libgcc
|
||||
configure-target-libsanitizer: maybe-all-target-libgcc
|
||||
configure-target-libvtv: maybe-all-target-libgcc
|
||||
configure-target-liboffloadmic: maybe-all-target-libgcc
|
||||
configure-target-libssp: maybe-all-target-libgcc
|
||||
configure-target-newlib: maybe-all-target-libgcc
|
||||
configure-target-libbacktrace: maybe-all-target-libgcc
|
||||
|
@ -65352,9 +64837,6 @@ configure-target-libsanitizer: maybe-all-target-newlib maybe-all-target-libgloss
|
|||
|
||||
configure-target-libvtv: maybe-all-target-newlib maybe-all-target-libgloss
|
||||
|
||||
configure-target-liboffloadmic: maybe-all-target-newlib maybe-all-target-libgloss
|
||||
configure-target-liboffloadmic: maybe-all-target-libstdc++-v3
|
||||
|
||||
configure-target-libssp: maybe-all-target-newlib maybe-all-target-libgloss
|
||||
|
||||
|
||||
|
|
66
configure
vendored
66
configure
vendored
|
@ -719,7 +719,6 @@ CPPFLAGS
|
|||
LDFLAGS
|
||||
CFLAGS
|
||||
CC
|
||||
extra_liboffloadmic_configure_flags
|
||||
target_subdir
|
||||
host_subdir
|
||||
build_subdir
|
||||
|
@ -805,7 +804,6 @@ enable_libquadmath_support
|
|||
enable_libada
|
||||
enable_libssp
|
||||
enable_libstdcxx
|
||||
enable_liboffloadmic
|
||||
enable_bootstrap
|
||||
enable_pgo_build
|
||||
with_mpc
|
||||
|
@ -1543,8 +1541,6 @@ Optional Features:
|
|||
--enable-libada build libada directory
|
||||
--enable-libssp build libssp directory
|
||||
--disable-libstdcxx do not build libstdc++-v3 directory
|
||||
--enable-liboffloadmic=ARG
|
||||
build liboffloadmic [ARG={no,host,target}]
|
||||
--enable-bootstrap enable bootstrapping [yes if native build]
|
||||
--enable-pgo-build[=lto]
|
||||
enable the PGO build
|
||||
|
@ -2825,7 +2821,6 @@ target_libraries="target-libgcc \
|
|||
target-libgloss \
|
||||
target-newlib \
|
||||
target-libgomp \
|
||||
target-liboffloadmic \
|
||||
target-libatomic \
|
||||
target-libitm \
|
||||
target-libstdc++-v3 \
|
||||
|
@ -3199,44 +3194,6 @@ if test "${ENABLE_LIBSTDCXX}" = "no" ; then
|
|||
noconfigdirs="$noconfigdirs target-libstdc++-v3"
|
||||
fi
|
||||
|
||||
# If this is accelerator compiler and its target is intelmic we enable
|
||||
# target liboffloadmic by default. If this is compiler with offloading
|
||||
# for intelmic we enable host liboffloadmic by default. Otherwise
|
||||
# liboffloadmic is disabled by default.
|
||||
# Check whether --enable-liboffloadmic was given.
|
||||
if test "${enable_liboffloadmic+set}" = set; then :
|
||||
enableval=$enable_liboffloadmic; case "$enableval" in
|
||||
no | host | target)
|
||||
enable_liboffloadmic=$enableval ;;
|
||||
*)
|
||||
as_fn_error $? "--enable-liboffloadmic=no/host/target" "$LINENO" 5 ;;
|
||||
esac
|
||||
else
|
||||
if test x"$enable_as_accelerator_for" != x; then
|
||||
case "${target}" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
enable_liboffloadmic=target
|
||||
extra_liboffloadmic_configure_flags="--enable-liboffloadmic=target"
|
||||
;;
|
||||
*)
|
||||
enable_liboffloadmic=no
|
||||
;;
|
||||
esac
|
||||
else
|
||||
case "${enable_offload_targets}" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
enable_liboffloadmic=host
|
||||
extra_liboffloadmic_configure_flags="--enable-liboffloadmic=host"
|
||||
;;
|
||||
*)
|
||||
enable_liboffloadmic=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Enable libgomp by default on hosted POSIX systems, and a few others.
|
||||
if test x$enable_libgomp = x ; then
|
||||
case "${target}" in
|
||||
|
@ -3275,25 +3232,6 @@ $as_echo "yes" >&6; }
|
|||
fi
|
||||
fi
|
||||
|
||||
# Disable liboffloadmic on unsupported systems.
|
||||
if test -d ${srcdir}/liboffloadmic; then
|
||||
if test x$enable_liboffloadmic != xno; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liboffloadmic support" >&5
|
||||
$as_echo_n "checking for liboffloadmic support... " >&6; }
|
||||
if (srcdir=${srcdir}/liboffloadmic; \
|
||||
. ${srcdir}/configure.tgt; \
|
||||
test -n "$UNSUPPORTED")
|
||||
then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
noconfigdirs="$noconfigdirs target-liboffloadmic"
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable libitm on unsupported systems.
|
||||
if test -d ${srcdir}/libitm; then
|
||||
if test x$enable_libitm = x; then
|
||||
|
@ -9083,7 +9021,7 @@ $as_echo "using paths configured with --with-target-bdw-gc options" >&6; }
|
|||
fi
|
||||
esac
|
||||
|
||||
# Disable libitm, libsanitizer, libvtv, liboffloadmic if we're not building C++
|
||||
# Disable libitm, libsanitizer, libvtv if we're not building C++
|
||||
case ,${enable_languages}, in
|
||||
*,c++,*)
|
||||
# Disable libitm, libsanitizer if we're not building libstdc++
|
||||
|
@ -9095,7 +9033,7 @@ case ,${enable_languages}, in
|
|||
esac
|
||||
;;
|
||||
*)
|
||||
noconfigdirs="$noconfigdirs target-liboffloadmic target-libitm target-libsanitizer target-libvtv"
|
||||
noconfigdirs="$noconfigdirs target-libitm target-libsanitizer target-libvtv"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
57
configure.ac
57
configure.ac
|
@ -150,7 +150,6 @@ target_libraries="target-libgcc \
|
|||
target-libgloss \
|
||||
target-newlib \
|
||||
target-libgomp \
|
||||
target-liboffloadmic \
|
||||
target-libatomic \
|
||||
target-libitm \
|
||||
target-libstdc++-v3 \
|
||||
|
@ -479,42 +478,6 @@ ENABLE_LIBSTDCXX=default)
|
|||
noconfigdirs="$noconfigdirs target-libstdc++-v3"
|
||||
fi]
|
||||
|
||||
# If this is accelerator compiler and its target is intelmic we enable
|
||||
# target liboffloadmic by default. If this is compiler with offloading
|
||||
# for intelmic we enable host liboffloadmic by default. Otherwise
|
||||
# liboffloadmic is disabled by default.
|
||||
AC_ARG_ENABLE([liboffloadmic],
|
||||
AC_HELP_STRING([[--enable-liboffloadmic[=ARG]]],
|
||||
[build liboffloadmic @<:@ARG={no,host,target}@:>@]),
|
||||
[case "$enableval" in
|
||||
no | host | target)
|
||||
enable_liboffloadmic=$enableval ;;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-liboffloadmic=no/host/target]) ;;
|
||||
esac],
|
||||
[if test x"$enable_as_accelerator_for" != x; then
|
||||
case "${target}" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
enable_liboffloadmic=target
|
||||
extra_liboffloadmic_configure_flags="--enable-liboffloadmic=target"
|
||||
;;
|
||||
*)
|
||||
enable_liboffloadmic=no
|
||||
;;
|
||||
esac
|
||||
else
|
||||
case "${enable_offload_targets}" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
enable_liboffloadmic=host
|
||||
extra_liboffloadmic_configure_flags="--enable-liboffloadmic=host"
|
||||
;;
|
||||
*)
|
||||
enable_liboffloadmic=no
|
||||
;;
|
||||
esac
|
||||
fi])
|
||||
AC_SUBST(extra_liboffloadmic_configure_flags)
|
||||
|
||||
# Enable libgomp by default on hosted POSIX systems, and a few others.
|
||||
if test x$enable_libgomp = x ; then
|
||||
case "${target}" in
|
||||
|
@ -550,22 +513,6 @@ if test -d ${srcdir}/libatomic; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Disable liboffloadmic on unsupported systems.
|
||||
if test -d ${srcdir}/liboffloadmic; then
|
||||
if test x$enable_liboffloadmic != xno; then
|
||||
AC_MSG_CHECKING([for liboffloadmic support])
|
||||
if (srcdir=${srcdir}/liboffloadmic; \
|
||||
. ${srcdir}/configure.tgt; \
|
||||
test -n "$UNSUPPORTED")
|
||||
then
|
||||
AC_MSG_RESULT([no])
|
||||
noconfigdirs="$noconfigdirs target-liboffloadmic"
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable libitm on unsupported systems.
|
||||
if test -d ${srcdir}/libitm; then
|
||||
if test x$enable_libitm = x; then
|
||||
|
@ -2334,7 +2281,7 @@ case ,${enable_languages},:${enable_objc_gc} in *,objc,*:yes|*,objc,*:auto)
|
|||
fi
|
||||
esac
|
||||
|
||||
# Disable libitm, libsanitizer, libvtv, liboffloadmic if we're not building C++
|
||||
# Disable libitm, libsanitizer, libvtv if we're not building C++
|
||||
case ,${enable_languages}, in
|
||||
*,c++,*)
|
||||
# Disable libitm, libsanitizer if we're not building libstdc++
|
||||
|
@ -2346,7 +2293,7 @@ case ,${enable_languages}, in
|
|||
esac
|
||||
;;
|
||||
*)
|
||||
noconfigdirs="$noconfigdirs target-liboffloadmic target-libitm target-libsanitizer target-libvtv"
|
||||
noconfigdirs="$noconfigdirs target-libitm target-libsanitizer target-libvtv"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ default_changelog_locations = {
|
|||
'libiberty',
|
||||
'libitm',
|
||||
'libobjc',
|
||||
'liboffloadmic',
|
||||
'libphobos',
|
||||
'libquadmath',
|
||||
'libsanitizer',
|
||||
|
|
|
@ -162,12 +162,6 @@ libsanitizer/sanitizer_common/Makefile.in: libsanitizer/sanitizer_common/Makefil
|
|||
libvtv/aclocal.m4: libvtv/configure.ac libvtv/acinclude.m4
|
||||
libvtv/Makefile.in: libvtv/Makefile.am libvtv/aclocal.m4
|
||||
libvtv/configure: libvtv/configure.ac libvtv/aclocal.m4
|
||||
liboffloadmic/aclocal.m4: liboffloadmic/configure.ac
|
||||
liboffloadmic/Makefile.in: liboffloadmic/Makefile.am
|
||||
liboffloadmic/configure: liboffloadmic/configure.ac
|
||||
liboffloadmic/plugin/aclocal.m4: liboffloadmic/plugin/configure.ac
|
||||
liboffloadmic/plugin/Makefile.in: liboffloadmic/plugin/Makefile.am
|
||||
liboffloadmic/plugin/configure: liboffloadmic/plugin/configure.ac
|
||||
libbacktrace/aclocal.m4: libbacktrace/configure.ac
|
||||
libbacktrace/Makefile.in: libbacktrace/Makefile.am libbacktrace/aclocal.m4
|
||||
libbacktrace/configure: libbacktrace/configure.ac libbacktrace/aclocal.m4
|
||||
|
|
|
@ -760,7 +760,6 @@ class GCCCmdLine (CmdLine):
|
|||
self.add_dir ('libiberty')
|
||||
self.add_dir ('libitm')
|
||||
self.add_dir ('libobjc')
|
||||
# liboffloadmic is imported from upstream.
|
||||
self.add_dir ('libphobos', LibPhobosFilter())
|
||||
self.add_dir ('libquadmath')
|
||||
# libsanitizer is imported from upstream.
|
||||
|
|
|
@ -3552,14 +3552,6 @@ case ${target} in
|
|||
;;
|
||||
esac
|
||||
|
||||
# Build mkoffload tool
|
||||
case ${target} in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
tmake_file="${tmake_file} i386/t-intelmic"
|
||||
tm_file="${tm_file} i386/intelmic-offload.h"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$target_has_targetcm" = "no" ]; then
|
||||
c_target_objs="$c_target_objs default-c.o"
|
||||
cxx_target_objs="$cxx_target_objs default-c.o"
|
||||
|
|
|
@ -314,10 +314,6 @@ ix86_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
|
|||
case omp_device_kind:
|
||||
return strcmp (name, "cpu") == 0;
|
||||
case omp_device_arch:
|
||||
#ifdef ACCEL_COMPILER
|
||||
if (strcmp (name, "intel_mic") == 0)
|
||||
return 1;
|
||||
#endif
|
||||
if (strcmp (name, "x86") == 0)
|
||||
return 1;
|
||||
if (TARGET_64BIT)
|
||||
|
|
|
@ -1,728 +0,0 @@
|
|||
/* Offload image generation tool for Intel MIC devices.
|
||||
|
||||
Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Ilya Verbin <ilya.verbin@intel.com>.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#define IN_TARGET_CODE 1
|
||||
|
||||
#include "config.h"
|
||||
#include <libgen.h>
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "obstack.h"
|
||||
#include "intl.h"
|
||||
#include "diagnostic.h"
|
||||
#include "collect-utils.h"
|
||||
#include "intelmic-offload.h"
|
||||
|
||||
const char tool_name[] = "intelmic mkoffload";
|
||||
|
||||
const char image_section_name[] = ".gnu.offload_images";
|
||||
const char *symbols[3] = { "__offload_image_intelmic_start",
|
||||
"__offload_image_intelmic_end",
|
||||
"__offload_image_intelmic_size" };
|
||||
const char *out_obj_filename = NULL;
|
||||
|
||||
int num_temps = 0;
|
||||
const int MAX_NUM_TEMPS = 10;
|
||||
const char *temp_files[MAX_NUM_TEMPS];
|
||||
|
||||
enum offload_abi offload_abi = OFFLOAD_ABI_UNSET;
|
||||
|
||||
/* Delete tempfiles and exit function. */
|
||||
|
||||
void
|
||||
tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
|
||||
{
|
||||
for (int i = 0; i < num_temps; i++)
|
||||
maybe_unlink (temp_files[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
mkoffload_cleanup (void)
|
||||
{
|
||||
tool_cleanup (false);
|
||||
}
|
||||
|
||||
/* Unlink FILE unless requested otherwise. */
|
||||
|
||||
void
|
||||
maybe_unlink (const char *file)
|
||||
{
|
||||
if (!save_temps)
|
||||
{
|
||||
if (unlink_if_ordinary (file)
|
||||
&& errno != ENOENT)
|
||||
fatal_error (input_location, "deleting file %s: %m", file);
|
||||
}
|
||||
else if (verbose)
|
||||
fprintf (stderr, "[Leaving %s]\n", file);
|
||||
}
|
||||
|
||||
/* Add or change the value of an environment variable, outputting the
|
||||
change to standard error if in verbose mode. */
|
||||
static void
|
||||
xputenv (const char *string)
|
||||
{
|
||||
if (verbose)
|
||||
fprintf (stderr, "%s\n", string);
|
||||
putenv (CONST_CAST (char *, string));
|
||||
}
|
||||
|
||||
/* Parse STR, saving found tokens into PVALUES and return their number.
|
||||
Tokens are assumed to be delimited by ':'. */
|
||||
static unsigned
|
||||
parse_env_var (const char *str, char ***pvalues)
|
||||
{
|
||||
const char *curval, *nextval;
|
||||
char **values;
|
||||
unsigned num = 1, i;
|
||||
|
||||
curval = strchr (str, ':');
|
||||
while (curval)
|
||||
{
|
||||
num++;
|
||||
curval = strchr (curval + 1, ':');
|
||||
}
|
||||
|
||||
values = (char **) xmalloc (num * sizeof (char *));
|
||||
curval = str;
|
||||
nextval = strchr (curval, ':');
|
||||
if (nextval == NULL)
|
||||
nextval = strchr (curval, '\0');
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
int l = nextval - curval;
|
||||
values[i] = (char *) xmalloc (l + 1);
|
||||
memcpy (values[i], curval, l);
|
||||
values[i][l] = 0;
|
||||
curval = nextval + 1;
|
||||
nextval = strchr (curval, ':');
|
||||
if (nextval == NULL)
|
||||
nextval = strchr (curval, '\0');
|
||||
}
|
||||
*pvalues = values;
|
||||
return num;
|
||||
}
|
||||
|
||||
/* Auxiliary function that frees elements of PTR and PTR itself.
|
||||
N is number of elements to be freed. If PTR is NULL, nothing is freed.
|
||||
If an element is NULL, subsequent elements are not freed. */
|
||||
static void
|
||||
free_array_of_ptrs (void **ptr, unsigned n)
|
||||
{
|
||||
unsigned i;
|
||||
if (!ptr)
|
||||
return;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!ptr[i])
|
||||
break;
|
||||
free (ptr[i]);
|
||||
}
|
||||
free (ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check whether NAME can be accessed in MODE. This is like access,
|
||||
except that it never considers directories to be executable. */
|
||||
static int
|
||||
access_check (const char *name, int mode)
|
||||
{
|
||||
if (mode == X_OK)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (name, &st) < 0 || S_ISDIR (st.st_mode))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return access (name, mode);
|
||||
}
|
||||
|
||||
/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH. */
|
||||
static char *
|
||||
find_target_compiler (const char *name)
|
||||
{
|
||||
bool found = false;
|
||||
char **paths = NULL;
|
||||
unsigned n_paths, i;
|
||||
char *target_compiler;
|
||||
const char *collect_gcc = getenv ("COLLECT_GCC");
|
||||
const char *gcc_path = dirname (ASTRDUP (collect_gcc));
|
||||
const char *gcc_exec = basename (ASTRDUP (collect_gcc));
|
||||
|
||||
if (strcmp (gcc_exec, collect_gcc) == 0)
|
||||
{
|
||||
/* collect_gcc has no path, so it was found in PATH. Make sure we also
|
||||
find accel-gcc in PATH. */
|
||||
target_compiler = XDUPVEC (char, name, strlen (name) + 1);
|
||||
found = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
target_compiler = concat (gcc_path, "/", name, NULL);
|
||||
if (access_check (target_compiler, X_OK) == 0)
|
||||
{
|
||||
found = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
n_paths = parse_env_var (getenv ("COMPILER_PATH"), &paths);
|
||||
for (i = 0; i < n_paths; i++)
|
||||
{
|
||||
size_t len = strlen (paths[i]) + 1 + strlen (name) + 1;
|
||||
target_compiler = XRESIZEVEC (char, target_compiler, len);
|
||||
sprintf (target_compiler, "%s/%s", paths[i], name);
|
||||
if (access_check (target_compiler, X_OK) == 0)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
free_array_of_ptrs ((void **) paths, n_paths);
|
||||
return found ? target_compiler : NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
compile_for_target (struct obstack *argv_obstack)
|
||||
{
|
||||
switch (offload_abi)
|
||||
{
|
||||
case OFFLOAD_ABI_LP64:
|
||||
obstack_ptr_grow (argv_obstack, "-m64");
|
||||
break;
|
||||
case OFFLOAD_ABI_ILP32:
|
||||
obstack_ptr_grow (argv_obstack, "-m32");
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
obstack_ptr_grow (argv_obstack, NULL);
|
||||
char **argv = XOBFINISH (argv_obstack, char **);
|
||||
|
||||
/* Save environment variables. */
|
||||
const char *epath = getenv ("GCC_EXEC_PREFIX");
|
||||
const char *cpath = getenv ("COMPILER_PATH");
|
||||
const char *lpath = getenv ("LIBRARY_PATH");
|
||||
const char *rpath = getenv ("LD_RUN_PATH");
|
||||
unsetenv ("GCC_EXEC_PREFIX");
|
||||
unsetenv ("COMPILER_PATH");
|
||||
unsetenv ("LIBRARY_PATH");
|
||||
unsetenv ("LD_RUN_PATH");
|
||||
|
||||
fork_execute (argv[0], argv, false, NULL);
|
||||
obstack_free (argv_obstack, NULL);
|
||||
|
||||
/* Restore environment variables. */
|
||||
xputenv (concat ("GCC_EXEC_PREFIX=", epath, NULL));
|
||||
xputenv (concat ("COMPILER_PATH=", cpath, NULL));
|
||||
xputenv (concat ("LIBRARY_PATH=", lpath, NULL));
|
||||
xputenv (concat ("LD_RUN_PATH=", rpath, NULL));
|
||||
}
|
||||
|
||||
/* Generates object file with the descriptor for the target library. */
|
||||
static const char *
|
||||
generate_target_descr_file (const char *target_compiler)
|
||||
{
|
||||
char *dump_filename = concat (dumppfx, "_target_descr.c", NULL);
|
||||
const char *src_filename = save_temps
|
||||
? dump_filename
|
||||
: make_temp_file ("_target_descr.c");
|
||||
const char *obj_filename = save_temps
|
||||
? concat (dumppfx, "_target_descr.o", NULL)
|
||||
: make_temp_file ("_target_descr.o");
|
||||
temp_files[num_temps++] = src_filename;
|
||||
temp_files[num_temps++] = obj_filename;
|
||||
FILE *src_file = fopen (src_filename, "w");
|
||||
|
||||
if (!src_file)
|
||||
fatal_error (input_location, "cannot open '%s'", src_filename);
|
||||
|
||||
fprintf (src_file,
|
||||
"extern const void *const __offload_funcs_end[];\n"
|
||||
"extern const void *const __offload_vars_end[];\n\n"
|
||||
|
||||
"const void *const __offload_func_table[0]\n"
|
||||
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
|
||||
"section (\".gnu.offload_funcs\"))) = { };\n\n"
|
||||
|
||||
"const void *const __offload_var_table[0]\n"
|
||||
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
|
||||
"section (\".gnu.offload_vars\"))) = { };\n\n"
|
||||
|
||||
"const void *const __OFFLOAD_TARGET_TABLE__[]\n"
|
||||
"__attribute__ ((__used__, visibility (\"hidden\"))) = {\n"
|
||||
" &__offload_func_table, &__offload_funcs_end,\n"
|
||||
" &__offload_var_table, &__offload_vars_end\n"
|
||||
"};\n\n");
|
||||
|
||||
fprintf (src_file,
|
||||
"#ifdef __cplusplus\n"
|
||||
"extern \"C\"\n"
|
||||
"#endif\n"
|
||||
"void target_register_lib (const void *);\n\n"
|
||||
|
||||
"__attribute__((constructor))\n"
|
||||
"static void\n"
|
||||
"init (void)\n"
|
||||
"{\n"
|
||||
" target_register_lib (__OFFLOAD_TARGET_TABLE__);\n"
|
||||
"}\n");
|
||||
fclose (src_file);
|
||||
|
||||
struct obstack argv_obstack;
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, target_compiler);
|
||||
if (save_temps)
|
||||
obstack_ptr_grow (&argv_obstack, "-save-temps");
|
||||
if (verbose)
|
||||
obstack_ptr_grow (&argv_obstack, "-v");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpdir");
|
||||
obstack_ptr_grow (&argv_obstack, "");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase");
|
||||
obstack_ptr_grow (&argv_obstack, dump_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
|
||||
obstack_ptr_grow (&argv_obstack, ".c");
|
||||
obstack_ptr_grow (&argv_obstack, "-c");
|
||||
obstack_ptr_grow (&argv_obstack, "-shared");
|
||||
obstack_ptr_grow (&argv_obstack, "-fPIC");
|
||||
obstack_ptr_grow (&argv_obstack, src_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-o");
|
||||
obstack_ptr_grow (&argv_obstack, obj_filename);
|
||||
compile_for_target (&argv_obstack);
|
||||
|
||||
return obj_filename;
|
||||
}
|
||||
|
||||
/* Generates object file with __offload_*_end symbols for the target
|
||||
library. */
|
||||
static const char *
|
||||
generate_target_offloadend_file (const char *target_compiler)
|
||||
{
|
||||
char *dump_filename = concat (dumppfx, "_target_offloadend.c", NULL);
|
||||
const char *src_filename = save_temps
|
||||
? dump_filename
|
||||
: make_temp_file ("_target_offloadend.c");
|
||||
const char *obj_filename = save_temps
|
||||
? concat (dumppfx, "_target_offloadend.o", NULL)
|
||||
: make_temp_file ("_target_offloadend.o");
|
||||
temp_files[num_temps++] = src_filename;
|
||||
temp_files[num_temps++] = obj_filename;
|
||||
FILE *src_file = fopen (src_filename, "w");
|
||||
|
||||
if (!src_file)
|
||||
fatal_error (input_location, "cannot open '%s'", src_filename);
|
||||
|
||||
fprintf (src_file,
|
||||
"const void *const __offload_funcs_end[0]\n"
|
||||
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
|
||||
"section (\".gnu.offload_funcs\"))) = { };\n\n"
|
||||
|
||||
"const void *const __offload_vars_end[0]\n"
|
||||
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
|
||||
"section (\".gnu.offload_vars\"))) = { };\n");
|
||||
fclose (src_file);
|
||||
|
||||
struct obstack argv_obstack;
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, target_compiler);
|
||||
if (save_temps)
|
||||
obstack_ptr_grow (&argv_obstack, "-save-temps");
|
||||
if (verbose)
|
||||
obstack_ptr_grow (&argv_obstack, "-v");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpdir");
|
||||
obstack_ptr_grow (&argv_obstack, "");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase");
|
||||
obstack_ptr_grow (&argv_obstack, dump_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
|
||||
obstack_ptr_grow (&argv_obstack, ".c");
|
||||
obstack_ptr_grow (&argv_obstack, "-c");
|
||||
obstack_ptr_grow (&argv_obstack, "-shared");
|
||||
obstack_ptr_grow (&argv_obstack, "-fPIC");
|
||||
obstack_ptr_grow (&argv_obstack, src_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-o");
|
||||
obstack_ptr_grow (&argv_obstack, obj_filename);
|
||||
compile_for_target (&argv_obstack);
|
||||
|
||||
return obj_filename;
|
||||
}
|
||||
|
||||
/* Generates object file with the host side descriptor. */
|
||||
static const char *
|
||||
generate_host_descr_file (const char *host_compiler, uint32_t omp_requires)
|
||||
{
|
||||
char *dump_filename = concat (dumppfx, "_host_descr.c", NULL);
|
||||
const char *src_filename = save_temps
|
||||
? dump_filename
|
||||
: make_temp_file ("_host_descr.c");
|
||||
const char *obj_filename = save_temps
|
||||
? concat (dumppfx, "_host_descr.o", NULL)
|
||||
: make_temp_file ("_host_descr.o");
|
||||
temp_files[num_temps++] = src_filename;
|
||||
temp_files[num_temps++] = obj_filename;
|
||||
FILE *src_file = fopen (src_filename, "w");
|
||||
|
||||
if (!src_file)
|
||||
fatal_error (input_location, "cannot open '%s'", src_filename);
|
||||
|
||||
fprintf (src_file, "#include <stdint.h>\n\n");
|
||||
|
||||
fprintf (src_file,
|
||||
"extern const void *const __OFFLOAD_TABLE__;\n"
|
||||
"extern const void *const __offload_image_intelmic_start;\n"
|
||||
"extern const void *const __offload_image_intelmic_end;\n\n"
|
||||
|
||||
"static const struct intelmic_data {\n"
|
||||
" uintptr_t omp_requires_mask;\n"
|
||||
" const void *const image_start;\n"
|
||||
" const void *const image_end;\n"
|
||||
"} intelmic_data = {\n"
|
||||
" %d,\n"
|
||||
" &__offload_image_intelmic_start, &__offload_image_intelmic_end\n"
|
||||
"};\n\n", omp_requires);
|
||||
|
||||
fprintf (src_file,
|
||||
"#ifdef __cplusplus\n"
|
||||
"extern \"C\"\n"
|
||||
"#endif\n"
|
||||
"void GOMP_offload_register_ver (unsigned, const void *, int, const void *);\n"
|
||||
"#ifdef __cplusplus\n"
|
||||
"extern \"C\"\n"
|
||||
"#endif\n"
|
||||
"void GOMP_offload_unregister_ver (unsigned, const void *, int, const void *);\n\n"
|
||||
|
||||
"__attribute__((constructor))\n"
|
||||
"static void\n"
|
||||
"init (void)\n"
|
||||
"{\n"
|
||||
" GOMP_offload_register_ver (%#x, &__OFFLOAD_TABLE__, %d, &intelmic_data);\n"
|
||||
"}\n\n",
|
||||
GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_INTEL_MIC),
|
||||
GOMP_DEVICE_INTEL_MIC);
|
||||
|
||||
fprintf (src_file,
|
||||
"__attribute__((destructor))\n"
|
||||
"static void\n"
|
||||
"fini (void)\n"
|
||||
"{\n"
|
||||
" GOMP_offload_unregister_ver (%#x, &__OFFLOAD_TABLE__, %d, &intelmic_data);\n"
|
||||
"}\n",
|
||||
GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_INTEL_MIC),
|
||||
GOMP_DEVICE_INTEL_MIC);
|
||||
|
||||
fclose (src_file);
|
||||
|
||||
struct obstack argv_obstack;
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, host_compiler);
|
||||
if (save_temps)
|
||||
obstack_ptr_grow (&argv_obstack, "-save-temps");
|
||||
if (verbose)
|
||||
obstack_ptr_grow (&argv_obstack, "-v");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpdir");
|
||||
obstack_ptr_grow (&argv_obstack, "");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase");
|
||||
obstack_ptr_grow (&argv_obstack, dump_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
|
||||
obstack_ptr_grow (&argv_obstack, ".c");
|
||||
obstack_ptr_grow (&argv_obstack, "-c");
|
||||
obstack_ptr_grow (&argv_obstack, "-fPIC");
|
||||
obstack_ptr_grow (&argv_obstack, "-shared");
|
||||
switch (offload_abi)
|
||||
{
|
||||
case OFFLOAD_ABI_LP64:
|
||||
obstack_ptr_grow (&argv_obstack, "-m64");
|
||||
break;
|
||||
case OFFLOAD_ABI_ILP32:
|
||||
obstack_ptr_grow (&argv_obstack, "-m32");
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
obstack_ptr_grow (&argv_obstack, src_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-o");
|
||||
obstack_ptr_grow (&argv_obstack, obj_filename);
|
||||
obstack_ptr_grow (&argv_obstack, NULL);
|
||||
|
||||
char **argv = XOBFINISH (&argv_obstack, char **);
|
||||
fork_execute (argv[0], argv, false, NULL);
|
||||
obstack_free (&argv_obstack, NULL);
|
||||
|
||||
return obj_filename;
|
||||
}
|
||||
|
||||
static const char *
|
||||
prepare_target_image (const char *target_compiler, int argc, char **argv, uint32_t *omp_requires)
|
||||
{
|
||||
const char *target_descr_filename
|
||||
= generate_target_descr_file (target_compiler);
|
||||
const char *target_offloadend_filename
|
||||
= generate_target_offloadend_file (target_compiler);
|
||||
|
||||
char *opt1
|
||||
= XALLOCAVEC (char, sizeof ("-Wl,") + strlen (target_descr_filename));
|
||||
char *opt2
|
||||
= XALLOCAVEC (char, sizeof ("-Wl,") + strlen (target_offloadend_filename));
|
||||
sprintf (opt1, "-Wl,%s", target_descr_filename);
|
||||
sprintf (opt2, "-Wl,%s", target_offloadend_filename);
|
||||
|
||||
char *dump_filename = concat (dumppfx, ".mkoffload", NULL);
|
||||
const char *target_so_filename = save_temps
|
||||
? concat (dumppfx, "_offload_intelmic.so", NULL)
|
||||
: make_temp_file ("_offload_intelmic.so");
|
||||
temp_files[num_temps++] = target_so_filename;
|
||||
struct obstack argv_obstack;
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, target_compiler);
|
||||
if (save_temps)
|
||||
obstack_ptr_grow (&argv_obstack, "-save-temps");
|
||||
if (verbose)
|
||||
obstack_ptr_grow (&argv_obstack, "-v");
|
||||
obstack_ptr_grow (&argv_obstack, "-xlto");
|
||||
obstack_ptr_grow (&argv_obstack, opt1);
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp (argv[i], "-o") && i + 1 != argc)
|
||||
++i;
|
||||
else
|
||||
obstack_ptr_grow (&argv_obstack, argv[i]);
|
||||
}
|
||||
obstack_ptr_grow (&argv_obstack, opt2);
|
||||
/* NB: Put -fPIC and -shared the last to create shared library. */
|
||||
obstack_ptr_grow (&argv_obstack, "-fPIC");
|
||||
obstack_ptr_grow (&argv_obstack, "-shared");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpdir");
|
||||
obstack_ptr_grow (&argv_obstack, "");
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase");
|
||||
obstack_ptr_grow (&argv_obstack, dump_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
|
||||
obstack_ptr_grow (&argv_obstack, "");
|
||||
obstack_ptr_grow (&argv_obstack, "-o");
|
||||
obstack_ptr_grow (&argv_obstack, target_so_filename);
|
||||
|
||||
char *omp_requires_file;
|
||||
if (save_temps)
|
||||
omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL);
|
||||
else
|
||||
omp_requires_file = make_temp_file (".mkoffload.omp_requires");
|
||||
temp_files[num_temps++] = omp_requires_file;
|
||||
xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
|
||||
|
||||
compile_for_target (&argv_obstack);
|
||||
|
||||
unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
|
||||
FILE *in = fopen (omp_requires_file, "rb");
|
||||
if (!in)
|
||||
fatal_error (input_location, "cannot open omp_requires file %qs",
|
||||
omp_requires_file);
|
||||
if (fread (omp_requires, sizeof (*omp_requires), 1, in) != 1)
|
||||
fatal_error (input_location, "cannot read omp_requires file %qs",
|
||||
omp_requires_file);
|
||||
fclose (in);
|
||||
|
||||
/* Run objcopy. */
|
||||
char *rename_section_opt
|
||||
= XALLOCAVEC (char, sizeof (".data=") + strlen (image_section_name));
|
||||
sprintf (rename_section_opt, ".data=%s", image_section_name);
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, "objcopy");
|
||||
obstack_ptr_grow (&argv_obstack, "-B");
|
||||
obstack_ptr_grow (&argv_obstack, "i386");
|
||||
obstack_ptr_grow (&argv_obstack, "-I");
|
||||
obstack_ptr_grow (&argv_obstack, "binary");
|
||||
obstack_ptr_grow (&argv_obstack, "-O");
|
||||
switch (offload_abi)
|
||||
{
|
||||
case OFFLOAD_ABI_LP64:
|
||||
obstack_ptr_grow (&argv_obstack, "elf64-x86-64");
|
||||
break;
|
||||
case OFFLOAD_ABI_ILP32:
|
||||
obstack_ptr_grow (&argv_obstack, "elf32-i386");
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
obstack_ptr_grow (&argv_obstack, target_so_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "--rename-section");
|
||||
obstack_ptr_grow (&argv_obstack, rename_section_opt);
|
||||
obstack_ptr_grow (&argv_obstack, NULL);
|
||||
char **new_argv = XOBFINISH (&argv_obstack, char **);
|
||||
fork_execute (new_argv[0], new_argv, false, NULL);
|
||||
obstack_free (&argv_obstack, NULL);
|
||||
|
||||
/* Objcopy has created symbols, containing the input file name with
|
||||
non-alphanumeric characters replaced by underscores.
|
||||
We are going to rename these new symbols. */
|
||||
size_t symbol_name_len = strlen (target_so_filename);
|
||||
char *symbol_name = XALLOCAVEC (char, symbol_name_len + 1);
|
||||
for (size_t i = 0; i < symbol_name_len; i++)
|
||||
{
|
||||
char c = target_so_filename[i];
|
||||
if (!ISALNUM (c))
|
||||
c = '_';
|
||||
symbol_name[i] = c;
|
||||
}
|
||||
symbol_name[symbol_name_len] = '\0';
|
||||
|
||||
char *opt_for_objcopy[3];
|
||||
opt_for_objcopy[0] = XALLOCAVEC (char, sizeof ("_binary__start=")
|
||||
+ symbol_name_len
|
||||
+ strlen (symbols[0]));
|
||||
opt_for_objcopy[1] = XALLOCAVEC (char, sizeof ("_binary__end=")
|
||||
+ symbol_name_len
|
||||
+ strlen (symbols[1]));
|
||||
opt_for_objcopy[2] = XALLOCAVEC (char, sizeof ("_binary__size=")
|
||||
+ symbol_name_len
|
||||
+ strlen (symbols[2]));
|
||||
sprintf (opt_for_objcopy[0], "_binary_%s_start=%s", symbol_name, symbols[0]);
|
||||
sprintf (opt_for_objcopy[1], "_binary_%s_end=%s", symbol_name, symbols[1]);
|
||||
sprintf (opt_for_objcopy[2], "_binary_%s_size=%s", symbol_name, symbols[2]);
|
||||
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, "objcopy");
|
||||
obstack_ptr_grow (&argv_obstack, target_so_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "--redefine-sym");
|
||||
obstack_ptr_grow (&argv_obstack, opt_for_objcopy[0]);
|
||||
obstack_ptr_grow (&argv_obstack, "--redefine-sym");
|
||||
obstack_ptr_grow (&argv_obstack, opt_for_objcopy[1]);
|
||||
obstack_ptr_grow (&argv_obstack, "--redefine-sym");
|
||||
obstack_ptr_grow (&argv_obstack, opt_for_objcopy[2]);
|
||||
obstack_ptr_grow (&argv_obstack, NULL);
|
||||
new_argv = XOBFINISH (&argv_obstack, char **);
|
||||
fork_execute (new_argv[0], new_argv, false, NULL);
|
||||
obstack_free (&argv_obstack, NULL);
|
||||
|
||||
return target_so_filename;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
progname = "mkoffload-intelmic";
|
||||
gcc_init_libintl ();
|
||||
diagnostic_initialize (global_dc, 0);
|
||||
|
||||
if (atexit (mkoffload_cleanup) != 0)
|
||||
fatal_error (input_location, "atexit failed");
|
||||
|
||||
const char *host_compiler = getenv ("COLLECT_GCC");
|
||||
if (!host_compiler)
|
||||
fatal_error (input_location, "COLLECT_GCC must be set");
|
||||
|
||||
const char *target_driver_name = GCC_INSTALL_NAME;
|
||||
char *target_compiler = find_target_compiler (target_driver_name);
|
||||
if (target_compiler == NULL)
|
||||
fatal_error (input_location, "offload compiler %s not found",
|
||||
target_driver_name);
|
||||
|
||||
/* We may be called with all the arguments stored in some file and
|
||||
passed with @file. Expand them into argv before processing. */
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
/* Scan the argument vector. */
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
#define STR "-foffload-abi="
|
||||
if (startswith (argv[i], STR))
|
||||
{
|
||||
if (strcmp (argv[i] + strlen (STR), "lp64") == 0)
|
||||
offload_abi = OFFLOAD_ABI_LP64;
|
||||
else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0)
|
||||
offload_abi = OFFLOAD_ABI_ILP32;
|
||||
else
|
||||
fatal_error (input_location,
|
||||
"unrecognizable argument of option " STR);
|
||||
}
|
||||
#undef STR
|
||||
else if (strcmp (argv[i], "-save-temps") == 0)
|
||||
save_temps = true;
|
||||
else if (strcmp (argv[i], "-v") == 0)
|
||||
verbose = true;
|
||||
else if (strcmp (argv[i], "-dumpbase") == 0
|
||||
&& i + 1 < argc)
|
||||
dumppfx = argv[++i];
|
||||
else if (strcmp (argv[i], "-o") == 0
|
||||
&& i + 1 < argc)
|
||||
out_obj_filename = argv[++i];
|
||||
}
|
||||
|
||||
if (!out_obj_filename)
|
||||
fatal_error (input_location, "output file not specified");
|
||||
|
||||
if (!dumppfx)
|
||||
dumppfx = out_obj_filename;
|
||||
|
||||
uint32_t omp_requires;
|
||||
|
||||
const char *target_so_filename
|
||||
= prepare_target_image (target_compiler, argc, argv, &omp_requires);
|
||||
|
||||
const char *host_descr_filename
|
||||
= generate_host_descr_file (host_compiler, omp_requires);
|
||||
|
||||
/* Perform partial linking for the target image and host side descriptor.
|
||||
As a result we'll get a finalized object file with all offload data. */
|
||||
struct obstack argv_obstack;
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, "ld");
|
||||
obstack_ptr_grow (&argv_obstack, "-m");
|
||||
switch (offload_abi)
|
||||
{
|
||||
case OFFLOAD_ABI_LP64:
|
||||
obstack_ptr_grow (&argv_obstack, "elf_x86_64");
|
||||
break;
|
||||
case OFFLOAD_ABI_ILP32:
|
||||
obstack_ptr_grow (&argv_obstack, "elf_i386");
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
obstack_ptr_grow (&argv_obstack, "--relocatable");
|
||||
obstack_ptr_grow (&argv_obstack, host_descr_filename);
|
||||
obstack_ptr_grow (&argv_obstack, target_so_filename);
|
||||
obstack_ptr_grow (&argv_obstack, "-o");
|
||||
obstack_ptr_grow (&argv_obstack, out_obj_filename);
|
||||
obstack_ptr_grow (&argv_obstack, NULL);
|
||||
char **new_argv = XOBFINISH (&argv_obstack, char **);
|
||||
fork_execute (new_argv[0], new_argv, false, NULL);
|
||||
obstack_free (&argv_obstack, NULL);
|
||||
|
||||
/* Run objcopy on the resultant object file to localize generated symbols
|
||||
to avoid conflicting between different DSO and an executable. */
|
||||
obstack_init (&argv_obstack);
|
||||
obstack_ptr_grow (&argv_obstack, "objcopy");
|
||||
obstack_ptr_grow (&argv_obstack, "-L");
|
||||
obstack_ptr_grow (&argv_obstack, symbols[0]);
|
||||
obstack_ptr_grow (&argv_obstack, "-L");
|
||||
obstack_ptr_grow (&argv_obstack, symbols[1]);
|
||||
obstack_ptr_grow (&argv_obstack, "-L");
|
||||
obstack_ptr_grow (&argv_obstack, symbols[2]);
|
||||
obstack_ptr_grow (&argv_obstack, out_obj_filename);
|
||||
obstack_ptr_grow (&argv_obstack, NULL);
|
||||
new_argv = XOBFINISH (&argv_obstack, char **);
|
||||
fork_execute (new_argv[0], new_argv, false, NULL);
|
||||
obstack_free (&argv_obstack, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/* Support for Intel MIC offloading.
|
||||
|
||||
Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef INTELMIC_OFFLOAD_H
|
||||
#define INTELMIC_OFFLOAD_H
|
||||
|
||||
/* Support for OpenACC acc_on_device. */
|
||||
|
||||
#include "gomp-constants.h"
|
||||
|
||||
#define ACCEL_COMPILER_acc_device GOMP_DEVICE_INTEL_MIC
|
||||
|
||||
#endif
|
|
@ -1,10 +0,0 @@
|
|||
CFLAGS-mkoffload.o += $(DRIVER_DEFINES) -DGCC_INSTALL_NAME=\"$(GCC_INSTALL_NAME)\"
|
||||
|
||||
mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.cc
|
||||
$(COMPILE) $<
|
||||
$(POSTCOMPILE)
|
||||
ALL_HOST_OBJS += mkoffload.o
|
||||
|
||||
mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS)
|
||||
$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
|
||||
mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
|
|
@ -1,6 +0,0 @@
|
|||
omp-device-properties-i386: $(srcdir)/config/i386/i386-options.cc
|
||||
echo kind: cpu > $@
|
||||
echo arch: intel_mic x86 x86_64 i386 i486 i586 i686 ia32 >> $@
|
||||
echo isa: sse4 `sed -n '/^static struct ix86_target_opts isa2\?_opts\[\] =/,/^};/p' \
|
||||
$(srcdir)/config/i386/i386-options.cc | \
|
||||
sed -n 's/",.*$$//;s/^ { "-m//p'` >> $@
|
14
gcc/configure
vendored
14
gcc/configure
vendored
|
@ -8253,12 +8253,6 @@ if test x"$enable_as_accelerator_for" != x; then
|
|||
$as_echo "#define ACCEL_COMPILER 1" >>confdefs.h
|
||||
|
||||
enable_as_accelerator=yes
|
||||
case "${target}" in
|
||||
*-intelmicemul-*)
|
||||
# In this case we expect offload compiler to be built as native, so we
|
||||
# need to rename the driver to avoid clashes with host's drivers.
|
||||
program_transform_name="s&^&${target}-&" ;;
|
||||
esac
|
||||
sedscript="s#${target_noncanonical}#${enable_as_accelerator_for}-accel-${target_noncanonical}#"
|
||||
program_transform_name=`echo $program_transform_name | sed $sedscript`
|
||||
accel_dir_suffix=/accel/${target_noncanonical}
|
||||
|
@ -8273,10 +8267,6 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
|
|||
|
||||
enable_offloading=1
|
||||
case "$tgt" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
omp_device_property=omp-device-properties-i386
|
||||
omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
|
||||
;;
|
||||
amdgcn*)
|
||||
omp_device_property=omp-device-properties-gcn
|
||||
omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/gcn/t-omp-device"
|
||||
|
@ -19720,7 +19710,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 19723 "configure"
|
||||
#line 19713 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -19826,7 +19816,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 19829 "configure"
|
||||
#line 19819 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
|
|
@ -1136,12 +1136,6 @@ if test x"$enable_as_accelerator_for" != x; then
|
|||
AC_DEFINE(ACCEL_COMPILER, 1,
|
||||
[Define if this compiler should be built as the offload target compiler.])
|
||||
enable_as_accelerator=yes
|
||||
case "${target}" in
|
||||
*-intelmicemul-*)
|
||||
# In this case we expect offload compiler to be built as native, so we
|
||||
# need to rename the driver to avoid clashes with host's drivers.
|
||||
program_transform_name="s&^&${target}-&" ;;
|
||||
esac
|
||||
sedscript="s#${target_noncanonical}#${enable_as_accelerator_for}-accel-${target_noncanonical}#"
|
||||
program_transform_name=`echo $program_transform_name | sed $sedscript`
|
||||
accel_dir_suffix=/accel/${target_noncanonical}
|
||||
|
@ -1156,10 +1150,6 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
|
|||
|
||||
enable_offloading=1
|
||||
case "$tgt" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
omp_device_property=omp-device-properties-i386
|
||||
omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
|
||||
;;
|
||||
amdgcn*)
|
||||
omp_device_property=omp-device-properties-gcn
|
||||
omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/gcn/t-omp-device"
|
||||
|
|
|
@ -2337,7 +2337,7 @@ specifying paths @var{path1}, @dots{}, @var{pathN}.
|
|||
|
||||
@smallexample
|
||||
% @var{srcdir}/configure \
|
||||
--enable-offload-targets=x86_64-intelmicemul-linux-gnu=/path/to/x86_64/compiler,nvptx-none
|
||||
--enable-offload-targets=amdgcn-amdhsa,nvptx-none
|
||||
@end smallexample
|
||||
|
||||
@item --enable-offload-defaulted
|
||||
|
|
|
@ -116,9 +116,6 @@ The runtime support library for transactional memory.
|
|||
@item libobjc
|
||||
The Objective-C and Objective-C++ runtime library.
|
||||
|
||||
@item liboffloadmic
|
||||
A library to allow OpenMP to Intel MIC targets.
|
||||
|
||||
@item libphobos
|
||||
The D standard and runtime library. The bulk of this library is mirrored
|
||||
from the @uref{https://github.com/@/dlang, master D repositories}.
|
||||
|
|
|
@ -229,7 +229,7 @@ enum gomp_map_kind
|
|||
/* #define GOMP_DEVICE_HOST_NONSHM 3 removed. */
|
||||
#define GOMP_DEVICE_NOT_HOST 4
|
||||
#define GOMP_DEVICE_NVIDIA_PTX 5
|
||||
#define GOMP_DEVICE_INTEL_MIC 6
|
||||
/* #define GOMP_DEVICE_INTEL_MIC 6 removed. */
|
||||
/* #define GOMP_DEVICE_HSA 7 removed. */
|
||||
#define GOMP_DEVICE_GCN 8
|
||||
|
||||
|
@ -284,7 +284,6 @@ enum gomp_map_kind
|
|||
to the plugin interface defined in libgomp/libgomp.h. */
|
||||
#define GOMP_VERSION 2
|
||||
#define GOMP_VERSION_NVIDIA_PTX 1
|
||||
#define GOMP_VERSION_INTEL_MIC 0
|
||||
#define GOMP_VERSION_GCN 2
|
||||
|
||||
#define GOMP_VERSION_PACK(LIB, DEV) (((LIB) << 16) | (DEV))
|
||||
|
|
3
libgomp/configure
vendored
3
libgomp/configure
vendored
|
@ -15200,9 +15200,6 @@ if test x"$enable_offload_targets" != x; then
|
|||
tgt=`echo $tgt | sed 's/=.*//'`
|
||||
tgt_plugin=
|
||||
case $tgt in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
tgt_plugin=intelmic
|
||||
;;
|
||||
nvptx*)
|
||||
case "${target}" in
|
||||
aarch64*-*-* | powerpc64le-*-* | x86_64-*-*)
|
||||
|
|
|
@ -49,7 +49,6 @@ enum offload_target_type
|
|||
OFFLOAD_TARGET_TYPE_HOST = 2,
|
||||
/* OFFLOAD_TARGET_TYPE_HOST_NONSHM = 3 removed. */
|
||||
OFFLOAD_TARGET_TYPE_NVIDIA_PTX = 5,
|
||||
OFFLOAD_TARGET_TYPE_INTEL_MIC = 6,
|
||||
OFFLOAD_TARGET_TYPE_HSA = 7,
|
||||
OFFLOAD_TARGET_TYPE_GCN = 8
|
||||
};
|
||||
|
|
|
@ -4303,7 +4303,7 @@ offloading devices (it's not clear if they should be):
|
|||
|
||||
@multitable @columnfractions .60 .10 .25
|
||||
@headitem @code{arch} @tab @code{kind} @tab @code{isa}
|
||||
@item @code{intel_mic}, @code{x86}, @code{x86_64}, @code{i386}, @code{i486},
|
||||
@item @code{x86}, @code{x86_64}, @code{i386}, @code{i486},
|
||||
@code{i586}, @code{i686}, @code{ia32}
|
||||
@tab @code{host}
|
||||
@tab See @code{-m...} flags in ``x86 Options'' (without @code{-m})
|
||||
|
|
|
@ -59,9 +59,6 @@ if test x"$enable_offload_targets" != x; then
|
|||
tgt=`echo $tgt | sed 's/=.*//'`
|
||||
tgt_plugin=
|
||||
case $tgt in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
tgt_plugin=intelmic
|
||||
;;
|
||||
nvptx*)
|
||||
case "${target}" in
|
||||
aarch64*-*-* | powerpc64le-*-* | x86_64-*-*)
|
||||
|
|
|
@ -119,18 +119,6 @@ proc libgomp_init { args } {
|
|||
# Compute what needs to be put into LD_LIBRARY_PATH
|
||||
set always_ld_library_path ".:${blddir}/.libs"
|
||||
|
||||
# Add liboffloadmic build directory in LD_LIBRARY_PATH to support
|
||||
# Intel MIC offloading testing.
|
||||
global offload_plugins
|
||||
if { [string match "*,intelmic,*" ",$offload_plugins,"] } {
|
||||
append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
|
||||
append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
|
||||
# libstdc++ is required by liboffloadmic
|
||||
append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
|
||||
# libgcc_s is required by libstdc++
|
||||
append always_ld_library_path ":${blddir}/../libgcc"
|
||||
}
|
||||
|
||||
global offload_additional_lib_paths
|
||||
if { $offload_additional_lib_paths != "" } {
|
||||
append always_ld_library_path "${offload_additional_lib_paths}"
|
||||
|
@ -313,9 +301,6 @@ proc offload_target_to_openacc_device_type { offload_target } {
|
|||
disable {
|
||||
return "host"
|
||||
}
|
||||
*-intelmic* {
|
||||
return ""
|
||||
}
|
||||
nvptx* {
|
||||
return "nvidia"
|
||||
}
|
||||
|
@ -449,28 +434,6 @@ proc check_effective_target_openacc_nvidia_accel_selected { } {
|
|||
return [string match "nvidia" $openacc_device_type]
|
||||
}
|
||||
|
||||
# Return 1 if using Intel MIC offload device.
|
||||
proc check_effective_target_offload_device_intel_mic { } {
|
||||
return [check_runtime_nocache offload_device_intel_mic {
|
||||
#include "testsuite/libgomp.c-c++-common/on_device_arch.h"
|
||||
int main ()
|
||||
{
|
||||
return !on_device_arch_intel_mic ();
|
||||
}
|
||||
} ]
|
||||
}
|
||||
|
||||
# Return 1 if any Intel MIC offload device is available.
|
||||
proc check_effective_target_offload_device_any_intel_mic { } {
|
||||
return [check_runtime_nocache offload_device_any_intel_mic {
|
||||
#include "testsuite/libgomp.c-c++-common/on_device_arch.h"
|
||||
int main ()
|
||||
{
|
||||
return !any_device_arch_intel_mic ();
|
||||
}
|
||||
} ]
|
||||
}
|
||||
|
||||
# Return 1 if the OpenACC 'host' device type is selected.
|
||||
|
||||
proc check_effective_target_openacc_host_selected { } {
|
||||
|
|
|
@ -13,15 +13,8 @@ device_arch_gcn (void)
|
|||
return GOMP_DEVICE_GCN;
|
||||
}
|
||||
|
||||
/* static */ int
|
||||
device_arch_intel_mic (void)
|
||||
{
|
||||
return GOMP_DEVICE_INTEL_MIC;
|
||||
}
|
||||
|
||||
#pragma omp declare variant (device_arch_nvptx) match(construct={target},device={arch(nvptx)})
|
||||
#pragma omp declare variant (device_arch_gcn) match(construct={target},device={arch(gcn)})
|
||||
#pragma omp declare variant (device_arch_intel_mic) match(construct={target},device={arch(intel_mic)})
|
||||
/* static */ int
|
||||
device_arch (void)
|
||||
{
|
||||
|
@ -49,31 +42,3 @@ on_device_arch_gcn ()
|
|||
{
|
||||
return on_device_arch (GOMP_DEVICE_GCN);
|
||||
}
|
||||
|
||||
int
|
||||
on_device_arch_intel_mic ()
|
||||
{
|
||||
return on_device_arch (GOMP_DEVICE_INTEL_MIC);
|
||||
}
|
||||
|
||||
static int
|
||||
any_device_arch (int d)
|
||||
{
|
||||
int nd = omp_get_num_devices ();
|
||||
for (int i = 0; i < nd; ++i)
|
||||
{
|
||||
int d_cur;
|
||||
#pragma omp target device(i) map(from:d_cur)
|
||||
d_cur = device_arch ();
|
||||
if (d_cur == d)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
any_device_arch_intel_mic ()
|
||||
{
|
||||
return any_device_arch (GOMP_DEVICE_INTEL_MIC);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* { dg-xfail-run-if TODO { offload_device_any_intel_mic } } */
|
||||
|
||||
#include <omp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
! { dg-do run }
|
||||
! { dg-xfail-run-if TODO { offload_device_any_intel_mic } }
|
||||
|
||||
program main
|
||||
use omp_lib
|
||||
|
|
|
@ -1,765 +0,0 @@
|
|||
2022-10-12 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* configure: Regenerate.
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2022-10-11 Olivier Hainque <hainque@adacore.com>
|
||||
Olivier Hainque <hainque@adacore.com>
|
||||
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2022-10-11 Olivier Hainque <hainque@adacore.com>
|
||||
Olivier Hainque <hainque@adacore.com>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
||||
2022-09-09 Tobias Burnus <tobias@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_load_image):
|
||||
Add (unused) uint64_t **rev_fn_table argument.
|
||||
|
||||
2022-08-25 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* configure: Regenerate.
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2022-07-04 Tobias Burnus <tobias@codesourcery.com>
|
||||
Chung-Lin Tang <cltang@codesourcery.com>
|
||||
Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_num_devices):
|
||||
Return -1 when device available but omp_requires_mask != 0.
|
||||
|
||||
2021-10-19 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* include/coi/source/COIBuffer_source.h: Convert 2 chars to
|
||||
unicode.
|
||||
|
||||
2021-05-25 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR libgomp/100747
|
||||
* configure: Make executable.
|
||||
* plugin/configure: Likewise.
|
||||
|
||||
2021-01-05 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||
|
||||
* configure: Re-generate.
|
||||
* plugin/configure: Re-generate.
|
||||
|
||||
2020-11-29 John David Anglin <danglin@gcc.gnu.org>
|
||||
|
||||
* configure: Regenerate.
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2020-05-05 Martin Liska <mliska@suse.cz>
|
||||
|
||||
PR other/89860
|
||||
* runtime/offload_target.cpp: Put index check
|
||||
before its use.
|
||||
|
||||
2020-01-24 Maciej W. Rozycki <macro@wdc.com>
|
||||
|
||||
* plugin/configure.ac: Handle `--with-toolexeclibdir='.
|
||||
* plugin/Makefile.in: Regenerate.
|
||||
* plugin/aclocal.m4: Regenerate.
|
||||
* plugin/configure: Regenerate.
|
||||
* configure.ac: Handle `--with-toolexeclibdir='.
|
||||
* Makefile.in: Regenerate.
|
||||
* aclocal.m4: Regenerate.
|
||||
* configure: Regenerate.
|
||||
|
||||
2020-01-10 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_property):
|
||||
Remove.
|
||||
|
||||
2019-12-22 Maciej W. Rozycki <macro@codesourcery.com>
|
||||
Frederik Harwath <frederik@codesourcery.com>
|
||||
Thomas Schwinge <tschwinge@codesourcery.com>
|
||||
|
||||
liboffloadmic/
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_property):
|
||||
New function.
|
||||
|
||||
2019-10-01 Maciej W. Rozycki <macro@wdc.com>
|
||||
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2019-09-27 Maciej W. Rozycki <macro@wdc.com>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
||||
2019-01-09 Sandra Loosemore <sandra@codesourcery.com>
|
||||
|
||||
PR other/16615
|
||||
|
||||
* include/coi/common/COIResult_common.h: Mechanically replace
|
||||
"can not" with "cannot".
|
||||
* include/coi/source/COIBuffer_source.h: Likewise.
|
||||
|
||||
2018-12-14 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* runtime/offload.h (omp_target_is_present, omp_target_memcpy)
|
||||
(omp_target_memcpy_rect, omp_target_associate_ptr)
|
||||
(omp_target_disassociate_ptr): Adjust to libgomp changes.
|
||||
|
||||
2018-10-31 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
PR bootstrap/82856
|
||||
* Makefile.am: Include multilib.am.
|
||||
* configure.ac: Remove AC_PREREQ.
|
||||
* plugin/Makefile.am: Include multilib.am.
|
||||
* plugin/configure.ac: Remove AC_PREREQ.
|
||||
* Makefile.in, aclocal.m4, configure, plugin/Makefile.in,
|
||||
plugin/aclocal.m4, plugin/configure: Regenerate.
|
||||
|
||||
2018-04-18 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
PR jit/85384
|
||||
* configure: Regenerate.
|
||||
* plugin/configure: Regenerate.
|
||||
|
||||
2017-01-31 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
|
||||
return type.
|
||||
(GOMP_OFFLOAD_load_image): Fix argument types.
|
||||
|
||||
2017-01-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR other/79046
|
||||
* plugin/configure.ac: Add GCC_BASE_VER.
|
||||
* plugin/Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead
|
||||
of cat to get version from BASE-VER file.
|
||||
* plugin/configure: Regenerated.
|
||||
* plugin/aclocal.m4: Regenerated.
|
||||
* plugin/Makefile.in: Regenerated.
|
||||
|
||||
2017-01-20 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR other/79046
|
||||
* aclocal.m4: Regenerated.
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
2017-01-17 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR other/79046
|
||||
* configure.ac: Add GCC_BASE_VER.
|
||||
* Makefile.am (gcc_version): Use @get_gcc_base_ver@ instead of cat to
|
||||
get version from BASE-VER file.
|
||||
* aclocal.m4: Include ../config/acx.m4.
|
||||
* configure: Regenerated.
|
||||
* Makefile.in: Regenerated.
|
||||
|
||||
2016-11-15 Matthias Klose <doko@ubuntu.com>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
||||
2016-07-21 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* Makefile.am (myo_inc_dir): Remove.
|
||||
(toolexeclib_LTLIBRARIES): Remove libmyo-client.la and
|
||||
libmyo-service.la.
|
||||
(liboffloadmic_cppflags): Remove -DMYO_SUPPORT.
|
||||
(liboffloadmic_host_la_SOURCES): Remove offload_myo_host.cpp.
|
||||
(liboffloadmic_target_la_SOURCES): Remove offload_myo_target.cpp.
|
||||
(liboffloadmic_target_la_LIBADD): Remove libmyo-service.la.
|
||||
(libmyo_client_la_SOURCES, libmyo_service_la_SOURCES): Remove.
|
||||
(libmyo_client_la_DEPENDENCIES, libmyo_service_la_DEPENDENCIES): Remove.
|
||||
(libmyo_client_la_CPPFLAGS, libmyo_service_la_CPPFLAGS): Remove.
|
||||
(libmyo_client_la_LDFLAGS, libmyo_service_la_LDFLAGS): Remove.
|
||||
* Makefile.in: Regenerate.
|
||||
* doc/doxygen/header.tex: Merge from upstream, version 20160715
|
||||
<https://openmprtl.org/sites/default/files/liboffload_oss_20160715.tgz>.
|
||||
* runtime/cean_util.cpp: Likewise.
|
||||
* runtime/cean_util.h: Likewise.
|
||||
* runtime/coi/coi_client.cpp: Likewise.
|
||||
* runtime/coi/coi_client.h: Likewise.
|
||||
* runtime/coi/coi_server.cpp: Likewise.
|
||||
* runtime/coi/coi_server.h: Likewise.
|
||||
* runtime/compiler_if_host.cpp: Likewise.
|
||||
* runtime/compiler_if_host.h: Likewise.
|
||||
* runtime/compiler_if_target.cpp: Likewise.
|
||||
* runtime/compiler_if_target.h: Likewise.
|
||||
* runtime/dv_util.cpp: Likewise.
|
||||
* runtime/dv_util.h: Likewise.
|
||||
* runtime/liboffload_error.c: Likewise.
|
||||
* runtime/liboffload_error_codes.h: Likewise.
|
||||
* runtime/liboffload_msg.c: Likewise.
|
||||
* runtime/liboffload_msg.h: Likewise.
|
||||
* runtime/mic_lib.f90: Likewise.
|
||||
* runtime/offload.h: Likewise.
|
||||
* runtime/offload_common.cpp: Likewise.
|
||||
* runtime/offload_common.h: Likewise.
|
||||
* runtime/offload_engine.cpp: Likewise.
|
||||
* runtime/offload_engine.h: Likewise.
|
||||
* runtime/offload_env.cpp: Likewise.
|
||||
* runtime/offload_env.h: Likewise.
|
||||
* runtime/offload_host.cpp: Likewise.
|
||||
* runtime/offload_host.h: Likewise.
|
||||
* runtime/offload_iterator.h: Likewise.
|
||||
* runtime/offload_myo_host.cpp: Likewise.
|
||||
* runtime/offload_myo_host.h: Likewise.
|
||||
* runtime/offload_myo_target.cpp: Likewise.
|
||||
* runtime/offload_myo_target.h: Likewise.
|
||||
* runtime/offload_omp_host.cpp: Likewise.
|
||||
* runtime/offload_omp_target.cpp: Likewise.
|
||||
* runtime/offload_orsl.cpp: Likewise.
|
||||
* runtime/offload_orsl.h: Likewise.
|
||||
* runtime/offload_table.cpp: Likewise.
|
||||
* runtime/offload_table.h: Likewise.
|
||||
* runtime/offload_target.cpp: Likewise.
|
||||
* runtime/offload_target.h: Likewise.
|
||||
* runtime/offload_target_main.cpp: Likewise.
|
||||
* runtime/offload_timer.h: Likewise.
|
||||
* runtime/offload_timer_host.cpp: Likewise.
|
||||
* runtime/offload_timer_target.cpp: Likewise.
|
||||
* runtime/offload_trace.cpp: Likewise.
|
||||
* runtime/offload_trace.h: Likewise.
|
||||
* runtime/offload_util.cpp: Likewise.
|
||||
* runtime/offload_util.h: Likewise.
|
||||
* runtime/ofldbegin.cpp: Likewise.
|
||||
* runtime/ofldend.cpp: Likewise.
|
||||
* runtime/orsl-lite/include/orsl-lite.h: Likewise.
|
||||
* runtime/orsl-lite/lib/orsl-lite.c: Likewise.
|
||||
* runtime/use_mpss2.txt: Remove.
|
||||
* include/coi/common/COIEngine_common.h: Merge from upstream, MPSS
|
||||
version 3.7.1
|
||||
<http://registrationcenter-download.intel.com/akdlm/irc_nas/9226/
|
||||
mpss-3.7.1-linux.tar>.
|
||||
* include/coi/common/COIEvent_common.h: Likewise.
|
||||
* include/coi/common/COIMacros_common.h: Likewise.
|
||||
* include/coi/common/COIPerf_common.h: Likewise.
|
||||
* include/coi/common/COIResult_common.h: Likewise.
|
||||
* include/coi/common/COISysInfo_common.h: Likewise.
|
||||
* include/coi/common/COITypes_common.h: Likewise.
|
||||
* include/coi/sink/COIBuffer_sink.h: Likewise.
|
||||
* include/coi/sink/COIPipeline_sink.h: Likewise.
|
||||
* include/coi/sink/COIProcess_sink.h: Likewise.
|
||||
* include/coi/source/COIBuffer_source.h: Likewise.
|
||||
* include/coi/source/COIEngine_source.h: Likewise.
|
||||
* include/coi/source/COIEvent_source.h: Likewise.
|
||||
* include/coi/source/COIPipeline_source.h: Likewise.
|
||||
* include/coi/source/COIProcess_source.h: Likewise.
|
||||
* include/myo/myo.h: Remove.
|
||||
* include/myo/myoimpl.h: Remove.
|
||||
* include/myo/myotypes.h: Remove.
|
||||
* plugin/Makefile.am (AM_LDFLAGS): Remove -lmyo-service.
|
||||
* plugin/Makefile.in: Regenerate.
|
||||
* plugin/libgomp-plugin-intelmic.cpp (LD_LIBRARY_PATH_ENV): Remove.
|
||||
(MIC_LD_LIBRARY_PATH_ENV): Remove.
|
||||
(init): Do not set MIC_LD_LIBRARY_PATH. Now liboffloadmic uses only
|
||||
LD_LIBRARY_PATH.
|
||||
* plugin/offload_target_main.cpp: Update copyright years.
|
||||
* runtime/emulator/coi_common.h: Likewise.
|
||||
* runtime/emulator/coi_device.cpp: Likewise.
|
||||
* runtime/emulator/coi_device.h: Likewise.
|
||||
* runtime/emulator/coi_host.cpp: Likewise.
|
||||
(COIBufferCreate): Allow COI_BUFFER_OPENCL.
|
||||
(COIEngineGetInfo): Return COI_DEVICE_KNL instead of COI_ISA_x86_64.
|
||||
* runtime/emulator/coi_host.h: Update copyright years.
|
||||
* runtime/emulator/coi_version_asm.h: Likewise.
|
||||
* runtime/emulator/coi_version_linker_script.map: Likewise.
|
||||
* runtime/emulator/myo_client.cpp: Remove.
|
||||
* runtime/emulator/myo_service.cpp: Remove.
|
||||
* runtime/emulator/myo_service.h: Remove.
|
||||
* runtime/emulator/myo_version_asm.h: Remove.
|
||||
* runtime/emulator/myo_version_linker_script.map: Remove.
|
||||
|
||||
2016-05-26 Chung-Lin Tang <cltang@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (offload): Change return type
|
||||
to bool, adjust return code.
|
||||
(GOMP_OFFLOAD_init_device): Likewise.
|
||||
(GOMP_OFFLOAD_fini_device): Likewise.
|
||||
(get_target_table): Likewise.
|
||||
(offload_image): Likwise.
|
||||
(GOMP_OFFLOAD_load_image): Adjust call to offload_image(), change
|
||||
to return -1 on error.
|
||||
(GOMP_OFFLOAD_unload_image): Change return type to bool, adjust return
|
||||
code.
|
||||
(GOMP_OFFLOAD_alloc): Likewise.
|
||||
(GOMP_OFFLOAD_free): Likewise.
|
||||
(GOMP_OFFLOAD_host2dev): Likewise.
|
||||
(GOMP_OFFLOAD_dev2host): Likewise.
|
||||
(GOMP_OFFLOAD_dev2dev): Likewise.
|
||||
|
||||
2016-01-20 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_run): Pass extra NULL
|
||||
to GOMP_OFFLOAD_async_run.
|
||||
|
||||
2016-01-19 Martin Jambor <mjambor@suse.cz>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_async_run): New
|
||||
unused parameter.
|
||||
(GOMP_OFFLOAD_run): Likewise.
|
||||
|
||||
2015-12-14 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (unregister_main_image): Remove.
|
||||
(register_main_image): Do not call unregister_main_image at exit.
|
||||
(GOMP_OFFLOAD_fini_device): Allow for OpenMP. Unregister main image.
|
||||
|
||||
2015-11-19 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (struct TargetImageDesc): New.
|
||||
(ImgDescMap): New typedef.
|
||||
(image_descriptors): New static var.
|
||||
(init): Allocate image_descriptors.
|
||||
(offload): Remove vars2 argument. Pass NULL to __offload_offload1
|
||||
instead of vars2.
|
||||
(unregister_main_image): New static function.
|
||||
(register_main_image): Call unregister_main_image at exit.
|
||||
(GOMP_OFFLOAD_init_device): Print device number, fix offload args.
|
||||
(GOMP_OFFLOAD_fini_device): Likewise.
|
||||
(get_target_table): Remove vd1g and vd2g, don't pass them to offload.
|
||||
(offload_image): Remove declaration of the struct TargetImage.
|
||||
Free table. Insert new descriptor into image_descriptors.
|
||||
(GOMP_OFFLOAD_unload_image): Call __offload_unregister_image, free
|
||||
the corresponding descriptor, and remove it from address_table and
|
||||
image_descriptors.
|
||||
(GOMP_OFFLOAD_alloc): Print device number, remove vd1g.
|
||||
(GOMP_OFFLOAD_free): Likewise.
|
||||
(GOMP_OFFLOAD_host2dev): Print device number, remove vd1g and vd2g.
|
||||
(GOMP_OFFLOAD_dev2host): Likewise.
|
||||
(GOMP_OFFLOAD_run): Print device number, remove vd1g.
|
||||
* plugin/offload_target_main.cpp (__offload_target_table_p1): Remove
|
||||
vd2, don't pass it to __offload_target_enter.
|
||||
(__offload_target_table_p2): Likewise.
|
||||
(__offload_target_alloc): Likewise.
|
||||
(__offload_target_free): Likewise.
|
||||
(__offload_target_host2tgt_p1): Likewise.
|
||||
(__offload_target_host2tgt_p2): Likewise.
|
||||
(__offload_target_tgt2host_p1): Likewise.
|
||||
(__offload_target_tgt2host_p2): Likewise.
|
||||
(__offload_target_run): Likewise.
|
||||
(__offload_target_tgt2tgt): Remove vd1g, don't pass it to
|
||||
__offload_target_enter.
|
||||
|
||||
2015-11-14 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* runtime/offload_host.cpp (task_completion_callback): New
|
||||
variable.
|
||||
(offload_proxy_task_completed_ooo): Call task_completion_callback.
|
||||
(__offload_register_task_callback): New function.
|
||||
* runtime/offload_host.h (__offload_register_task_callback): New
|
||||
declaration.
|
||||
* plugin/libgomp-plugin-intelmic.cpp (offload): Add async_data
|
||||
argument, handle async offloading.
|
||||
(register_main_image): Call register_main_image.
|
||||
(GOMP_OFFLOAD_init_device, get_target_table, GOMP_OFFLOAD_alloc,
|
||||
GOMP_OFFLOAD_free, GOMP_OFFLOAD_host2dev, GOMP_OFFLOAD_dev2host,
|
||||
GOMP_OFFLOAD_dev2dev): Adjust offload callers.
|
||||
(GOMP_OFFLOAD_async_run): New function.
|
||||
(GOMP_OFFLOAD_run): Implement using GOMP_OFFLOAD_async_run.
|
||||
|
||||
2015-10-26 Ilya Verbin <ilya.verbin@intel.com>
|
||||
Aleksander Ivanushenko <aleksander.ivanushenko@intel.com>
|
||||
|
||||
* runtime/offload_host.cpp (OffloadDescriptor::setup_misc_data): Use
|
||||
calloc instead of malloc.
|
||||
(__offload_fini_library): Set mic_engines_total to zero.
|
||||
|
||||
2015-10-13 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_dev2dev): New
|
||||
function.
|
||||
* plugin/offload_target_main.cpp (__offload_target_tgt2tgt): New
|
||||
static function, register it in liboffloadmic.
|
||||
|
||||
2015-10-08 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* runtime/offload_engine.cpp (Engine::init_process): Use strdup instead
|
||||
of sizeof+malloc+sprintf, check for return value.
|
||||
* runtime/offload_env.cpp (MicEnvVar::get_env_var_kind): Check for
|
||||
strdup return value.
|
||||
* runtime/offload_host.cpp (__offload_init_library_once): Check for
|
||||
strdup return value. Fix size calculation of COI_HOST_THREAD_AFFINITY.
|
||||
* runtime/emulator/coi_device.cpp (COIProcessWaitForShutdown): Check for
|
||||
malloc return value.
|
||||
|
||||
2015-09-29 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (OFFLOAD_ACTIVE_WAIT_ENV): New
|
||||
define.
|
||||
(init): Set OFFLOAD_ACTIVE_WAIT env var to 0, if it is not set.
|
||||
* runtime/emulator/coi_common.h (PIPE_HOST_PATH): Replace with ...
|
||||
(PIPE_HOST2TGT_NAME): ... this.
|
||||
(PIPE_TARGET_PATH): Replace with ...
|
||||
(PIPE_TGT2HOST_NAME): ... this.
|
||||
(MALLOCN): New define.
|
||||
(READN): Likewise.
|
||||
(WRITEN): Likewise.
|
||||
(enum cmd_t): Replace CMD_RUN_FUNCTION with CMD_PIPELINE_RUN_FUNCTION.
|
||||
Add CMD_PIPELINE_CREATE, CMD_PIPELINE_DESTROY.
|
||||
* runtime/emulator/coi_device.cpp (engine_dir): New static variable.
|
||||
(pipeline_thread_routine): New static function.
|
||||
(COIProcessWaitForShutdown): Use global engine_dir instead of mic_dir.
|
||||
Rename pipe_host and pipe_target to pipe_host2tgt and pipe_tgt2host.
|
||||
If cmd is CMD_PIPELINE_CREATE, create a new thread for the pipeline.
|
||||
Remove cmd == CMD_RUN_FUNCTION case.
|
||||
* runtime/emulator/coi_device.h (COIERRORN): New define.
|
||||
* runtime/emulator/coi_host.cpp: Include set, map, queue.
|
||||
Replace typedefs with enums and structs.
|
||||
(struct Function): Remove name, add num_buffers, bufs_size,
|
||||
bufs_data_target, misc_data_len, misc_data, return_value_len,
|
||||
return_value, completion_event.
|
||||
(struct Callback): New.
|
||||
(struct Process): Remove pipeline. Add pipe_host2tgt and pipe_tgt2host.
|
||||
(struct Pipeline): Remove pipe_host and pipe_target. Add thread,
|
||||
destroy, is_destroyed, pipe_host2tgt_path, pipe_tgt2host_path,
|
||||
pipe_host2tgt, pipe_tgt2host, queue, process.
|
||||
(max_pipeline_num): New static variable.
|
||||
(pipelines): Likewise.
|
||||
(max_event_num): Likewise.
|
||||
(non_signalled_events): Likewise.
|
||||
(errored_events): Likewise.
|
||||
(callbacks): Likewise.
|
||||
(cleanup): Do not check tmp_dirs before free.
|
||||
(start_critical_section): New static function.
|
||||
(finish_critical_section): Likewise.
|
||||
(pipeline_is_destroyed): Likewise.
|
||||
(maybe_invoke_callback): Likewise.
|
||||
(signal_event): Likewise.
|
||||
(get_event_result): Likewise.
|
||||
(COIBufferCopy): Rename arguments according to headers. Add asserts.
|
||||
Use process' main pipes, instead of pipeline's pipes. Signal completion
|
||||
event.
|
||||
(COIBufferCreate): Rename arguments according to headers. Add asserts.
|
||||
Use process' main pipes, instead of pipeline's pipes.
|
||||
(COIBufferCreateFromMemory): Rename arguments according to headers.
|
||||
Add asserts.
|
||||
(COIBufferDestroy): Rename arguments according to headers. Add asserts.
|
||||
Use process' main pipes, instead of pipeline's pipes.
|
||||
(COIBufferGetSinkAddress): Rename arguments according to headers.
|
||||
Add asserts.
|
||||
(COIBufferMap): Rename arguments according to headers. Add asserts.
|
||||
Signal completion event.
|
||||
(COIBufferRead): Likewise.
|
||||
(COIBufferSetState): Likewise.
|
||||
(COIBufferUnmap): Likewise.
|
||||
(COIBufferWrite): Likewise.
|
||||
(COIEngineGetCount): Add assert.
|
||||
(COIEngineGetHandle): Rename arguments according to headers.
|
||||
Add assert.
|
||||
(COIEventWait): Rename arguments according to headers. Add asserts.
|
||||
Implement waiting for events with zero or infinite timeout.
|
||||
(COIEventRegisterCallback): New function.
|
||||
(pipeline_thread_routine): New static function.
|
||||
(COIPipelineCreate): Create a new thread for the pipeline.
|
||||
(COIPipelineDestroy): Exit pipeline thread.
|
||||
(COIPipelineRunFunction): Add the function into pipeline's queue,
|
||||
instead running it here. Wait for it's completion in case of
|
||||
synchronous execution.
|
||||
(COIProcessCreateFromMemory): Rename arguments according to headers.
|
||||
Add asserts. Create process' main pipes, instead of pipeline's pipes.
|
||||
(COIProcessDestroy): Rename arguments according to headers.
|
||||
Add asserts. Destroy all undestroyed pipelines.
|
||||
(COIProcessGetFunctionHandles): Rename arguments according to headers.
|
||||
Add asserts. Use process' main pipes, instead of pipeline's pipes.
|
||||
Remove useless function names.
|
||||
(COIProcessLoadLibraryFromMemory): Add asserts. Use process' main
|
||||
pipes, instead of pipeline's pipes.
|
||||
(COIProcessUnloadLibrary): Likewise.
|
||||
(COIEngineGetInfo): Add assert.
|
||||
* runtime/emulator/coi_host.h (COIERRORN): New define.
|
||||
|
||||
2015-09-28 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
PR other/67652
|
||||
* runtime/offload_engine.cpp (Engine::init_process): Fix sizeof.
|
||||
|
||||
2015-09-08 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* Makefile.am (liboffloadmic_host_la_DEPENDENCIES): Remove libcoi_host
|
||||
and libmyo-client. liboffloadmic_host loads them dynamically.
|
||||
* Makefile.in: Regenerate.
|
||||
* doc/doxygen/header.tex: Merge from upstream, version 20150803
|
||||
<https://openmprtl.org/sites/default/files/liboffload_oss_20150803.tgz>.
|
||||
* runtime/cean_util.cpp: Likewise.
|
||||
* runtime/cean_util.h: Likewise.
|
||||
* runtime/coi/coi_client.cpp: Likewise.
|
||||
* runtime/coi/coi_client.h: Likewise.
|
||||
* runtime/coi/coi_server.cpp: Likewise.
|
||||
* runtime/coi/coi_server.h: Likewise.
|
||||
* runtime/compiler_if_host.cpp: Likewise.
|
||||
* runtime/compiler_if_host.h: Likewise.
|
||||
* runtime/compiler_if_target.cpp: Likewise.
|
||||
* runtime/compiler_if_target.h: Likewise.
|
||||
* runtime/dv_util.cpp: Likewise.
|
||||
* runtime/dv_util.h: Likewise.
|
||||
* runtime/liboffload_error.c: Likewise.
|
||||
* runtime/liboffload_error_codes.h: Likewise.
|
||||
* runtime/liboffload_msg.c: Likewise.
|
||||
* runtime/liboffload_msg.h: Likewise.
|
||||
* runtime/mic_lib.f90: Likewise.
|
||||
* runtime/offload.h: Likewise.
|
||||
* runtime/offload_common.cpp: Likewise.
|
||||
* runtime/offload_common.h: Likewise.
|
||||
* runtime/offload_engine.cpp: Likewise.
|
||||
* runtime/offload_engine.h: Likewise.
|
||||
* runtime/offload_env.cpp: Likewise.
|
||||
* runtime/offload_env.h: Likewise.
|
||||
* runtime/offload_host.cpp: Likewise.
|
||||
* runtime/offload_host.h: Likewise.
|
||||
* runtime/offload_iterator.h: Likewise.
|
||||
* runtime/offload_myo_host.cpp: Likewise.
|
||||
* runtime/offload_myo_host.h: Likewise.
|
||||
* runtime/offload_myo_target.cpp: Likewise.
|
||||
* runtime/offload_myo_target.h: Likewise.
|
||||
* runtime/offload_omp_host.cpp: Likewise.
|
||||
* runtime/offload_omp_target.cpp: Likewise.
|
||||
* runtime/offload_orsl.cpp: Likewise.
|
||||
* runtime/offload_orsl.h: Likewise.
|
||||
* runtime/offload_table.cpp: Likewise.
|
||||
* runtime/offload_table.h: Likewise.
|
||||
* runtime/offload_target.cpp: Likewise.
|
||||
* runtime/offload_target.h: Likewise.
|
||||
* runtime/offload_target_main.cpp: Likewise.
|
||||
* runtime/offload_timer.h: Likewise.
|
||||
* runtime/offload_timer_host.cpp: Likewise.
|
||||
* runtime/offload_timer_target.cpp: Likewise.
|
||||
* runtime/offload_trace.cpp: Likewise.
|
||||
* runtime/offload_trace.h: Likewise.
|
||||
* runtime/offload_util.cpp: Likewise.
|
||||
* runtime/offload_util.h: Likewise.
|
||||
* runtime/ofldbegin.cpp: Likewise.
|
||||
* runtime/ofldend.cpp: Likewise.
|
||||
* runtime/orsl-lite/include/orsl-lite.h: Likewise.
|
||||
* runtime/orsl-lite/lib/orsl-lite.c: Likewise.
|
||||
* runtime/use_mpss2.txt: Likewise.
|
||||
* include/coi/common/COIEngine_common.h: Merge from upstream, MPSS
|
||||
version 3.5
|
||||
<http://registrationcenter.intel.com/irc_nas/7445/mpss-src-3.5.tar>.
|
||||
* include/coi/common/COIEvent_common.h: Likewise.
|
||||
* include/coi/common/COIMacros_common.h: Likewise.
|
||||
* include/coi/common/COIPerf_common.h: Likewise.
|
||||
* include/coi/common/COIResult_common.h: Likewise.
|
||||
* include/coi/common/COISysInfo_common.h: Likewise.
|
||||
* include/coi/common/COITypes_common.h: Likewise.
|
||||
* include/coi/sink/COIBuffer_sink.h: Likewise.
|
||||
* include/coi/sink/COIPipeline_sink.h: Likewise.
|
||||
* include/coi/sink/COIProcess_sink.h: Likewise.
|
||||
* include/coi/source/COIBuffer_source.h: Likewise.
|
||||
* include/coi/source/COIEngine_source.h: Likewise.
|
||||
* include/coi/source/COIEvent_source.h: Likewise.
|
||||
* include/coi/source/COIPipeline_source.h: Likewise.
|
||||
* include/coi/source/COIProcess_source.h: Likewise.
|
||||
* include/myo/myo.h: Likewise.
|
||||
* include/myo/myoimpl.h: Likewise.
|
||||
* include/myo/myotypes.h: Likewise.
|
||||
* plugin/Makefile.am (myo_inc_dir): Remove.
|
||||
(libgomp_plugin_intelmic_la_CPPFLAGS): Do not define MYO_SUPPORT.
|
||||
(AM_CPPFLAGS): Likewise for offload_target_main.
|
||||
* plugin/Makefile.in: Regenerate.
|
||||
* runtime/emulator/coi_common.h: Update copyright years.
|
||||
(OFFLOAD_EMUL_KNC_NUM_ENV): Replace with ...
|
||||
(OFFLOAD_EMUL_NUM_ENV): ... this.
|
||||
(enum cmd_t): Add CMD_CLOSE_LIBRARY.
|
||||
* runtime/emulator/coi_device.cpp: Update copyright years.
|
||||
(COIProcessWaitForShutdown): Add space between string constants.
|
||||
Return handle to host in CMD_OPEN_LIBRARY.
|
||||
Support CMD_CLOSE_LIBRARY.
|
||||
* runtime/emulator/coi_device.h: Update copyright years.
|
||||
* runtime/emulator/coi_host.cpp: Update copyright years.
|
||||
(knc_engines_num): Replace with ...
|
||||
(num_engines): ... this.
|
||||
(init): Replace OFFLOAD_EMUL_KNC_NUM_ENV with OFFLOAD_EMUL_NUM_ENV.
|
||||
(COIEngineGetCount): Replace COI_ISA_KNC with COI_ISA_MIC, and
|
||||
knc_engines_num with num_engines.
|
||||
(COIEngineGetHandle): Likewise.
|
||||
(COIProcessCreateFromMemory): Add space between string constants.
|
||||
(COIProcessCreateFromFile): New function.
|
||||
(COIProcessLoadLibraryFromMemory): Rename arguments according to
|
||||
COIProcess_source.h. Return handle, received from target.
|
||||
(COIProcessUnloadLibrary): New function.
|
||||
(COIPipelineClearCPUMask): New function.
|
||||
(COIPipelineSetCPUMask): New function.
|
||||
(COIEngineGetInfo): New function.
|
||||
* runtime/emulator/coi_host.h: Update copyright years.
|
||||
* runtime/emulator/coi_version_asm.h: Regenerate.
|
||||
* runtime/emulator/coi_version_linker_script.map: Regenerate.
|
||||
* runtime/emulator/myo_client.cpp: Update copyright years.
|
||||
* runtime/emulator/myo_service.cpp: Update copyright years.
|
||||
(myoArenaRelease): New function.
|
||||
(myoArenaAcquire): New function.
|
||||
(myoArenaAlignedFree): New function.
|
||||
(myoArenaAlignedMalloc): New function.
|
||||
* runtime/emulator/myo_service.h: Update copyright years.
|
||||
* runtime/emulator/myo_version_asm.h: Regenerate.
|
||||
* runtime/emulator/myo_version_linker_script.map: Regenerate.
|
||||
|
||||
2015-08-24 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_version): New.
|
||||
(GOMP_OFFLOAD_load_image): Add version arg and check it.
|
||||
(GOMP_OFFLOAD_unload_image): Likewise.
|
||||
|
||||
2015-08-24 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/Makefile.am (include_src_dir): Set.
|
||||
[PLUGIN_HOST] (libgomp_plugin_intelmic_la_CPPFLAGS): Use it.
|
||||
* plugin/Makefile.in: Regenerate.
|
||||
* plugin/libgomp-plugin-intelmic.cpp: Include "gomp-constants.h".
|
||||
|
||||
2015-07-24 Micahel Darling <darlingm@gmail.com>
|
||||
|
||||
PR other/66259
|
||||
* configure: Reflects renaming of configure.in to configure.ac
|
||||
|
||||
2015-07-17 Nathan Sidwell <nathan@acm.org>
|
||||
Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (ImgDevAddrMap): Constify.
|
||||
(offload_image, GOMP_OFFLOAD_load_image,
|
||||
GOMP_OFFLOAD_unload_image): Constify target data.
|
||||
|
||||
2015-07-08 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/Makefile.am (main_target_image.h): Change type of data
|
||||
member of struct MainTargetImage to uint8_t.
|
||||
* plugin/Makefile.in: Regenerate.
|
||||
|
||||
2015-05-13 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
|
||||
|
||||
* Makefile.in: Regenerated with automake-1.11.6.
|
||||
* aclocal.m4: Likewise.
|
||||
* configure: Likewise.
|
||||
* plugin/Makefile.in: Likewise.
|
||||
* plugin/aclocal.m4: Likewise.
|
||||
* plugin/configure: Likewise.
|
||||
|
||||
2015-04-06 Ilya Verbin <ilya.verbin@intel.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp: Include map.
|
||||
(AddrVect, DevAddrVect, ImgDevAddrMap): New typedefs.
|
||||
(num_devices, num_images, address_table): New static vars.
|
||||
(num_libraries, lib_descrs): Remove static vars.
|
||||
(set_mic_lib_path): Rename to ...
|
||||
(init): ... this. Allocate address_table and get num_devices.
|
||||
(GOMP_OFFLOAD_get_num_devices): return num_devices.
|
||||
(load_lib_and_get_table): Remove static function.
|
||||
(offload_image): New static function.
|
||||
(GOMP_OFFLOAD_get_table): Remove function.
|
||||
(GOMP_OFFLOAD_load_image, GOMP_OFFLOAD_unload_image): New functions.
|
||||
|
||||
2015-01-15 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_name)
|
||||
(GOMP_OFFLOAD_get_caps, GOMP_OFFLOAD_fini_device): New functions.
|
||||
|
||||
2014-11-13 Ilya Verbin <ilya.verbin@intel.com>
|
||||
Andrey Turetskiy <andrey.turetskiy@intel.com>
|
||||
|
||||
* Makefile.in: Regenerate.
|
||||
* configure: Regenerate.
|
||||
* configure.ac: Add subdirectory 'plugin'.
|
||||
* plugin/Makefile.am: New file.
|
||||
* plugin/Makefile.in: New file, generated by automake.
|
||||
* plugin/aclocal.m4: New file, generated by aclocal.
|
||||
* plugin/configure: New file, generated by autoconf.
|
||||
* plugin/configure.ac: New file.
|
||||
* plugin/libgomp-plugin-intelmic.cpp: New file.
|
||||
* plugin/offload_target_main.cpp: New file.
|
||||
|
||||
2014-11-13 Kirill Yukhin <kirill.yukhin@intel.com>
|
||||
|
||||
Initial commit. Imported from upstream:
|
||||
https://www.openmprtl.org/sites/default/files/liboffload_oss.tgz
|
||||
* Makefile.am: New file.
|
||||
* Makefile.in: New file, generated by automake.
|
||||
* aclocal.m4: New file, generated by aclocal.
|
||||
* configure: New file, generated by autoconf.
|
||||
* configure.ac: New file.
|
||||
* configure.tgt: Ditto.
|
||||
* doc/doxygen/config: Ditto.
|
||||
* doc/doxygen/header.tex: Ditto.
|
||||
* include/coi/common/COIEngine_common.h: Ditto.
|
||||
* include/coi/common/COIMacros_common.h: Ditto.
|
||||
* include/coi/common/COIPerf_common.h : Ditto.
|
||||
* include/coi/common/COIResult_common.h : Ditto.
|
||||
* include/coi/common/COITypes_common.h: Ditto.
|
||||
* include/coi/sink/COIBuffer_sink.h: Ditto.
|
||||
* include/coi/sink/COIPipeline_sink.h: Ditto.
|
||||
* include/coi/sink/COIProcess_sink.h: Ditto.
|
||||
* include/coi/source/COIBuffer_source.h: Ditto.
|
||||
* include/coi/source/COIEngine_source.h: Ditto.
|
||||
* include/coi/source/COIEvent_source.h: Ditto.
|
||||
* include/coi/source/COIPipeline_source.h: Ditto.
|
||||
* include/coi/source/COIProcess_source.h: Ditto.
|
||||
* include/myo/myo.h: Ditto.
|
||||
* include/myo/myoimpl.h: Ditto.
|
||||
* include/myo/myotypes.h: Ditto.
|
||||
* liboffloadmic_host.spec.in: Ditto.
|
||||
* liboffloadmic_target.spec.in: Ditto.
|
||||
* runtime/cean_util.cpp: Ditto.
|
||||
* runtime/cean_util.h: Ditto.
|
||||
* runtime/coi/coi_client.cpp: Ditto.
|
||||
* runtime/coi/coi_client.h: Ditto.
|
||||
* runtime/coi/coi_server.cpp: Ditto.
|
||||
* runtime/coi/coi_server.h: Ditto.
|
||||
* runtime/compiler_if_host.cpp: Ditto.
|
||||
* runtime/compiler_if_host.h: Ditto.
|
||||
* runtime/compiler_if_target.cpp: Ditto.
|
||||
* runtime/compiler_if_target.h: Ditto.
|
||||
* runtime/dv_util.cpp: Ditto.
|
||||
* runtime/dv_util.h: Ditto.
|
||||
* runtime/emulator/coi_common.h: Ditto.
|
||||
* runtime/emulator/coi_device.cpp: Ditto.
|
||||
* runtime/emulator/coi_device.h: Ditto.
|
||||
* runtime/emulator/coi_host.cpp: Ditto.
|
||||
* runtime/emulator/coi_host.h: Ditto.
|
||||
* runtime/emulator/coi_version_asm.h: Ditto.
|
||||
* runtime/emulator/coi_version_linker_script.map: Ditto.
|
||||
* runtime/emulator/myo_client.cpp: Ditto.
|
||||
* runtime/emulator/myo_service.cpp: Ditto.
|
||||
* runtime/emulator/myo_service.h: Ditto.
|
||||
* runtime/emulator/myo_version_asm.h: Ditto.
|
||||
* runtime/emulator/myo_version_linker_script.map: Ditto.
|
||||
* runtime/liboffload_error.c: Ditto.
|
||||
* runtime/liboffload_error_codes.h: Ditto.
|
||||
* runtime/liboffload_msg.c: Ditto.
|
||||
* runtime/liboffload_msg.h: Ditto.
|
||||
* runtime/mic_lib.f90: Ditto.
|
||||
* runtime/offload.h: Ditto.
|
||||
* runtime/offload_common.cpp: Ditto.
|
||||
* runtime/offload_common.h: Ditto.
|
||||
* runtime/offload_engine.cpp: Ditto.
|
||||
* runtime/offload_engine.h: Ditto.
|
||||
* runtime/offload_env.cpp: Ditto.
|
||||
* runtime/offload_env.h: Ditto.
|
||||
* runtime/offload_host.cpp: Ditto.
|
||||
* runtime/offload_host.h: Ditto.
|
||||
* runtime/offload_myo_host.cpp: Ditto.
|
||||
* runtime/offload_myo_host.h: Ditto.
|
||||
* runtime/offload_myo_target.cpp: Ditto.
|
||||
* runtime/offload_myo_target.h: Ditto.
|
||||
* runtime/offload_omp_host.cpp: Ditto.
|
||||
* runtime/offload_omp_target.cpp: Ditto.
|
||||
* runtime/offload_orsl.cpp: Ditto.
|
||||
* runtime/offload_orsl.h: Ditto.
|
||||
* runtime/offload_table.cpp: Ditto.
|
||||
* runtime/offload_table.h: Ditto.
|
||||
* runtime/offload_target.cpp: Ditto.
|
||||
* runtime/offload_target.h: Ditto.
|
||||
* runtime/offload_target_main.cpp: Ditto.
|
||||
* runtime/offload_timer.h: Ditto.
|
||||
* runtime/offload_timer_host.cpp: Ditto.
|
||||
* runtime/offload_timer_target.cpp: Ditto.
|
||||
* runtime/offload_trace.cpp: Ditto.
|
||||
* runtime/offload_trace.h: Ditto.
|
||||
* runtime/offload_util.cpp: Ditto.
|
||||
* runtime/offload_util.h: Ditto.
|
||||
* runtime/ofldbegin.cpp: Ditto.
|
||||
* runtime/ofldend.cpp: Ditto.
|
||||
* runtime/orsl-lite/include/orsl-lite.h: Ditto.
|
||||
* runtime/orsl-lite/lib/orsl-lite.c: Ditto.
|
||||
* runtime/orsl-lite/version.txt: Ditto.
|
||||
* runtime/use_mpss2.txt: Ditto.
|
||||
|
||||
Copyright (C) 2014-2018 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved.
|
|
@ -1,160 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2014 Intel Corporation. All Rights Reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Intel Corporation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
|
||||
# Build plugin for Intel MIC
|
||||
SUBDIRS = . plugin
|
||||
|
||||
# Directories.
|
||||
build_dir = $(top_builddir)
|
||||
coi_inc_dir = $(top_srcdir)/include/coi
|
||||
libgomp_dir = $(build_dir)/../libgomp
|
||||
source_dir = $(top_srcdir)/runtime
|
||||
|
||||
# May be used by toolexeclibdir.
|
||||
gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
|
||||
libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
|
||||
|
||||
# Target list.
|
||||
if LIBOFFLOADMIC_HOST
|
||||
nodist_toolexeclib_HEADERS = liboffloadmic_host.spec
|
||||
toolexeclib_LTLIBRARIES = libcoi_host.la liboffloadmic_host.la
|
||||
nodist_libsubinclude_HEADERS = runtime/compiler_if_host.h
|
||||
ofld_obj =
|
||||
else # LIBOFFLOADMIC_TARGET
|
||||
nodist_toolexeclib_HEADERS = liboffloadmic_target.spec
|
||||
toolexeclib_LTLIBRARIES = libcoi_device.la liboffloadmic_target.la
|
||||
nodist_libsubinclude_HEADERS = runtime/compiler_if_target.h
|
||||
ofld_obj = ofldbegin.o ofldend.o
|
||||
endif
|
||||
|
||||
# Liboffloadmic.
|
||||
liboffloadmic_sources = runtime/dv_util.cpp \
|
||||
runtime/liboffload_error.c \
|
||||
runtime/liboffload_msg.c \
|
||||
runtime/offload_common.cpp \
|
||||
runtime/offload_table.cpp \
|
||||
runtime/offload_trace.cpp \
|
||||
runtime/offload_util.cpp
|
||||
|
||||
liboffloadmic_cppflags = -DLINUX -DCOI_LIBRARY_VERSION=2 -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -I$(coi_inc_dir) -I$(source_dir) -I$(libgomp_dir)
|
||||
|
||||
liboffloadmic_host_la_SOURCES = $(liboffloadmic_sources) \
|
||||
runtime/cean_util.cpp \
|
||||
runtime/coi/coi_client.cpp \
|
||||
runtime/compiler_if_host.cpp \
|
||||
runtime/offload_engine.cpp \
|
||||
runtime/offload_env.cpp \
|
||||
runtime/offload_host.cpp \
|
||||
runtime/offload_omp_host.cpp \
|
||||
runtime/offload_orsl.cpp \
|
||||
runtime/offload_timer_host.cpp \
|
||||
runtime/orsl-lite/lib/orsl-lite.c
|
||||
|
||||
liboffloadmic_host_la_CPPFLAGS = $(liboffloadmic_cppflags) -DHOST_LIBRARY=1
|
||||
liboffloadmic_host_la_LDFLAGS = @lt_cv_dlopen_libs@ -version-info 5:0:0
|
||||
|
||||
liboffloadmic_target_la_SOURCES = $(liboffloadmic_sources) \
|
||||
runtime/coi/coi_server.cpp \
|
||||
runtime/compiler_if_target.cpp \
|
||||
runtime/offload_omp_target.cpp \
|
||||
runtime/offload_target.cpp \
|
||||
runtime/offload_timer_target.cpp
|
||||
|
||||
liboffloadmic_target_la_CPPFLAGS = $(liboffloadmic_cppflags) -DHOST_LIBRARY=0
|
||||
liboffloadmic_target_la_LDFLAGS = @lt_cv_dlopen_libs@ -version-info 5:0:0
|
||||
liboffloadmic_target_la_LIBADD = libcoi_device.la
|
||||
liboffloadmic_target_la_DEPENDENCIES = $(liboffloadmic_target_la_LIBADD)
|
||||
|
||||
# Emulator.
|
||||
libcoi_host_la_SOURCES = runtime/emulator/coi_host.cpp
|
||||
libcoi_device_la_SOURCES = runtime/emulator/coi_device.cpp
|
||||
|
||||
libcoi_host_la_DEPENDENCIES = runtime/emulator/coi_version_linker_script.map
|
||||
libcoi_device_la_DEPENDENCIES = runtime/emulator/coi_version_linker_script.map
|
||||
|
||||
libcoi_host_la_CPPFLAGS = -I$(coi_inc_dir)
|
||||
libcoi_device_la_CPPFLAGS = -I$(coi_inc_dir)
|
||||
|
||||
libcoi_host_la_LDFLAGS = -lrt -Wl,--version-script=$(source_dir)/emulator/coi_version_linker_script.map
|
||||
libcoi_device_la_LDFLAGS = -lrt -Wl,--version-script=$(source_dir)/emulator/coi_version_linker_script.map
|
||||
|
||||
# ofldbegin, ofldend
|
||||
all-local: $(ofld_obj)
|
||||
|
||||
ofldbegin.o: runtime/ofldbegin.cpp
|
||||
$(CXXCOMPILE) $(liboffloadmic_target_la_CPPFLAGS) -c $< -o $@
|
||||
|
||||
ofldend.o: runtime/ofldend.cpp
|
||||
$(CXXCOMPILE) $(liboffloadmic_target_la_CPPFLAGS) -c $< -o $@
|
||||
|
||||
# Work around what appears to be a GNU make bug handling MAKEFLAGS
|
||||
# values defined in terms of make variables, as is the case for CC and
|
||||
# friends when we are called from the top level Makefile.
|
||||
AM_MAKEFLAGS = \
|
||||
"AR_FLAGS=$(AR_FLAGS)" \
|
||||
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
|
||||
"CFLAGS=$(CFLAGS)" \
|
||||
"CXXFLAGS=$(CXXFLAGS)" \
|
||||
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
|
||||
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
|
||||
"INSTALL=$(INSTALL)" \
|
||||
"INSTALL_DATA=$(INSTALL_DATA)" \
|
||||
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
|
||||
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
|
||||
"JC1FLAGS=$(JC1FLAGS)" \
|
||||
"LDFLAGS=$(LDFLAGS)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
|
||||
"MAKE=$(MAKE)" \
|
||||
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
|
||||
"SHELL=$(SHELL)" \
|
||||
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
|
||||
"exec_prefix=$(exec_prefix)" \
|
||||
"infodir=$(infodir)" \
|
||||
"libdir=$(libdir)" \
|
||||
"prefix=$(prefix)" \
|
||||
"includedir=$(includedir)" \
|
||||
"AR=$(AR)" \
|
||||
"AS=$(AS)" \
|
||||
"LD=$(LD)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"NM=$(NM)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"DESTDIR=$(DESTDIR)"
|
||||
|
||||
MAKEOVERRIDES =
|
||||
|
||||
include $(top_srcdir)/../multilib.am
|
File diff suppressed because it is too large
Load diff
1180
liboffloadmic/aclocal.m4
vendored
1180
liboffloadmic/aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
17512
liboffloadmic/configure
vendored
17512
liboffloadmic/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,143 +0,0 @@
|
|||
# Copyright (c) 2014 Intel Corporation. All Rights Reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Intel Corporation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Process this file with autoconf to produce a configure script, like so:
|
||||
# aclocal -I .. -I ../config && autoconf && automake
|
||||
|
||||
AC_INIT([MIC Offload Runtime Library], [1.0], ,[liboffloadmic])
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
target_alias=${target_alias-$host_alias}
|
||||
AC_SUBST(target_alias)
|
||||
|
||||
AM_INIT_AUTOMAKE(foreign no-dist)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_CONFIG_FILES([Makefile liboffloadmic_host.spec liboffloadmic_target.spec])
|
||||
AM_ENABLE_MULTILIB(, ..)
|
||||
AC_CONFIG_SUBDIRS(plugin)
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_HEADERS([mm_malloc.h], [], [AC_MSG_ERROR(["Couldn't find mm_malloc.h"])])
|
||||
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
|
||||
|
||||
# Get target configure.
|
||||
. ${srcdir}/configure.tgt
|
||||
if test -n "$UNSUPPORTED"; then
|
||||
AC_MSG_ERROR([Configuration ${target} is unsupported])
|
||||
fi
|
||||
|
||||
if test "${multilib}" = "yes"; then
|
||||
multilib_arg="--enable-multilib"
|
||||
else
|
||||
multilib_arg=
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
|
||||
AC_ARG_ENABLE([version-specific-runtime-libs],
|
||||
AC_HELP_STRING([--enable-version-specific-runtime-libs],
|
||||
[Specify that runtime libraries should be installed in a compiler-specific directory]),
|
||||
[case "$enableval" in
|
||||
yes) enable_version_specific_runtime_libs=yes ;;
|
||||
no) enable_version_specific_runtime_libs=no ;;
|
||||
*) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
|
||||
esac],
|
||||
[enable_version_specific_runtime_libs=no])
|
||||
AC_MSG_RESULT($enable_version_specific_runtime_libs)
|
||||
|
||||
# Make sure liboffloadmic is enabled
|
||||
case "$enable_liboffloadmic" in
|
||||
host | target)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Liboffloadmic is disabled]) ;;
|
||||
esac
|
||||
AM_CONDITIONAL(LIBOFFLOADMIC_HOST, [test x"$enable_liboffloadmic" = xhost])
|
||||
|
||||
GCC_WITH_TOOLEXECLIBDIR
|
||||
|
||||
# Calculate toolexeclibdir.
|
||||
# Also toolexecdir, though it's only used in toolexeclibdir.
|
||||
case ${enable_version_specific_runtime_libs} in
|
||||
yes)
|
||||
# Need the gcc compiler version to know where to install libraries
|
||||
# and header files if --enable-version-specific-runtime-libs option
|
||||
# is selected.
|
||||
toolexecdir='$(libdir)/gcc/$(target_alias)'
|
||||
toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
|
||||
;;
|
||||
no)
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
# Install a library built with a cross compiler in tooldir, not libdir.
|
||||
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||
case ${with_toolexeclibdir} in
|
||||
no)
|
||||
toolexeclibdir='$(toolexecdir)/lib'
|
||||
;;
|
||||
*)
|
||||
toolexeclibdir=${with_toolexeclibdir}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
multi_os_directory=`$CC -print-multi-os-directory`
|
||||
case $multi_os_directory in
|
||||
.) ;; # Avoid trailing /.
|
||||
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_LIBTOOL_DLOPEN
|
||||
AM_PROG_LIBTOOL
|
||||
# Forbid libtool to hardcode RPATH, because we want to be able to specify
|
||||
# library search directory using LD_LIBRARY_PATH
|
||||
hardcode_into_libs=no
|
||||
AC_SUBST(toolexecdir)
|
||||
AC_SUBST(toolexeclibdir)
|
||||
|
||||
AC_SUBST(lt_cv_dlopen_libs)
|
||||
|
||||
if test $enable_shared = yes; then
|
||||
link_offloadmic_host="-loffloadmic_host %{static: $LIBS}"
|
||||
link_offloadmic_target="-loffloadmic_target %{static: $LIBS}"
|
||||
else
|
||||
link_offloadmic_host="-loffloadmic_host $LIBS"
|
||||
link_offloadmic_target="-loffloadmic_target $LIBS"
|
||||
fi
|
||||
AC_SUBST(link_offloadmic_host)
|
||||
AC_SUBST(link_offloadmic_target)
|
||||
|
||||
# Determine what GCC version number to use in filesystem paths.
|
||||
GCC_BASE_VER
|
||||
|
||||
# Must be last
|
||||
AC_OUTPUT
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright (c) 2014 Intel Corporation. All Rights Reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Intel Corporation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Disable Offload Runtime library for non x86 architecture.
|
||||
case "${target}" in
|
||||
x86_64-*-linux*)
|
||||
;;
|
||||
i?86-*-linux*)
|
||||
;;
|
||||
*-*-*)
|
||||
UNSUPPORTED=1 ;;
|
||||
esac
|
||||
|
||||
# Disable liboffloadmic on non POSIX hosted systems.
|
||||
. ${srcdir}/../config/target-posix
|
File diff suppressed because it is too large
Load diff
|
@ -1,90 +0,0 @@
|
|||
% Latex header for doxygen 1.8.3.1
|
||||
\documentclass{book}
|
||||
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm]{geometry}
|
||||
\usepackage{makeidx}
|
||||
\usepackage{natbib}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{multicol}
|
||||
\usepackage{float}
|
||||
\usepackage{listings}
|
||||
\usepackage{color}
|
||||
\usepackage{ifthen}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{textcomp}
|
||||
\usepackage{alltt}
|
||||
\usepackage{ifpdf}
|
||||
\ifpdf
|
||||
\usepackage[pdftex,
|
||||
pagebackref=true,
|
||||
colorlinks=true,
|
||||
linkcolor=blue,
|
||||
unicode
|
||||
]{hyperref}
|
||||
\else
|
||||
\usepackage[ps2pdf,
|
||||
pagebackref=true,
|
||||
colorlinks=true,
|
||||
linkcolor=blue,
|
||||
unicode
|
||||
]{hyperref}
|
||||
\usepackage{pspicture}
|
||||
\fi
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{mathptmx}
|
||||
\usepackage[scaled=.90]{helvet}
|
||||
\usepackage{courier}
|
||||
\usepackage{sectsty}
|
||||
\usepackage{amssymb}
|
||||
\usepackage[titles]{tocloft}
|
||||
\usepackage{doxygen}
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancy}
|
||||
\lstset{language=C++,inputencoding=utf8,basicstyle=\footnotesize,breaklines=true,breakatwhitespace=true,tabsize=4,numbers=left }
|
||||
\makeindex
|
||||
\setcounter{tocdepth}{3}
|
||||
\renewcommand{\footrulewidth}{0.4pt}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\hfuzz=15pt
|
||||
\setlength{\emergencystretch}{15pt}
|
||||
\hbadness=750
|
||||
\tolerance=750
|
||||
\begin{document}
|
||||
\hypersetup{pageanchor=false,citecolor=blue}
|
||||
\begin{titlepage}
|
||||
\vspace*{7cm}
|
||||
\begin{center}
|
||||
{\Large Intel\textsuperscript{\textregistered} Offload Runtime Library }\\
|
||||
\vspace*{1cm}
|
||||
{\large Generated by Doxygen $doxygenversion }\\
|
||||
\vspace*{0.5cm}
|
||||
{\small $datetime }\\
|
||||
\end{center}
|
||||
\end{titlepage}
|
||||
|
||||
{\bf FTC Optimization Notice}
|
||||
|
||||
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for
|
||||
optimizations that are not unique to Intel microprocessors. These optimizations include SSE2,
|
||||
SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the
|
||||
availability, functionality, or effectiveness of any optimization on microprocessors not
|
||||
manufactured by Intel.
|
||||
|
||||
Microprocessor-dependent optimizations in this product are intended for use with Intel
|
||||
microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for
|
||||
Intel microprocessors. Please refer to the applicable product User and Reference Guides for
|
||||
more information regarding the specific instruction sets covered by this notice.
|
||||
|
||||
Notice revision \#20110804
|
||||
|
||||
\vspace*{0.5cm}
|
||||
|
||||
{\bf Trademarks}
|
||||
|
||||
Intel, Xeon, and Intel Xeon Phi are trademarks of Intel Corporation in the U.S. and/or other countries.
|
||||
|
||||
This document is Copyright \textcopyright 2014-2016, Intel Corporation. All rights reserved.
|
||||
|
||||
\pagenumbering{roman}
|
||||
\tableofcontents
|
||||
\pagenumbering{arabic}
|
||||
\hypersetup{pageanchor=true,citecolor=blue}
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIENGINE_COMMON_H
|
||||
#define _COIENGINE_COMMON_H
|
||||
|
||||
/** @ingroup COIEngine
|
||||
* @addtogroup COIEnginecommon
|
||||
@{
|
||||
* @file common/COIEngine_common.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#define COI_MAX_ISA_x86_64_DEVICES 128
|
||||
#define COI_MAX_ISA_MIC_DEVICES 128
|
||||
#define COI_MAX_ISA_KNF_DEVICES 0
|
||||
#define COI_MAX_ISA_KNC_DEVICES COI_MAX_ISA_MIC_DEVICES
|
||||
#define COI_MAX_ISA_KNL_DEVICES COI_MAX_ISA_MIC_DEVICES
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// List of ISA types of supported engines.
|
||||
///
|
||||
typedef enum
|
||||
{
|
||||
COI_DEVICE_INVALID = 0, ///< Represents an invalid device type.
|
||||
COI_DEVICE_SOURCE, ///< The engine from which offload originates
|
||||
COI_DEVICE_MIC, ///< Special value used to represent any device
|
||||
///< in the Intel(R) Many Integrated Core family.
|
||||
COI_DEVICE_DEPRECATED_0, ///< Placeholder for L1OM devices (deprecated).
|
||||
COI_DEVICE_KNC, ///< K1OM devices (Knigts Corner).
|
||||
COI_DEVICE_KNL, ///< Knights Landing devices
|
||||
COI_DEVICE_MAX,
|
||||
COI_DEVICE_KNF = COI_DEVICE_DEPRECATED_0
|
||||
} COI_DEVICE_TYPE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// List of deprecated device types for backward compatibility
|
||||
///
|
||||
#define COI_ISA_INVALID COI_DEVICE_INVALID
|
||||
#define COI_ISA_x86_64 COI_DEVICE_SOURCE
|
||||
#define COI_ISA_MIC COI_DEVICE_MIC
|
||||
#define COI_ISA_KNF COI_DEVICE_KNF
|
||||
#define COI_ISA_KNC COI_DEVICE_KNC
|
||||
|
||||
typedef COI_DEVICE_TYPE COI_ISA_TYPE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Get the information about the COIEngine executing this function call.
|
||||
///
|
||||
/// @param out_pType
|
||||
/// [out] The COI_DEVICE_TYPE of the engine.
|
||||
///
|
||||
/// @param out_pIndex
|
||||
/// [out] The zero-based index of this engine in the collection of
|
||||
/// engines of the ISA returned in out_pType.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if any of the parameters are NULL.
|
||||
///
|
||||
/// @return COI_SUCCESS
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEngineGetIndex(
|
||||
COI_DEVICE_TYPE *out_pType,
|
||||
uint32_t *out_pIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIENGINE_COMMON_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIEVENT_COMMON_H
|
||||
#define _COIEVENT_COMMON_H
|
||||
|
||||
/** @ingroup COIEvent
|
||||
* @addtogroup COIEventcommon
|
||||
@{
|
||||
* @file common/COIEvent_common.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Signal one shot user event. User events created on source can be
|
||||
/// signaled from both sink and source. This fires the event and wakes up
|
||||
/// threads waiting on COIEventWait.
|
||||
///
|
||||
/// Note: For events that are not registered or already signaled this call
|
||||
/// will behave as a NOP. Users need to make sure that they pass valid
|
||||
/// events on the sink side.
|
||||
///
|
||||
/// @param in_Event
|
||||
/// Event Handle to be signaled.
|
||||
///
|
||||
/// @return COI_INVAILD_HANDLE if in_Event was not a User event.
|
||||
///
|
||||
/// @return COI_ERROR if the signal fails to be sent from the sink.
|
||||
///
|
||||
/// @return COI_SUCCESS if the event was successfully signaled or ignored.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT COIEventSignalUserEvent(COIEVENT in_Event);
|
||||
///
|
||||
///
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIEVENT_COMMON_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIMACROS_COMMON_H
|
||||
#define _COIMACROS_COMMON_H
|
||||
|
||||
#include <string.h>
|
||||
#include "../source/COIPipeline_source.h"
|
||||
#include "../common/COITypes_common.h"
|
||||
|
||||
/// @file common/COIMacros_common.h
|
||||
/// Commonly used macros
|
||||
|
||||
// Note that UNUSUED_ATTR means that it is "possibly" unused, not "definitely".
|
||||
// This should compile out in release mode if indeed it is unused.
|
||||
#define UNUSED_ATTR __attribute__((unused))
|
||||
#include <sched.h>
|
||||
#ifndef UNREFERENCED_CONST_PARAM
|
||||
#define UNREFERENCED_CONST_PARAM(P) { void* x UNUSED_ATTR = \
|
||||
(void*)(uint64_t)P; \
|
||||
}
|
||||
#endif
|
||||
|
||||
// This seems to work on everything.
|
||||
#ifndef UNREFERENCED_PARAM
|
||||
#define UNREFERENCED_PARAM(P) (P = P)
|
||||
#endif
|
||||
|
||||
#ifndef SYMBOL_VERSION
|
||||
|
||||
/* Linux support: */
|
||||
|
||||
#define SYMBOL_VERSION( SYMBOL , VERSION ) SYMBOL ## VERSION
|
||||
|
||||
#endif
|
||||
|
||||
/* The following are static inline definitions of functions used for manipulating
|
||||
COI_CPU_MASK info (The COI_CPU_MASK type is declared as an array of 16 uint64_t's
|
||||
in COITypes_common.h "typedef uint64_t COI_CPU_MASK[16]").
|
||||
|
||||
These static inlined functions are intended on being roughly the same as the Linux
|
||||
CPU_* macros defined in sched.h - with the important difference being a different
|
||||
fundamental type difference: cpu_set_t versus COI_CPU_MASK.
|
||||
|
||||
The motivation for writing this code was to ease portability on the host side of COI
|
||||
applications to both Windows and Linux.
|
||||
*/
|
||||
|
||||
/* Roughly equivalent to CPU_ISSET(). */
|
||||
static inline uint64_t COI_CPU_MASK_ISSET(int bitNumber, const COI_CPU_MASK cpu_mask)
|
||||
{
|
||||
if ((size_t)bitNumber < sizeof(COI_CPU_MASK) * 8)
|
||||
return ((cpu_mask)[bitNumber / 64] & (((uint64_t)1) << (bitNumber % 64)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_SET(). */
|
||||
static inline void COI_CPU_MASK_SET(int bitNumber, COI_CPU_MASK cpu_mask)
|
||||
{
|
||||
if ((size_t)bitNumber < sizeof(COI_CPU_MASK) * 8)
|
||||
((cpu_mask)[bitNumber / 64] |= (((uint64_t)1) << (bitNumber % 64)));
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_ZERO(). */
|
||||
static inline void COI_CPU_MASK_ZERO(COI_CPU_MASK cpu_mask)
|
||||
{
|
||||
memset(cpu_mask, 0, sizeof(COI_CPU_MASK));
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_AND(). */
|
||||
static inline void COI_CPU_MASK_AND(COI_CPU_MASK dst, const COI_CPU_MASK src1, const COI_CPU_MASK src2)
|
||||
{
|
||||
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(dst[0]);
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < loopIterations; ++i)
|
||||
dst[i] = src1[i] & src2[i];
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_XOR(). */
|
||||
static inline void COI_CPU_MASK_XOR(COI_CPU_MASK dst, const COI_CPU_MASK src1, const COI_CPU_MASK src2)
|
||||
{
|
||||
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(dst[0]);
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < loopIterations; ++i)
|
||||
dst[i] = src1[i] ^ src2[i];
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_OR(). */
|
||||
static inline void COI_CPU_MASK_OR(COI_CPU_MASK dst, const COI_CPU_MASK src1, const COI_CPU_MASK src2)
|
||||
{
|
||||
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(dst[0]);
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < loopIterations; ++i)
|
||||
dst[i] = src1[i] | src2[i];
|
||||
}
|
||||
|
||||
/* Utility function for COI_CPU_MASK_COUNT() below. */
|
||||
static inline int __COI_CountBits(uint64_t n)
|
||||
{
|
||||
int cnt = 0;
|
||||
|
||||
for (; n; cnt++)
|
||||
n &= (n - 1);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_COUNT(). */
|
||||
static inline int COI_CPU_MASK_COUNT(const COI_CPU_MASK cpu_mask)
|
||||
{
|
||||
int cnt = 0;
|
||||
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(cpu_mask[0]);
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < loopIterations; ++i)
|
||||
{
|
||||
cnt += __COI_CountBits(cpu_mask[i]);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Roughly equivalent to CPU_EQUAL(). */
|
||||
static inline int COI_CPU_MASK_EQUAL(const COI_CPU_MASK cpu_mask1, const COI_CPU_MASK cpu_mask2)
|
||||
{
|
||||
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(cpu_mask1[0]);
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < loopIterations; ++i)
|
||||
{
|
||||
if (cpu_mask1[i] != cpu_mask2[i])
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Utility function to translate from cpu_set * to COI_CPU_MASK. */
|
||||
static inline void COI_CPU_MASK_XLATE(COI_CPU_MASK dest, const cpu_set_t *src)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
COI_CPU_MASK_ZERO(dest);
|
||||
#if 0
|
||||
/* Slightly slower version than the following #else/#endif block. Left here only to
|
||||
document the intent of the code. */
|
||||
for (i = 0; i < sizeof(cpu_set_t) * 8; ++i)
|
||||
if (CPU_ISSET(i, src))
|
||||
COI_CPU_MASK_SET(i, dest);
|
||||
#else
|
||||
for (i = 0; i < sizeof(COI_CPU_MASK) / sizeof(dest[0]); ++i)
|
||||
{
|
||||
for (j = 0; j < 64; ++j)
|
||||
{
|
||||
if (CPU_ISSET(i * 64 + j, src))
|
||||
dest[i] |= ((uint64_t)1) << j;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Utility function to translate from COI_CPU_MASK to cpu_set *. */
|
||||
static inline void COI_CPU_MASK_XLATE_EX(cpu_set_t *dest, const COI_CPU_MASK src)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
CPU_ZERO(dest);
|
||||
#if 0
|
||||
/* Slightly slower version than the following #else/#endif block. Left here only to
|
||||
document the intent of the code. */
|
||||
for (i = 0; i < sizeof(COI_CPU_MASK) * 8; ++i)
|
||||
if (COI_CPU_MASK_ISSET(i, src))
|
||||
CPU_SET(i, dest);
|
||||
#else
|
||||
for (i = 0; i < sizeof(COI_CPU_MASK) / sizeof(src[0]); ++i)
|
||||
{
|
||||
const uint64_t cpu_mask = src[i];
|
||||
|
||||
for (j = 0; j < 64; ++j)
|
||||
{
|
||||
const uint64_t bit = ((uint64_t)1) << j;
|
||||
|
||||
if (bit & cpu_mask)
|
||||
CPU_SET(i * 64 + j, dest);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* _COIMACROS_COMMON_H */
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIPERF_COMMON_H
|
||||
#define _COIPERF_COMMON_H
|
||||
|
||||
/** @ingroup COIPerf
|
||||
* @addtogroup COIPerfCommon
|
||||
@{
|
||||
|
||||
* @file common/COIPerf_common.h
|
||||
* Performance Analysis API */
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#include "../common/COITypes_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns a performance counter value
|
||||
///
|
||||
/// This function returns a performance counter value that increments
|
||||
/// at a constant rate for all time and is coherent across all cores.
|
||||
///
|
||||
/// @return Current performance counter value or 0 if no performance counter
|
||||
///// is available
|
||||
///
|
||||
///
|
||||
COIACCESSAPI
|
||||
uint64_t COIPerfGetCycleCounter(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns the calculated system frequency in hertz.
|
||||
///
|
||||
/// @return Current system frequency in hertz.
|
||||
///
|
||||
COIACCESSAPI
|
||||
uint64_t COIPerfGetCycleFrequency(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/*! @} */
|
||||
|
||||
#endif /* _COIPERF_COMMON_H */
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIRESULT_COMMON_H
|
||||
#define _COIRESULT_COMMON_H
|
||||
|
||||
/** @ingroup COIResult
|
||||
* @addtogroup COIResultCommon
|
||||
@{
|
||||
|
||||
* @file common/COIResult_common.h
|
||||
* Result codes and definitions. */
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum COIRESULT
|
||||
{
|
||||
COI_SUCCESS = 0, ///< The function succeeded without error.
|
||||
COI_ERROR, ///< Unspecified error.
|
||||
COI_NOT_INITIALIZED, ///< The function was called before the
|
||||
///< system was initialized.
|
||||
COI_ALREADY_INITIALIZED, ///< The function was called after the
|
||||
///< system was initialized.
|
||||
COI_ALREADY_EXISTS, ///< Cannot complete the request due to
|
||||
///< the existence of a similar object.
|
||||
COI_DOES_NOT_EXIST, ///< The specified object was not found.
|
||||
COI_INVALID_POINTER, ///< One of the provided addresses was not
|
||||
///< valid.
|
||||
COI_OUT_OF_RANGE, ///< One of the arguments contains a value
|
||||
///< that is invalid.
|
||||
COI_NOT_SUPPORTED, ///< This function is not currently
|
||||
///< supported as used.
|
||||
COI_TIME_OUT_REACHED, ///< The specified time out caused the
|
||||
///< function to abort.
|
||||
COI_MEMORY_OVERLAP, ///< The source and destination range
|
||||
///< specified overlaps for the same
|
||||
///< buffer.
|
||||
COI_ARGUMENT_MISMATCH, ///< The specified arguments are not
|
||||
///< compatible.
|
||||
COI_SIZE_MISMATCH, ///< The specified size does not match the
|
||||
///< expected size.
|
||||
COI_OUT_OF_MEMORY, ///< The function was unable to allocate
|
||||
///< the required memory.
|
||||
COI_INVALID_HANDLE, ///< One of the provided handles was not
|
||||
///< valid.
|
||||
COI_RETRY, ///< This function currently can't
|
||||
///< complete, but might be able to later.
|
||||
COI_RESOURCE_EXHAUSTED, ///< The resource was not large enough.
|
||||
COI_ALREADY_LOCKED, ///< The object was expected to be
|
||||
///< unlocked, but was locked.
|
||||
COI_NOT_LOCKED, ///< The object was expected to be locked,
|
||||
///< but was unlocked.
|
||||
COI_MISSING_DEPENDENCY, ///< One or more dependent components
|
||||
///< could not be found.
|
||||
COI_UNDEFINED_SYMBOL, ///< One or more symbols the component
|
||||
///< required was not defined in any
|
||||
///< library.
|
||||
COI_PENDING, ///< Operation is not finished
|
||||
COI_BINARY_AND_HARDWARE_MISMATCH, ///< A specified binary will not run on
|
||||
///< the specified hardware.
|
||||
COI_PROCESS_DIED,
|
||||
COI_INVALID_FILE, ///< The file is invalid for its intended
|
||||
///< usage in the function.
|
||||
COI_EVENT_CANCELED, ///< Event wait on a user event that
|
||||
///< was unregistered or is being
|
||||
///< unregistered returns
|
||||
///< COI_EVENT_CANCELED.
|
||||
COI_VERSION_MISMATCH, ///< The version of Intel(R) Coprocessor
|
||||
///< Offload Infrastructure on the host
|
||||
///< is not compatible with the version
|
||||
///< on the device.
|
||||
COI_BAD_PORT, ///< The port that the host is set to
|
||||
///< connect to is invalid.
|
||||
COI_AUTHENTICATION_FAILURE, ///< The daemon was unable to authenticate
|
||||
///< the user that requested an engine.
|
||||
///< Only reported if daemon is set up for
|
||||
///< authorization. Is also reported in
|
||||
///< Windows if host cannot find user.
|
||||
COI_COMM_NOT_INITIALIZED, ///< The function was called before the
|
||||
///< comm was initialized.
|
||||
COI_INCORRECT_FORMAT, ///< Format of data is incorrect
|
||||
COI_NUM_RESULTS ///< Reserved, do not use.
|
||||
} COIRESULT;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns the string version of the passed in COIRESULT. Thus if
|
||||
/// COI_RETRY is passed in, this function returns the string "COI_RETRY". If
|
||||
/// the error code passed ins is not valid then "COI_ERROR" will be returned.
|
||||
///
|
||||
/// @param in_ResultCode
|
||||
/// [in] COIRESULT code to return the string version of.
|
||||
///
|
||||
/// @return String version of the passed in COIRESULT code.
|
||||
///
|
||||
COIACCESSAPI
|
||||
const char *
|
||||
COIResultGetName(
|
||||
COIRESULT in_ResultCode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIRESULT_COMMON_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COISYSINFO_COMMON_H
|
||||
#define _COISYSINFO_COMMON_H
|
||||
|
||||
/** @ingroup COISysInfo
|
||||
* @addtogroup COISysInfoCommon
|
||||
@{
|
||||
* @file common/COISysInfo_common.h
|
||||
* This interface allows developers to query the platform for system level
|
||||
* information. */
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#include "../common/COITypes_common.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#define INITIAL_APIC_ID_BITS 0xFF000000 // EBX[31:24] unique APIC ID
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \fn uint32_t COISysGetAPICID(void)
|
||||
/// @return The Advanced Programmable Interrupt Controller (APIC) ID of
|
||||
/// the hardware thread on which the caller is running.
|
||||
///
|
||||
/// @warning APIC IDs are unique to each hardware thread within a processor,
|
||||
/// but may not be sequential.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetAPICID(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The number of cores exposed by the processor on which the caller is
|
||||
/// running. Returns 0 if there is an error loading the processor info.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetCoreCount(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The number of hardware threads exposed by the processor on which
|
||||
/// the caller is running. Returns 0 if there is an error loading processor
|
||||
/// info.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetHardwareThreadCount(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The index of the hardware thread on which the caller is running.
|
||||
///
|
||||
/// The indexes of neighboring hardware threads will differ by a value of one
|
||||
/// and are within the range zero through COISysGetHardwareThreadCount()-1.
|
||||
/// Returns ((uint32_t)-1) if there was an error loading processor info.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetHardwareThreadIndex(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The index of the core on which the caller is running.
|
||||
///
|
||||
/// The indexes of neighboring cores will differ by a value of one and are
|
||||
/// within the range zero through COISysGetCoreCount()-1. Returns ((uint32_t)-1)
|
||||
/// if there was an error loading processor info.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetCoreIndex(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The number of level 2 caches within the processor on which the
|
||||
/// caller is running. Returns ((uint32_t)-1) if there was an error loading
|
||||
/// processor info.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetL2CacheCount(void);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// @return The index of the level 2 cache on which the caller is running.
|
||||
/// Returns ((uint32_t)-1) if there was an error loading processor info.
|
||||
///
|
||||
/// The indexes of neighboring cores will differ by a value of one and are
|
||||
/// within the range zero through COISysGetL2CacheCount()-1.
|
||||
COIACCESSAPI
|
||||
uint32_t COISysGetL2CacheIndex(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/*! @} */
|
||||
|
||||
#endif /* _COISYSINFO_COMMON_H */
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COITYPES_COMMON_H
|
||||
#define _COITYPES_COMMON_H
|
||||
|
||||
/** @ingroup COITypes
|
||||
* @addtogroup COITypesSource
|
||||
@{
|
||||
|
||||
* @file common/COITypes_common.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#include <stdint.h>
|
||||
#include <wchar.h>
|
||||
#define COIACCESSAPI /* nothing */
|
||||
#define COIACCESSAPI2 /* nothing */
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct coievent
|
||||
{
|
||||
uint64_t opaque[2];
|
||||
};
|
||||
|
||||
typedef struct coiprocess *COIPROCESS;
|
||||
typedef struct coipipeline *COIPIPELINE;
|
||||
typedef struct coifunction *COIFUNCTION;
|
||||
typedef struct coiengine *COIENGINE;
|
||||
typedef struct coievent COIEVENT;
|
||||
typedef struct coibuffer *COIBUFFER;
|
||||
typedef struct coilibrary *COILIBRARY;
|
||||
typedef struct coimapinst *COIMAPINSTANCE;
|
||||
|
||||
typedef uint64_t COI_CPU_MASK[16];
|
||||
|
||||
/**
|
||||
* On Windows, coi_wchar_t is a uint32_t. On Windows, wchar_t is 16 bits wide, and on Linux it is 32 bits wide, so uint32_t is used for portability.
|
||||
*/
|
||||
typedef wchar_t coi_wchar_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COITYPES_COMMON_H */
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIBUFFER_SINK_H
|
||||
#define _COIBUFFER_SINK_H
|
||||
|
||||
/** @ingroup COIBuffer
|
||||
* @addtogroup COIBufferSink
|
||||
@{
|
||||
|
||||
* @file sink\COIBuffer_sink.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Adds a reference to the memory of a buffer. The memory of the buffer
|
||||
/// will remain on the device until both a corresponding COIBufferReleaseRef()
|
||||
/// call is made and the run function that delivered the buffer returns.
|
||||
///
|
||||
/// Running this API in a thread spawned within the run function is not
|
||||
/// supported and will cause unpredictable results and may cause data corruption.
|
||||
///
|
||||
/// @warning 1.It is possible for enqueued run functions to be unable to
|
||||
/// execute due to all card memory being occupied by AddRef'd
|
||||
/// buffers. As such, it is important that whenever a buffer is
|
||||
/// AddRef'd that there be no dependencies on future run functions
|
||||
/// for progress to be made towards releasing the buffer.
|
||||
/// 2.It is important that AddRef is called within the scope of
|
||||
/// run function that carries the buffer to be AddRef'd.
|
||||
///
|
||||
/// @param in_pBuffer
|
||||
/// [in] Pointer to the start of a buffer being AddRef'd, that was
|
||||
/// passed in at the start of the run function.
|
||||
///
|
||||
/// @return COI_SUCCESS if the buffer ref count was successfully incremented.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the buffer pointer is NULL.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the buffer pointer is invalid.
|
||||
///
|
||||
COIRESULT
|
||||
COIBufferAddRef(
|
||||
void *in_pBuffer);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Removes a reference to the memory of a buffer. The memory of the buffer
|
||||
/// will be eligible for being freed on the device when the following
|
||||
/// conditions are met: the run function that delivered the buffer
|
||||
/// returns, and the number of calls to COIBufferReleaseRef() matches the
|
||||
/// number of calls to COIBufferAddRef().
|
||||
//
|
||||
/// Running this API in a thread spawned within the run function is not
|
||||
/// supported and will cause unpredictable results and may cause data corruption.
|
||||
///
|
||||
/// @warning When a buffer is AddRef'd it is assumed that it is in use and all
|
||||
/// other operations on that buffer waits for ReleaseRef() to happen.
|
||||
/// So you cannot pass the AddRef'd buffer's handle to RunFunction
|
||||
/// that calls ReleaseRef(). This is a circular dependency and will
|
||||
/// cause a deadlock. Buffer's pointer (buffer's sink side
|
||||
/// address/pointer which is different than source side BUFFER handle)
|
||||
/// needs to be stored somewhere to retrieve it later to use in
|
||||
/// ReleaseRef.
|
||||
///
|
||||
/// @param in_pBuffer
|
||||
/// [in] Pointer to the start of a buffer previously AddRef'd, that
|
||||
/// was passed in at the start of the run function.
|
||||
///
|
||||
/// @return COI_SUCCESS if the buffer refcount was successfully decremented.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the buffer pointer was invalid.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the buffer did not have COIBufferAddRef()
|
||||
/// previously called on it.
|
||||
///
|
||||
COIRESULT
|
||||
COIBufferReleaseRef(
|
||||
void *in_pBuffer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIBUFFER_SINK_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIPIPELINE_SINK_H
|
||||
#define _COIPIPELINE_SINK_H
|
||||
|
||||
/** @ingroup COIPipeline
|
||||
* @addtogroup COIPipelineSink
|
||||
@{
|
||||
* @file sink/COIPipeline_sink.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define COINATIVELIBEXPORT_VISIBILITY "extern"
|
||||
#else
|
||||
#define COINATIVELIBEXPORT_VISIBILITY "default"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define COINATIVELIBEXPORT \
|
||||
extern "C" __attribute__ ((visibility(COINATIVELIBEXPORT_VISIBILITY)))
|
||||
#else
|
||||
#define COINATIVELIBEXPORT \
|
||||
__attribute__ ((visibility(COINATIVELIBEXPORT_VISIBILITY)))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// This is the prototype that run functions should follow.
|
||||
///
|
||||
/// @param in_BufferCount
|
||||
/// The number of buffers passed to the run function.
|
||||
///
|
||||
/// @param in_ppBufferPointers
|
||||
/// An array that is in_BufferCount in length that contains the
|
||||
/// sink side virtual addresses for each buffer passed in to
|
||||
/// the run function.
|
||||
///
|
||||
/// @param in_pBufferLengths
|
||||
/// An array that is in_BufferCount in length of uint32_t integers
|
||||
/// describing the length of each passed in buffer in bytes.
|
||||
///
|
||||
/// @param in_pMiscData
|
||||
/// Pointer to the MiscData passed in when the run function
|
||||
/// was enqueued on the source.
|
||||
///
|
||||
/// @param in_MiscDataLen
|
||||
/// Length in bytes of the MiscData passed in when the run function
|
||||
/// was enqueued on the source.
|
||||
///
|
||||
/// @param in_pReturnValue
|
||||
/// Pointer to the location where the return value from this run
|
||||
/// function will be stored.
|
||||
///
|
||||
/// @param in_ReturnValueLength
|
||||
/// Length in bytes of the user-allocated ReturnValue pointer.
|
||||
///
|
||||
/// @return A uint64_t that can be retrieved in the out_UserData parameter
|
||||
/// from the COIPipelineWaitForEvent function.
|
||||
///
|
||||
typedef void
|
||||
(*RunFunctionPtr_t)(
|
||||
uint32_t in_BufferCount,
|
||||
void **in_ppBufferPointers,
|
||||
uint64_t *in_pBufferLengths,
|
||||
void *in_pMiscData,
|
||||
uint16_t in_MiscDataLength,
|
||||
void *in_pReturnValue,
|
||||
uint16_t in_ReturnValueLength);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Start processing pipelines on the Sink. This should be done after any
|
||||
/// required initialization in the Sink's application has finished. No
|
||||
/// run functions will actually be executed (although they may be queued)
|
||||
/// until this function is called.
|
||||
///
|
||||
///
|
||||
/// @return COI_SUCCESS if the pipelines were successfully started.
|
||||
///
|
||||
COIRESULT
|
||||
COIPipelineStartExecutingRunFunctions();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIPIPELINE_SINK_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIPROCESS_SINK_H
|
||||
#define _COIPROCESS_SINK_H
|
||||
|
||||
/** @ingroup COIProcess
|
||||
* @addtogroup COIProcessSink
|
||||
@{
|
||||
* @file sink/COIProcess_sink.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// This call will block while waiting for the source to send a process destroy
|
||||
/// message. This provides the sink side application with an event to keep the
|
||||
/// main() function from exiting until it is directed to by the source. When
|
||||
/// the shutdown message is received this function will stop any future run
|
||||
/// functions from executing but will wait for any current run functions to
|
||||
/// complete. All Intel® Coprocessor Offload Infrastructure (Intel® COI)
|
||||
/// resources will be cleaned up and no additional Intel® Coprocessor Offload
|
||||
/// Infrastructure (Intel® COI) APIs should be called after this function
|
||||
/// returns. This function does not invoke exit() so the application
|
||||
/// can perform any of its own cleanup once this call returns.
|
||||
///
|
||||
/// @return COI_SUCCESS once the process receives the shutdown message.
|
||||
///
|
||||
COIRESULT
|
||||
COIProcessWaitForShutdown();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// This call will block until all stdout and stderr output has been proxied
|
||||
/// to and written by the source. This call guarantees that any output in a
|
||||
/// run function is transmitted to the source before the run function signals
|
||||
/// its completion event back to the source.
|
||||
///
|
||||
/// Note that having an additional thread printing forever while another
|
||||
/// calls COIProxyFlush may lead to a hang because the process will be forced
|
||||
/// to wait until all that output can be flushed to the source before returning
|
||||
/// from this call.
|
||||
///
|
||||
/// @return COI_SUCCESS once the proxy output has been flushed to and written
|
||||
/// written by the host. Note that Intel® Coprocessor Offload
|
||||
/// Infrastructure (Intel® COI) on the source writes to stdout and
|
||||
/// stderr, but does not flush this output.
|
||||
/// @return COI_SUCCESS if the process was created without enabling
|
||||
/// proxy IO this function.
|
||||
///
|
||||
COIRESULT
|
||||
COIProcessProxyFlush();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Loads a shared library from host filesystem into the current sink
|
||||
/// process, akin to using dlopen() on a local process in Linux or
|
||||
/// LoadLibrary() in Windows.
|
||||
///
|
||||
/// @param in_pFileName
|
||||
/// [in] The name of the shared library file on the source's file
|
||||
/// system that is being loaded. If the file name is not an absolute
|
||||
/// path, the file is searched for in the same manner as dependencies.
|
||||
///
|
||||
/// @param in_pLibraryName
|
||||
/// [in] Name for the shared library. This optional parameter can
|
||||
/// be specified in case the dynamic library doesn't have an
|
||||
/// SO_NAME field. If specified, it will take precedence over
|
||||
/// the SO_NAME if it exists. If it is not specified then
|
||||
/// the library must have a valid SO_NAME field.
|
||||
///
|
||||
///@param in_LibrarySearchPath
|
||||
/// [in] a path to locate dynamic libraries dependencies for the
|
||||
/// library being loaded. If not NULL, this path will override the
|
||||
/// environment variable SINK_LD_LIBRARY_PATH. If NULL it will use
|
||||
/// SINK_LD_LIBRARY_PATH to locate dependencies.
|
||||
///
|
||||
/// @param in_Flags
|
||||
/// [in] Bitmask of the flags that will be passed in as the dlopen()
|
||||
/// "flag" parameter on the sink.
|
||||
///
|
||||
/// @param out_pLibrary
|
||||
/// [out] If COI_SUCCESS or COI_ALREADY_EXISTS is returned, the handle
|
||||
/// that uniquely identifies the loaded library.
|
||||
///
|
||||
/// @return COI_SUCCESS if the library was successfully loaded.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if in_pFileName is NULL.
|
||||
///
|
||||
/// @return COI_DOES_NOT_EXIST if in_pFileName cannot be found.
|
||||
///
|
||||
/// @return COI_INVALID_FILE if the file is not a valid shared library.
|
||||
///
|
||||
/// @return COI_MISSING_DEPENDENCY if a dependent library is missing from
|
||||
/// either SINK_LD_LIBRARY_PATH or the in_LibrarySearchPath parameter.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if the shared library is missing an SONAME
|
||||
/// and in_pLibraryName is NULL.
|
||||
///
|
||||
/// @return COI_UNDEFINED_SYMBOL if we are unable to load the library due to
|
||||
/// an undefined symbol.
|
||||
///
|
||||
/// @return COI_ALREADY_EXISTS if there is an existing COILIBRARY handle
|
||||
/// that identifies this library, and this COILIBRARY hasn't been
|
||||
/// unloaded yet.
|
||||
///
|
||||
/// @return COI_BINARY_AND_HARDWARE_MISMATCH if the target machine of the
|
||||
/// binary or any of its recursive dependencies does not match the
|
||||
/// engine associated with Process.
|
||||
///
|
||||
/// @return COI_NOT_INITIALIZED if setup of remote process on host is not
|
||||
/// completed yet.
|
||||
///
|
||||
COIRESULT
|
||||
COIProcessLoadSinkLibraryFromFile(
|
||||
const char *in_pFileName,
|
||||
const char *in_pLibraryName,
|
||||
const char *in_LibrarySearchPath,
|
||||
uint32_t in_Flags,
|
||||
COILIBRARY *out_pLibrary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIPROCESS_SINK_H */
|
||||
|
||||
/*! @} */
|
File diff suppressed because it is too large
Load diff
|
@ -1,273 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIENGINE_SOURCE_H
|
||||
#define _COIENGINE_SOURCE_H
|
||||
|
||||
/** @ingroup COIEngine
|
||||
* @addtogroup COIEngineSource
|
||||
@{
|
||||
|
||||
* @file source\COIEngine_source.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#include <wchar.h>
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
#include "../common/COIEngine_common.h"
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COI_MAX_DRIVER_VERSION_STR_LEN 255
|
||||
|
||||
#define COI_MAX_HW_THREADS 1024
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// This enum defines miscellaneous information returned from the
|
||||
/// COIGetEngineInfo() function.
|
||||
///
|
||||
typedef enum
|
||||
{
|
||||
COI_ENG_ECC_DISABLED = 0, //ECC is not enabled on this engine
|
||||
COI_ENG_ECC_ENABLED = 0x00000001, //ECC is enabled on this engine
|
||||
COI_ENG_ECC_UNKNOWN = 0x00000002 //ECC is mode is unknown
|
||||
} coi_eng_misc;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// This structure returns information about an Intel(R) Xeon Phi(TM)
|
||||
/// coprocessor.
|
||||
/// A pointer to this structure is passed into the COIGetEngineInfo() function,
|
||||
/// which fills in the data before returning to the caller.
|
||||
///
|
||||
typedef struct COI_ENGINE_INFO
|
||||
{
|
||||
/// The version string identifying the driver.
|
||||
coi_wchar_t DriverVersion[COI_MAX_DRIVER_VERSION_STR_LEN];
|
||||
|
||||
/// The DeviceType supported by the engine.
|
||||
COI_DEVICE_TYPE ISA;
|
||||
|
||||
/// The number of cores on the engine.
|
||||
uint32_t NumCores;
|
||||
|
||||
/// Miscellaneous fields
|
||||
coi_eng_misc MiscFlags;
|
||||
|
||||
/// The number of hardware threads on the engine.
|
||||
uint32_t NumThreads;
|
||||
|
||||
/// The maximum frequency (in MHz) of the cores on the engine.
|
||||
uint32_t CoreMaxFrequency;
|
||||
|
||||
/// The load percentage for each of the hardware threads on the engine.
|
||||
/// Currently this is limited to reporting out a maximum of 1024 HW threads
|
||||
uint32_t Load[COI_MAX_HW_THREADS];
|
||||
|
||||
/// The amount of physical memory managed by the OS.
|
||||
uint64_t PhysicalMemory;
|
||||
|
||||
/// The amount of free physical memory in the OS.
|
||||
uint64_t PhysicalMemoryFree;
|
||||
|
||||
/// The amount of swap memory managed by the OS.
|
||||
uint64_t SwapMemory;
|
||||
|
||||
/// The amount of free swap memory in the OS.
|
||||
uint64_t SwapMemoryFree;
|
||||
|
||||
/// The pci config vendor id
|
||||
uint16_t VendorId;
|
||||
|
||||
/// The pci config device id
|
||||
uint16_t DeviceId;
|
||||
|
||||
/// The pci config subsystem id
|
||||
uint16_t SubSystemId;
|
||||
|
||||
/// The stepping of the board, A0, A1, C0, D0 etc.
|
||||
uint16_t BoardStepping;
|
||||
|
||||
/// The SKU of the stepping, EB, ED, etc.
|
||||
uint16_t BoardSKU;
|
||||
} COI_ENGINE_INFO;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns information related to a specified engine. Note that if the runtime
|
||||
/// is unable to query a value it will be returned as zero but the call will
|
||||
/// still succeed.
|
||||
///
|
||||
///
|
||||
/// @param in_EngineHandle
|
||||
/// [in] The COIENGINE structure as provided from COIEngineGetHandle()
|
||||
/// which to query for device level information.
|
||||
///
|
||||
/// @param in_EngineInfoSize
|
||||
/// [in] The size of the structure that out_pEngineInfo points to.
|
||||
/// Used for version safety of the function call.
|
||||
///
|
||||
/// @param out_pEngineInfo
|
||||
/// [out] The address of a user allocated COI_ENGINE_INFO structure.
|
||||
/// Upon success, the contents of the structure will be updated
|
||||
/// to contain information related to the specified engine.
|
||||
///
|
||||
///
|
||||
/// @return COI_SUCCESS if the function completed without error.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the in_EngineHandle handle is not valid.
|
||||
///
|
||||
/// @return COI_SIZE_MISMATCH if in_EngineInfoSize does not match any current
|
||||
/// or previous COI_ENGINE_INFO structure sizes.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_pEngineInfo pointer is NULL.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEngineGetInfo(
|
||||
COIENGINE in_EngineHandle,
|
||||
uint32_t in_EngineInfoSize,
|
||||
COI_ENGINE_INFO *out_pEngineInfo);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns the number of engines in the system that match the provided device type.
|
||||
///
|
||||
/// The number of available coprocessor devices (i.e. cards connected via PCIe)
|
||||
/// is detected by the COI runtime.
|
||||
///
|
||||
/// @param in_DeviceType
|
||||
/// [in] Specifies the ISA type of the engine requested.
|
||||
///
|
||||
/// @param out_pNumEngines
|
||||
/// [out] The number of engines available. This can be used to index
|
||||
/// into the engines using COIEngineGetHandle().
|
||||
///
|
||||
/// @return COI_SUCCESS if the function completed without error.
|
||||
///
|
||||
/// @return COI_DOES_NOT_EXIST if the in_DeviceType parameter is not valid.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_pNumEngines parameter is NULL.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if number of selected devices is greater than 8.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEngineGetCount(
|
||||
COI_DEVICE_TYPE in_DeviceType,
|
||||
uint32_t *out_pNumEngines);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns the handle of a user specified engine.
|
||||
///
|
||||
/// @param in_DeviceType
|
||||
/// [in] Specifies the ISA type of the engine requested.
|
||||
///
|
||||
/// @param in_EngineIndex
|
||||
/// [in] A unsigned integer which specifies the zero-based position of
|
||||
/// the engine in a collection of engines. The makeup of this
|
||||
/// collection is defined by the in_DeviceType parameter.
|
||||
///
|
||||
/// @param out_pEngineHandle
|
||||
/// [out] The address of a COIENGINE handle.
|
||||
///
|
||||
/// @return COI_SUCCESS if the function completed without error.
|
||||
///
|
||||
/// @return COI_DOES_NOT_EXIST if the in_DeviceType parameter is not valid.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if in_EngineIndex is greater than or equal to
|
||||
/// the number of engines that match the in_DeviceType parameter.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_pEngineHandle parameter is NULL.
|
||||
///
|
||||
/// @return COI_VERSION_MISMATCH if the version of Intel(R) Coprocessor Offload
|
||||
/// Infrastructure (Intel(R) COI) on the host is not
|
||||
/// compatible with the version on the device.
|
||||
///
|
||||
/// @return COI_NOT_INITIALIZED if the engine requested exists but is offline.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEngineGetHandle(
|
||||
COI_DEVICE_TYPE in_DeviceType,
|
||||
uint32_t in_EngineIndex,
|
||||
COIENGINE *out_pEngineHandle);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Returns the hostname for a specified COIEngine.
|
||||
///
|
||||
/// @param in_EngineHandle
|
||||
/// [in] The connected COI Engine Handle passed in by the user that is
|
||||
/// used to request the hostname of the device connected by this COIEngine.
|
||||
///
|
||||
/// @param out_Hostname
|
||||
/// [out] The hostname of the device connected by this COIEngine.
|
||||
/// COI will write at most 4096 bytes and the user must make sure that the size
|
||||
/// of the memory pointed by this argument is large enough.
|
||||
///
|
||||
/// @return COI_SUCCESS if the hostname was retrieved without error.
|
||||
///
|
||||
/// @return COI_ERROR if the function was unable to retrieve the hostname and/or
|
||||
/// the retrieved out_Hostname is NULL.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the in_EngineHandle is invalid.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_Hostname is NULL.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEngineGetHostname(
|
||||
COIENGINE in_EngineHandle,
|
||||
char *out_Hostname);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIENGINE_SOURCE_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIEVENT_SOURCE_H
|
||||
#define _COIEVENT_SOURCE_H
|
||||
|
||||
/** @ingroup COIEvent
|
||||
* @addtogroup COIEventSource
|
||||
@{
|
||||
* @file source/COIEvent_source.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Special case event values which can be passed in to APIs to specify
|
||||
/// how the API should behave. In COIBuffer APIs passing in NULL for the
|
||||
/// completion event is the equivalent of passing COI_EVENT_SYNC.
|
||||
/// Note that passing COI_EVENT_ASYNC can be used when the caller wishes the
|
||||
/// operation to be performed asynchronously but does not care when the
|
||||
/// operation completes. This can be useful for operations that by definition
|
||||
/// must complete in order (DMAs, run functions on a single pipeline). If
|
||||
/// the caller does care when the operation completes then they should pass
|
||||
/// in a valid completion event which they can later wait on.
|
||||
///
|
||||
#define COI_EVENT_ASYNC ((COIEVENT*)1)
|
||||
#define COI_EVENT_SYNC ((COIEVENT*)2)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// This can be used to initialize a COIEVENT to a known invalid state.
|
||||
/// This is not required to use, but can be useful in some cases
|
||||
/// if a program is unsure if the event will be initialized by the runtime.
|
||||
/// Simply set the event to this value: COIEVENT event = COI_EVENT_INITIALIZER;
|
||||
///
|
||||
#define COI_EVENT_INITIALIZER { { 0, -1 } }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Wait for an arbitrary number of COIEVENTs to be signaled as completed,
|
||||
/// eg when the run function or asynchronous map call associated with an event
|
||||
/// has finished execution.
|
||||
/// If the user sets in_WaitForAll = True and not all of the events are
|
||||
/// signaled when the timeout period is reached then COI_TIME_OUT_REACHED will
|
||||
/// be returned.
|
||||
/// If the user sets in_WaitForAll = False then if at least one event is
|
||||
/// signaled when the timeout is reached then COI_SUCCESS is returned.
|
||||
///
|
||||
/// @param in_NumEvents
|
||||
/// [in] The number of events to wait for.
|
||||
///
|
||||
/// @param in_pEvents
|
||||
/// [in] The array of COIEVENT handles to wait for.
|
||||
///
|
||||
/// @param in_Timeout
|
||||
/// [in] The time in milliseconds to wait for the event. 0 polls
|
||||
/// and returns immediately, -1 blocks indefinitely.
|
||||
///
|
||||
/// @param in_WaitForAll
|
||||
/// [in] Boolean value specifying behavior. If true, wait for all
|
||||
/// events to be signaled, or for timeout, whichever happens first.
|
||||
/// If false, return when any event is signaled, or at timeout.
|
||||
///
|
||||
/// @param out_pNumSignaled
|
||||
/// [out] The number of events that were signaled. If in_NumEvents
|
||||
/// is 1 or in_WaitForAll = True, this parameter is optional.
|
||||
///
|
||||
/// @param out_pSignaledIndices
|
||||
/// [out] Pointer to an array of indices into the original event
|
||||
/// array. Those denoted have been signaled. The user must provide an
|
||||
/// array that is no smaller than the in_Events array. If in_NumEvents
|
||||
/// is 1 or in_WaitForAll = True, this parameter is optional.
|
||||
///
|
||||
/// @return COI_SUCCESS once an event has been signaled completed.
|
||||
///
|
||||
/// @return COI_TIME_OUT_REACHED if the events are still in use when the
|
||||
/// timeout is reached or timeout is zero (a poll).
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if a negative value other than -1 is passed in to
|
||||
/// the in_Timeout parameter.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if in_NumEvents is 0.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if in_pEvents is NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_NumEvents > 1 and if in_WaitForAll
|
||||
/// is not true and out_pSignaled or out_pSignaledIndicies are NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if out_pNumSignaled is not NULL
|
||||
/// and out_pSignaledIndices is NULL (or vice versa).
|
||||
///
|
||||
/// @return COI_EVENT_CANCELED if while waiting on a user event, it gets
|
||||
/// unregistered this returns COI_EVENT_CANCELED
|
||||
///
|
||||
/// @return COI_PROCESS_DIED if the remote process died. See COIProcessDestroy
|
||||
/// for more details.
|
||||
///
|
||||
/// @return COI_<REAL ERROR> if only a single event is passed in, and that event
|
||||
/// failed, COI will attempt to return the real error code that caused
|
||||
/// the original operation to fail, otherwise COI_PROCESS_DIED is reported.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEventWait(
|
||||
uint16_t in_NumEvents,
|
||||
const COIEVENT *in_pEvents,
|
||||
int32_t in_TimeoutMilliseconds,
|
||||
uint8_t in_WaitForAll,
|
||||
uint32_t *out_pNumSignaled,
|
||||
uint32_t *out_pSignaledIndices);
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Register a User COIEVENT so that it can be fired. Registered event is
|
||||
/// a one shot User event; in other words once signaled it cannot be used
|
||||
/// again for signaling. You have to unregister and register again to enable
|
||||
/// signaling. An event will be reset if it is re-registered without
|
||||
/// unregistering, resulting in loss of all outstanding signals.
|
||||
///
|
||||
/// @param out_pEvent
|
||||
/// [out] Pointer to COIEVENT handle being Registered
|
||||
///
|
||||
/// @return COI_SUCCESS an event is successfully registered
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if out_pEvent is NULL
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEventRegisterUserEvent(
|
||||
COIEVENT *out_pEvent);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Unregister a User COIEVENT. Unregistering a unsignaled event is similar
|
||||
/// to firing an event. Except Calling COIEventWait on an event that is
|
||||
/// being unregistered returns COI_EVENT_CANCELED
|
||||
///
|
||||
/// @param in_Event
|
||||
/// [in] Event Handle to be unregistered.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if in_Event is not a UserEvent
|
||||
///
|
||||
/// @return COI_SUCCESS if an event is successfully unregistered
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEventUnregisterUserEvent(
|
||||
COIEVENT in_Event);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// A callback that will be invoked to notify the user of an internal
|
||||
/// runtime event completion.
|
||||
///
|
||||
/// As with any callback mechanism it is up to the user to make sure that
|
||||
/// there are no possible deadlocks due to reentrancy (ie the callback being
|
||||
/// invoked in the same context that triggered the notification) and also
|
||||
/// that the callback does not slow down overall processing. If the user
|
||||
/// performs too much work within the callback it could delay further
|
||||
/// processing. The callback will be invoked prior to the signaling of
|
||||
/// the corresponding COIEvent. For example, if a user is waiting
|
||||
/// for a COIEvent associated with a run function completing they will
|
||||
/// receive the callback before the COIEvent is marked as signaled.
|
||||
///
|
||||
/// @param in_Event
|
||||
/// [in] The completion event that is associated with the
|
||||
/// operation that is being notified.
|
||||
///
|
||||
/// @param in_Result
|
||||
/// [in] The COIRESULT of the operation.
|
||||
///
|
||||
/// @param in_UserData
|
||||
/// [in] Opaque data that was provided when the callback was
|
||||
/// registered. Intel(R) Coprocessor Offload Infrastructure
|
||||
/// (Intel(R) COI) simply passes this back to the user so that
|
||||
/// they can interpret it as they choose.
|
||||
///
|
||||
typedef void (*COI_EVENT_CALLBACK)(
|
||||
COIEVENT in_Event,
|
||||
const COIRESULT in_Result,
|
||||
const void *in_UserData);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Registers any COIEVENT to receive a one time callback, when the event
|
||||
/// is marked complete in the offload runtime. If the event has completed
|
||||
/// before the COIEventRegisterCallback() is called then the callback will
|
||||
/// immediately be invoked by the calling thread. When the event is
|
||||
/// registered before the event completes, the runtime gaurantees that
|
||||
/// the callback will be invoked before COIEventWait() is notified of
|
||||
/// the same event completing. In well written user code, this may provide
|
||||
/// a slight performance advantage.
|
||||
///
|
||||
/// Users should treat the callback much like an interrupt routine, in regards
|
||||
/// of performance. Specifically designing the callback to be as short and
|
||||
/// non blocking as possible. Since the thread that runs the callback is
|
||||
/// non deterministic blocking or stalling of the callback, may have severe
|
||||
/// performance impacts on the offload runtime. Thus, it is important to not
|
||||
/// create deadlocks between the callback and other signaling/waiting
|
||||
/// mechanisms. It is recommended to never invoke COIEventWait() inside
|
||||
/// a callback function, as this could lead to immediate deadlocks.
|
||||
///
|
||||
/// It is important to note that the runtime cannot distinguish between
|
||||
/// already triggered events and invalid events. Thus the user needs to pass
|
||||
/// in a valid event, or the callback will be invoked immediately.
|
||||
/// Failed events will still receive a callback and the user can query
|
||||
/// COIEventWait() after the callback for the failed return code.
|
||||
///
|
||||
/// If more than one callback is registered for the same event, only the
|
||||
/// single most current callback will be used, i.e. the older one will
|
||||
/// be replaced.
|
||||
///
|
||||
/// @param in_Event
|
||||
/// [in] A valid single event handle to be registered to receive a callback.
|
||||
///
|
||||
/// @param in_Callback
|
||||
/// [in] Pointer to a user function used to signal an
|
||||
/// event completion.
|
||||
///
|
||||
/// @param in_UserData
|
||||
/// [in] Opaque data to pass to the callback when it is invoked.
|
||||
///
|
||||
/// @param in_Flags
|
||||
/// [in] Reserved parameter for future expansion, required to be zero for now.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if in_Event is not a valid COIEVENT
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if in_Callback is not a valid pointer.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if the in_Flags is not zero.
|
||||
///
|
||||
/// @return COI_SUCCESS an event is successfully registered
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIEventRegisterCallback(
|
||||
const COIEVENT in_Event,
|
||||
COI_EVENT_CALLBACK in_Callback,
|
||||
const void *in_UserData,
|
||||
const uint64_t in_Flags);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIEVENT_SOURCE_H */
|
||||
|
||||
/*! @} */
|
|
@ -1,437 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
#ifndef _COIPIPELINE_SOURCE_H
|
||||
#define _COIPIPELINE_SOURCE_H
|
||||
|
||||
/** @ingroup COIPipeline
|
||||
* @addtogroup COIPipelineSource
|
||||
@{
|
||||
* @file source/COIPipeline_source.h
|
||||
*/
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#include "../common/COITypes_common.h"
|
||||
#include "../common/COIResult_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// These flags specify how a buffer will be used within a run function. They
|
||||
/// allow the runtime to make optimizations in how it moves the data around.
|
||||
/// These flags can affect the correctness of an application, so they must be
|
||||
/// set properly. For example, if a buffer is used in a run function with the
|
||||
/// COI_SINK_READ flag and then mapped on the source, the runtime may use a
|
||||
/// previously cached version of the buffer instead of retrieving data from
|
||||
/// the sink.
|
||||
typedef enum COI_ACCESS_FLAGS
|
||||
{
|
||||
/// Specifies that the run function will only read the associated buffer.
|
||||
COI_SINK_READ = 1,
|
||||
|
||||
/// Specifies that the run function will write to the associated buffer.
|
||||
COI_SINK_WRITE,
|
||||
|
||||
/// Specifies that the run function will overwrite the entire associated
|
||||
/// buffer and therefore the buffer will not be synchronized with the
|
||||
/// source before execution.
|
||||
COI_SINK_WRITE_ENTIRE,
|
||||
|
||||
/// Specifies that the run function will only read the associated buffer
|
||||
/// and will maintain the reference count on the buffer after
|
||||
/// run function exit.
|
||||
COI_SINK_READ_ADDREF,
|
||||
|
||||
/// Specifies that the run function will write to the associated buffer
|
||||
/// and will maintain the reference count on the buffer after
|
||||
/// run function exit.
|
||||
COI_SINK_WRITE_ADDREF,
|
||||
|
||||
/// Specifies that the run function will overwrite the entire associated
|
||||
/// buffer and therefore the buffer will not be synchronized with the
|
||||
/// source before execution and will maintain the reference count on the
|
||||
/// buffer after run function exit.
|
||||
COI_SINK_WRITE_ENTIRE_ADDREF
|
||||
} COI_ACCESS_FLAGS;
|
||||
|
||||
#define COI_PIPELINE_MAX_PIPELINES 512
|
||||
#define COI_PIPELINE_MAX_IN_BUFFERS 16384
|
||||
#define COI_PIPELINE_MAX_IN_MISC_DATA_LEN 32768
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Create a pipeline associated with a remote process. This pipeline can
|
||||
/// then be used to execute remote functions and to share data using
|
||||
/// COIBuffers.
|
||||
///
|
||||
/// @param in_Process
|
||||
/// [in] A handle to an already existing process that the pipeline
|
||||
/// will be associated with.
|
||||
///
|
||||
/// @param in_Mask
|
||||
/// [in] An optional mask of the set of hardware threads on which the
|
||||
/// sink pipeline command processing thread could run.
|
||||
///
|
||||
/// @param in_StackSize
|
||||
/// [in] An optional value that will be used when the pipeline
|
||||
/// processing thread is created on the sink. If the user passes in
|
||||
/// 0 the OS default stack size will be used. Otherwise the value
|
||||
/// must be PTHREAD_STACK_MIN (16384) bytes or larger and must be
|
||||
/// a multiple of a page (4096 bytes).
|
||||
///
|
||||
/// @param out_pPipeline
|
||||
/// [out] Handle returned to uniquely identify the pipeline that was
|
||||
/// created for use in later API calls.
|
||||
///
|
||||
///
|
||||
/// @return COI_SUCCESS if the pipeline was successfully created.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the in_Process handle passed in was invalid.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_pPipeline pointer was NULL.
|
||||
///
|
||||
/// @return COI_RESOURCE_EXHAUSTED if no more COIPipelines can be created. The
|
||||
/// maximum number of pipelines allowed is COI_PIPELINE_MAX_PIPELINES.
|
||||
/// It is recommended in most cases to not exceed the number of CPU's
|
||||
/// that are reported on the offload device, performance will suffer.
|
||||
///
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if the in_StackSize > 0 &&
|
||||
/// in_StackSize < PTHREAD_STACK_MIN or if in_StackSize is not a
|
||||
/// multiple of a page (4096 bytes).
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if the in_Mask is set to all zeroes. If no mask
|
||||
/// is desired then the in_Mask should be passed as NULL, otherwise
|
||||
/// at least one thread must be set.
|
||||
///
|
||||
/// @return COI_TIME_OUT_REACHED if establishing the communication channel with
|
||||
/// the remote pipeline timed out.
|
||||
///
|
||||
/// @return COI_RETRY if the pipeline cannot be created due to the number of
|
||||
/// source-to-sink connections in use. A subsequent call to
|
||||
/// COIPipelineCreate may succeed if resources are freed up.
|
||||
///
|
||||
/// @return COI_PROCESS_DIED if in_Process died.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineCreate(
|
||||
COIPROCESS in_Process,
|
||||
COI_CPU_MASK in_Mask,
|
||||
uint32_t in_StackSize,
|
||||
COIPIPELINE *out_pPipeline);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Destroys the indicated pipeline, releasing its resources.
|
||||
///
|
||||
/// @param in_Pipeline
|
||||
/// [in] Pipeline to destroy.
|
||||
///
|
||||
///
|
||||
/// @return COI_SUCCESS if the pipeline was destroyed
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineDestroy(
|
||||
COIPIPELINE in_Pipeline);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Enqueues a function in the remote process binary to be executed. The
|
||||
/// function execution is asynchronous in regards to the Source and all
|
||||
/// run functions enqueued on a pipeline are executed in-order. The run
|
||||
/// function will only execute when all of the required buffers are present
|
||||
/// in the Sink's memory.
|
||||
///
|
||||
/// Potential Hazards while using Runfunctions:
|
||||
///
|
||||
/// 1. Proper care has to be taken while setting the input dependencies for
|
||||
/// RunFunctions. Setting it incorrectly can lead to cyclic dependencies
|
||||
/// and can cause the respective pipeline to stall.
|
||||
/// 2. RunFunctions can also segfault if enough memory space is not available
|
||||
/// on the sink for the buffers passed in. Buffers that are AddRef'd
|
||||
/// need to be accounted for available memory space. In other
|
||||
/// words, this memory is not available for use until it is freed up.
|
||||
/// 3. Unexpected segmentation faults or erroneous behavior can occur if
|
||||
/// handles or data passed in to Runfunction gets destroyed before the
|
||||
/// RunFunction finishes.
|
||||
/// For example, if a variable passed in as Misc data or the buffer gets
|
||||
/// destroyed before the runtime receives the completion notification
|
||||
/// of the Runfunction, it can cause unexpected behavior. So it is always
|
||||
/// recommended to wait for RunFunction completion event before any related
|
||||
/// destroy event occurs.
|
||||
///
|
||||
/// The runtime expects users to handle such scenarios. COIPipelineRunFunction
|
||||
/// returns COI_SUCCESS for above cases because it was queued up successfully.
|
||||
/// Also if you try to destroy a pipeline with a stalled function then the
|
||||
/// destroy call will hang. COIPipelineDestroy waits until all the functions
|
||||
/// enqueued are finished executing.
|
||||
///
|
||||
/// @param in_Pipeline
|
||||
/// [in] Handle to a previously created pipeline that this run
|
||||
/// function should be enqueued to.
|
||||
///
|
||||
/// @param in_Function
|
||||
/// [in] Previously returned handle from a call to
|
||||
/// COIPipelineGetFunctionHandle() that represents a function in the
|
||||
/// application running on the Sink process.
|
||||
///
|
||||
/// @param in_NumBuffers
|
||||
/// [in] The number of buffers that are being passed to the run
|
||||
/// function. This number must match the number of buffers in the
|
||||
/// in_pBuffers and in_pBufferAccessFlags arrays. Must be less than
|
||||
/// COI_PIPELINE_MAX_IN_BUFFERS.
|
||||
///
|
||||
/// @param in_pBuffers
|
||||
/// [in] An array of COIBUFFER handles that the function is expected
|
||||
/// to use during its execution. Each buffer when it arrives at the
|
||||
/// Sink process will be at least 4k page aligned, thus, using a very
|
||||
/// large number of small buffers is memory inefficient and should be
|
||||
/// avoided.
|
||||
///
|
||||
/// @param in_pBufferAccessFlags
|
||||
/// [in] An array of flag values which correspond to the buffers
|
||||
/// passed in the in_pBuffers parameter. These flags are used to
|
||||
/// track dependencies between different run functions being
|
||||
/// executed from different pipelines.
|
||||
///
|
||||
/// @param in_NumDependencies
|
||||
/// [in] The number of dependencies specified in the in_pDependencies
|
||||
/// array. This may be 0 if the caller does not want the run function
|
||||
/// to wait for any dependencies.
|
||||
///
|
||||
/// @param in_pDependencies
|
||||
/// [in] An optional array of COIEVENT objects that this run
|
||||
/// function will wait for before executing. This allows the user to
|
||||
/// create dependencies between run functions in different pipelines.
|
||||
/// The user may pass in NULL if they do not wish to wait for any
|
||||
/// dependencies to complete.
|
||||
///
|
||||
/// @param in_pMiscData
|
||||
/// [in] Pointer to user defined data, typically used to pass
|
||||
/// parameters to Sink side functions. Should only be used for small
|
||||
/// amounts data since the data will be placed directly in the
|
||||
/// Driver's command buffer. COIBuffers should be used to pass large
|
||||
/// amounts of data.
|
||||
///
|
||||
/// @param in_MiscDataLen
|
||||
/// [in] Size of the in_pMiscData in bytes. Must be less than
|
||||
/// COI_PIPELINE_MAX_IN_MISC_DATA_LEN, and should usually be much
|
||||
/// smaller, see documentation for the parameter in_pMiscData.
|
||||
///
|
||||
/// @param out_pAsyncReturnValue
|
||||
/// [out] Pointer to user-allocated memory where the return value from
|
||||
/// the run function will be placed. This memory should not be read
|
||||
/// until out_pCompletion has been signaled.
|
||||
///
|
||||
/// @param in_AsyncReturnValueLen
|
||||
/// [in] Size of the out_pAsyncReturnValue in bytes.
|
||||
///
|
||||
/// @param out_pCompletion
|
||||
/// [out] An optional pointer to a COIEVENT object
|
||||
/// that will be signaled when this run function has completed
|
||||
/// execution. The user may pass in NULL if they wish for this function
|
||||
/// to be synchronous, otherwise if a COIEVENT object is passed in the
|
||||
/// function is then asynchronous and closes after enqueuing the
|
||||
/// RunFunction and passes back the COIEVENT that will be signaled
|
||||
/// once the RunFunction has completed.
|
||||
///
|
||||
/// @return COI_SUCCESS if the function was successfully placed in a
|
||||
/// pipeline for future execution. Note that the actual
|
||||
/// execution of the function will occur in the future.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if in_NumBuffers is greater than
|
||||
/// COI_PIPELINE_MAX_IN_BUFFERS or if in_MiscDataLen is greater than
|
||||
/// COI_PIPELINE_MAX_IN_MISC_DATA_LEN.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the pipeline handle passed in was invalid.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the function handle passed in was invalid.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if any of the buffers passed in are invalid.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_NumDependencies is non-zero while
|
||||
/// in_pDependencies was passed in as NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_pDependencies is non-NULL but
|
||||
/// in_NumDependencies is zero.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_MiscDataLen is non-zero while
|
||||
/// in_pMiscData was passed in as NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_pMiscData is non-NULL but
|
||||
/// in_MiscDataLen is zero.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_NumBuffers is non-zero and in_pBuffers
|
||||
/// or in_pBufferAccessFlags are NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_pBuffers is non-NULL but
|
||||
/// in_NumBuffers is zero.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_pBufferAccessFlags is non-NULL but
|
||||
/// in_NumBuffers is zero.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_ReturnValueLen is non-zero while
|
||||
/// in_pReturnValue was passed in as NULL.
|
||||
///
|
||||
/// @return COI_ARGUMENT_MISMATCH if in_pReturnValue is non-NULL but
|
||||
/// in_ReturnValueLen is zero.
|
||||
///
|
||||
/// @return COI_RETRY if any input buffers are still mapped when
|
||||
/// passed to the run function.
|
||||
///
|
||||
/// @return COI_MISSING_DEPENDENCY if buffer was not created on the process
|
||||
/// associated with the pipeline that was passed in.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if any of the access flags in
|
||||
/// in_pBufferAccessFlags is not a valid COI_ACCESS_FLAGS.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineRunFunction(
|
||||
COIPIPELINE in_Pipeline,
|
||||
COIFUNCTION in_Function,
|
||||
uint32_t in_NumBuffers,
|
||||
const COIBUFFER *in_pBuffers,
|
||||
const COI_ACCESS_FLAGS *in_pBufferAccessFlags,
|
||||
uint32_t in_NumDependencies,
|
||||
const COIEVENT *in_pDependencies,
|
||||
const void *in_pMiscData,
|
||||
uint16_t in_MiscDataLen,
|
||||
void *out_pAsyncReturnValue,
|
||||
uint16_t in_AsyncReturnValueLen,
|
||||
COIEVENT *out_pCompletion);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Retrieve the engine that the pipeline is associated with.
|
||||
///
|
||||
/// @param in_Pipeline
|
||||
/// [in] Pipeline to query.
|
||||
///
|
||||
/// @param out_pEngine
|
||||
/// [out] The handle of the Engine.
|
||||
///
|
||||
/// @return COI_SUCCESS if the engine was retrieved.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if the pipeline handle passed in was invalid.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if the out_pEngine parameter is NULL.
|
||||
///
|
||||
/// @return COI_PROCESS_DIED if the process associated with this engine died.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineGetEngine(
|
||||
COIPIPELINE in_Pipeline,
|
||||
COIENGINE *out_pEngine);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Add a particular core:thread pair to a COI_CPU_MASK.
|
||||
///
|
||||
/// @param in_Process
|
||||
/// [in] A handle to an already existing process that the pipeline
|
||||
/// will be associated with.
|
||||
///
|
||||
/// @param in_CoreID
|
||||
/// [in] Core to affinitize to; must be less than the number of cores
|
||||
/// on the device.
|
||||
///
|
||||
/// @param in_ThreadID
|
||||
/// [in] Thread on the core to affinitize to (0 - 3).
|
||||
///
|
||||
/// @param out_pMask
|
||||
/// [out] Pointer to the mask to set.
|
||||
///
|
||||
/// @warning Unless it is explicitly done, the contents of the mask may not
|
||||
/// be zero when creating or declaring a COI_CPU_MASK variable.
|
||||
///
|
||||
/// @return COI_SUCCESS if the mask was set.
|
||||
///
|
||||
/// @return COI_OUT_OF_RANGE if the in_CoreID or in_ThreadID is out of range.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if out_pMask is invalid.
|
||||
///
|
||||
/// @return COI_INVALID_HANDLE if in_Process is invalid.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineSetCPUMask(
|
||||
COIPROCESS in_Process,
|
||||
uint32_t in_CoreID,
|
||||
uint8_t in_ThreadID,
|
||||
COI_CPU_MASK *out_pMask);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Clears a given mask. Note that the memory contents of COI_CPU_MASK are not
|
||||
/// guaranteed to be zero when declaring a COI_CPU_MASK variable. Thus, prior
|
||||
/// to setting a specific affinity to in_Mask it is important to call this
|
||||
/// function first.
|
||||
///
|
||||
/// @param in_Mask
|
||||
/// [in] Pointer to the mask to clear.
|
||||
///
|
||||
/// @return COI_SUCCESS if the mask was cleared.
|
||||
///
|
||||
/// @return COI_INVALID_POINTER if in_Mask is invalid.
|
||||
///
|
||||
COIACCESSAPI
|
||||
COIRESULT
|
||||
COIPipelineClearCPUMask(
|
||||
COI_CPU_MASK *in_Mask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _COIPIPELINE_SOURCE_H */
|
||||
|
||||
/*! @} */
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +0,0 @@
|
|||
# This spec file is read by gcc when linking. It is used to specify the
|
||||
# standard libraries we need in order to link with liboffloadmic_host.
|
||||
*link_offloadmic_host: @link_offloadmic_host@
|
|
@ -1,3 +0,0 @@
|
|||
# This spec file is read by gcc when linking. It is used to specify the
|
||||
# standard libraries we need in order to link with liboffloadmic_target.
|
||||
*link_offloadmic_target: @link_offloadmic_target@
|
|
@ -1,125 +0,0 @@
|
|||
# Plugin for offload execution on Intel MIC devices.
|
||||
#
|
||||
# Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
#
|
||||
# Contributed by Ilya Verbin <ilya.verbin@intel.com> and
|
||||
# Andrey Turetskiy <andrey.turetskiy@intel.com>.
|
||||
#
|
||||
# This file is part of the GNU Offloading and Multi Processing Library
|
||||
# (libgomp).
|
||||
#
|
||||
# Libgomp is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the GCC Runtime Library Exception, version
|
||||
# 3.1, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License and
|
||||
# a copy of the GCC Runtime Library Exception along with this program;
|
||||
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I ../.. -I ../../config
|
||||
|
||||
# Directories
|
||||
build_dir = $(top_builddir)
|
||||
source_dir = $(top_srcdir)
|
||||
coi_inc_dir = $(top_srcdir)/../include/coi
|
||||
include_src_dir = $(top_srcdir)/../../include
|
||||
libgomp_src_dir = $(top_srcdir)/../../libgomp
|
||||
libgomp_dir = $(build_dir)/../../libgomp
|
||||
liboffload_src_dir = $(top_srcdir)/../runtime
|
||||
liboffload_dir = $(top_builddir)/..
|
||||
|
||||
# May be used by toolexeclibdir.
|
||||
gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../../gcc/BASE-VER)
|
||||
libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/include
|
||||
# Search for main_target_image.h in these directories
|
||||
target_prefix_dir = $(libdir)/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
|
||||
target_build_dir = $(accel_search_dir)/$(accel_target)$(MULTISUBDIR)/liboffloadmic/plugin
|
||||
target_install_dir = $(accel_search_dir)/lib/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
|
||||
|
||||
if PLUGIN_HOST
|
||||
toolexeclib_LTLIBRARIES = libgomp-plugin-intelmic.la
|
||||
libgomp_plugin_intelmic_la_SOURCES = libgomp-plugin-intelmic.cpp
|
||||
libgomp_plugin_intelmic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=1 -I$(coi_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_src_dir) -I$(libgomp_dir) -I$(include_src_dir) -I$(target_prefix_dir)/include -I$(target_build_dir) -I$(target_install_dir)/include
|
||||
libgomp_plugin_intelmic_la_LDFLAGS = -L$(liboffload_dir)/.libs -loffloadmic_host -version-info 1:0:0
|
||||
else # PLUGIN_TARGET
|
||||
plugin_includedir = $(libsubincludedir)
|
||||
plugin_include_HEADERS = main_target_image.h
|
||||
AM_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=0 -I$(coi_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_dir)
|
||||
AM_CXXFLAGS = $(CXXFLAGS)
|
||||
AM_LDFLAGS = -L$(liboffload_dir)/.libs -L$(libgomp_dir)/.libs -loffloadmic_target -lcoi_device -lgomp -rdynamic
|
||||
endif
|
||||
|
||||
main_target_image.h: offload_target_main
|
||||
@echo -n "const int image_size = " > $@
|
||||
@stat -c '%s' $< >> $@
|
||||
@echo ";" >> $@
|
||||
@echo "struct MainTargetImage {" >> $@
|
||||
@echo " int64_t size;" >> $@
|
||||
@echo " char name[sizeof \"offload_target_main\"];" >> $@
|
||||
@echo " uint8_t data[image_size];" >> $@
|
||||
@echo "};" >> $@
|
||||
@echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
|
||||
@echo " image_size, \"offload_target_main\"," >> $@
|
||||
@cat $< | xxd -include >> $@
|
||||
@echo "};" >> $@
|
||||
|
||||
offload_target_main: $(liboffload_dir)/ofldbegin.o offload_target_main.o $(liboffload_dir)/ofldend.o
|
||||
$(CXX) $(AM_LDFLAGS) $^ -o $@
|
||||
|
||||
offload_target_main.o: offload_target_main.cpp
|
||||
$(CXX) $(AM_CXXFLAGS) $(AM_CPPFLAGS) -c $< -o $@
|
||||
|
||||
# Work around what appears to be a GNU make bug handling MAKEFLAGS
|
||||
# values defined in terms of make variables, as is the case for CC and
|
||||
# friends when we are called from the top level Makefile.
|
||||
AM_MAKEFLAGS = \
|
||||
"AR_FLAGS=$(AR_FLAGS)" \
|
||||
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
|
||||
"CFLAGS=$(CFLAGS)" \
|
||||
"CXXFLAGS=$(CXXFLAGS)" \
|
||||
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
|
||||
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
|
||||
"INSTALL=$(INSTALL)" \
|
||||
"INSTALL_DATA=$(INSTALL_DATA)" \
|
||||
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
|
||||
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
|
||||
"JC1FLAGS=$(JC1FLAGS)" \
|
||||
"LDFLAGS=$(LDFLAGS)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
|
||||
"MAKE=$(MAKE)" \
|
||||
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
|
||||
"SHELL=$(SHELL)" \
|
||||
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
|
||||
"exec_prefix=$(exec_prefix)" \
|
||||
"infodir=$(infodir)" \
|
||||
"libdir=$(libdir)" \
|
||||
"prefix=$(prefix)" \
|
||||
"includedir=$(includedir)" \
|
||||
"AR=$(AR)" \
|
||||
"AS=$(AS)" \
|
||||
"LD=$(LD)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"NM=$(NM)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"DESTDIR=$(DESTDIR)"
|
||||
|
||||
MAKEOVERRIDES =
|
||||
|
||||
include $(top_srcdir)/../../multilib.am
|
|
@ -1,840 +0,0 @@
|
|||
# Makefile.in generated by automake 1.15.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
# Plugin for offload execution on Intel MIC devices.
|
||||
#
|
||||
# Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
#
|
||||
# Contributed by Ilya Verbin <ilya.verbin@intel.com> and
|
||||
# Andrey Turetskiy <andrey.turetskiy@intel.com>.
|
||||
#
|
||||
# This file is part of the GNU Offloading and Multi Processing Library
|
||||
# (libgomp).
|
||||
#
|
||||
# Libgomp is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the GCC Runtime Library Exception, version
|
||||
# 3.1, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License and
|
||||
# a copy of the GCC Runtime Library Exception along with this program;
|
||||
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../config/acx.m4 \
|
||||
$(top_srcdir)/../../config/depstand.m4 \
|
||||
$(top_srcdir)/../../config/toolexeclibdir.m4 \
|
||||
$(top_srcdir)/../../config/lead-dot.m4 \
|
||||
$(top_srcdir)/../../config/multi.m4 \
|
||||
$(top_srcdir)/../../config/override.m4 \
|
||||
$(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/../../ltoptions.m4 \
|
||||
$(top_srcdir)/../../ltsugar.m4 \
|
||||
$(top_srcdir)/../../ltversion.m4 \
|
||||
$(top_srcdir)/../../lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(am__plugin_include_HEADERS_DIST)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
|
||||
"$(DESTDIR)$(plugin_includedir)"
|
||||
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
|
||||
libgomp_plugin_intelmic_la_LIBADD =
|
||||
@PLUGIN_HOST_TRUE@am_libgomp_plugin_intelmic_la_OBJECTS = libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo
|
||||
libgomp_plugin_intelmic_la_OBJECTS = \
|
||||
$(am_libgomp_plugin_intelmic_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
libgomp_plugin_intelmic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(libgomp_plugin_intelmic_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@PLUGIN_HOST_TRUE@am_libgomp_plugin_intelmic_la_rpath = -rpath \
|
||||
@PLUGIN_HOST_TRUE@ $(toolexeclibdir)
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/../../depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
AM_V_CXX = $(am__v_CXX_@AM_V@)
|
||||
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
|
||||
am__v_CXX_0 = @echo " CXX " $@;
|
||||
am__v_CXX_1 =
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
|
||||
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
|
||||
am__v_CXXLD_0 = @echo " CXXLD " $@;
|
||||
am__v_CXXLD_1 =
|
||||
SOURCES = $(libgomp_plugin_intelmic_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__plugin_include_HEADERS_DIST = main_target_image.h
|
||||
HEADERS = $(plugin_include_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
AM_RECURSIVE_TARGETS = cscope
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
accel_search_dir = @accel_search_dir@
|
||||
accel_target = @accel_target@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
get_gcc_base_ver = @get_gcc_base_ver@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
multi_basedir = @multi_basedir@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
toolexecdir = @toolexecdir@
|
||||
toolexeclibdir = @toolexeclibdir@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I ../.. -I ../../config
|
||||
|
||||
# Directories
|
||||
build_dir = $(top_builddir)
|
||||
source_dir = $(top_srcdir)
|
||||
coi_inc_dir = $(top_srcdir)/../include/coi
|
||||
include_src_dir = $(top_srcdir)/../../include
|
||||
libgomp_src_dir = $(top_srcdir)/../../libgomp
|
||||
libgomp_dir = $(build_dir)/../../libgomp
|
||||
liboffload_src_dir = $(top_srcdir)/../runtime
|
||||
liboffload_dir = $(top_builddir)/..
|
||||
|
||||
# May be used by toolexeclibdir.
|
||||
gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../../gcc/BASE-VER)
|
||||
libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/include
|
||||
# Search for main_target_image.h in these directories
|
||||
target_prefix_dir = $(libdir)/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
|
||||
target_build_dir = $(accel_search_dir)/$(accel_target)$(MULTISUBDIR)/liboffloadmic/plugin
|
||||
target_install_dir = $(accel_search_dir)/lib/gcc/$(accel_target)/$(gcc_version)$(MULTISUBDIR)
|
||||
@PLUGIN_HOST_TRUE@toolexeclib_LTLIBRARIES = libgomp-plugin-intelmic.la
|
||||
@PLUGIN_HOST_TRUE@libgomp_plugin_intelmic_la_SOURCES = libgomp-plugin-intelmic.cpp
|
||||
@PLUGIN_HOST_TRUE@libgomp_plugin_intelmic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=1 -I$(coi_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_src_dir) -I$(libgomp_dir) -I$(include_src_dir) -I$(target_prefix_dir)/include -I$(target_build_dir) -I$(target_install_dir)/include
|
||||
@PLUGIN_HOST_TRUE@libgomp_plugin_intelmic_la_LDFLAGS = -L$(liboffload_dir)/.libs -loffloadmic_host -version-info 1:0:0
|
||||
@PLUGIN_HOST_FALSE@plugin_includedir = $(libsubincludedir)
|
||||
@PLUGIN_HOST_FALSE@plugin_include_HEADERS = main_target_image.h
|
||||
@PLUGIN_HOST_FALSE@AM_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=0 -I$(coi_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_dir)
|
||||
@PLUGIN_HOST_FALSE@AM_CXXFLAGS = $(CXXFLAGS)
|
||||
@PLUGIN_HOST_FALSE@AM_LDFLAGS = -L$(liboffload_dir)/.libs -L$(libgomp_dir)/.libs -loffloadmic_target -lcoi_device -lgomp -rdynamic
|
||||
|
||||
# Work around what appears to be a GNU make bug handling MAKEFLAGS
|
||||
# values defined in terms of make variables, as is the case for CC and
|
||||
# friends when we are called from the top level Makefile.
|
||||
AM_MAKEFLAGS = \
|
||||
"AR_FLAGS=$(AR_FLAGS)" \
|
||||
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
|
||||
"CFLAGS=$(CFLAGS)" \
|
||||
"CXXFLAGS=$(CXXFLAGS)" \
|
||||
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
|
||||
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
|
||||
"INSTALL=$(INSTALL)" \
|
||||
"INSTALL_DATA=$(INSTALL_DATA)" \
|
||||
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
|
||||
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
|
||||
"JC1FLAGS=$(JC1FLAGS)" \
|
||||
"LDFLAGS=$(LDFLAGS)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
|
||||
"MAKE=$(MAKE)" \
|
||||
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
|
||||
"SHELL=$(SHELL)" \
|
||||
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
|
||||
"exec_prefix=$(exec_prefix)" \
|
||||
"infodir=$(infodir)" \
|
||||
"libdir=$(libdir)" \
|
||||
"prefix=$(prefix)" \
|
||||
"includedir=$(includedir)" \
|
||||
"AR=$(AR)" \
|
||||
"AS=$(AS)" \
|
||||
"LD=$(LD)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"NM=$(NM)" \
|
||||
"PICFLAG=$(PICFLAG)" \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"DESTDIR=$(DESTDIR)"
|
||||
|
||||
MAKEOVERRIDES =
|
||||
MULTISRCTOP =
|
||||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
am--refresh: Makefile
|
||||
@:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/../../multilib.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
$(top_srcdir)/../../multilib.am $(am__empty):
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \
|
||||
}
|
||||
|
||||
uninstall-toolexeclibLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-toolexeclibLTLIBRARIES:
|
||||
-test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES)
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; \
|
||||
locs=`for p in $$list; do echo $$p; done | \
|
||||
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
||||
sort -u`; \
|
||||
test -z "$$locs" || { \
|
||||
echo rm -f $${locs}; \
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
|
||||
libgomp-plugin-intelmic.la: $(libgomp_plugin_intelmic_la_OBJECTS) $(libgomp_plugin_intelmic_la_DEPENDENCIES) $(EXTRA_libgomp_plugin_intelmic_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(libgomp_plugin_intelmic_la_LINK) $(am_libgomp_plugin_intelmic_la_rpath) $(libgomp_plugin_intelmic_la_OBJECTS) $(libgomp_plugin_intelmic_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.Plo@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.obj:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.cpp.lo:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo: libgomp-plugin-intelmic.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgomp_plugin_intelmic_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo -MD -MP -MF $(DEPDIR)/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.Tpo -c -o libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo `test -f 'libgomp-plugin-intelmic.cpp' || echo '$(srcdir)/'`libgomp-plugin-intelmic.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.Tpo $(DEPDIR)/libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='libgomp-plugin-intelmic.cpp' object='libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgomp_plugin_intelmic_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgomp_plugin_intelmic_la-libgomp-plugin-intelmic.lo `test -f 'libgomp-plugin-intelmic.cpp' || echo '$(srcdir)/'`libgomp-plugin-intelmic.cpp
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
install-plugin_includeHEADERS: $(plugin_include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(plugin_include_HEADERS)'; test -n "$(plugin_includedir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(plugin_includedir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(plugin_includedir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(plugin_includedir)'"; \
|
||||
$(INSTALL_HEADER) $$files "$(DESTDIR)$(plugin_includedir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-plugin_includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(plugin_include_HEADERS)'; test -n "$(plugin_includedir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(plugin_includedir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscope: cscope.files
|
||||
test ! -s cscope.files \
|
||||
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
|
||||
clean-cscope:
|
||||
-rm -f cscope.files
|
||||
cscope.files: clean-cscope cscopelist
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS) all-local
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(plugin_includedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-local \
|
||||
clean-toolexeclibLTLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-local distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-plugin_includeHEADERS
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-exec-local install-toolexeclibLTLIBRARIES
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic \
|
||||
maintainer-clean-local
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool mostlyclean-local
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-plugin_includeHEADERS \
|
||||
uninstall-toolexeclibLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am all-local am--refresh check \
|
||||
check-am clean clean-cscope clean-generic clean-libtool \
|
||||
clean-local clean-toolexeclibLTLIBRARIES cscope cscopelist-am \
|
||||
ctags ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-local distclean-tags dvi dvi-am \
|
||||
html html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-exec-local install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-plugin_includeHEADERS \
|
||||
install-ps install-ps-am install-strip \
|
||||
install-toolexeclibLTLIBRARIES installcheck installcheck-am \
|
||||
installdirs maintainer-clean maintainer-clean-generic \
|
||||
maintainer-clean-local mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \
|
||||
pdf-am ps ps-am tags tags-am uninstall uninstall-am \
|
||||
uninstall-plugin_includeHEADERS \
|
||||
uninstall-toolexeclibLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
main_target_image.h: offload_target_main
|
||||
@echo -n "const int image_size = " > $@
|
||||
@stat -c '%s' $< >> $@
|
||||
@echo ";" >> $@
|
||||
@echo "struct MainTargetImage {" >> $@
|
||||
@echo " int64_t size;" >> $@
|
||||
@echo " char name[sizeof \"offload_target_main\"];" >> $@
|
||||
@echo " uint8_t data[image_size];" >> $@
|
||||
@echo "};" >> $@
|
||||
@echo "extern \"C\" const MainTargetImage main_target_image = {" >> $@
|
||||
@echo " image_size, \"offload_target_main\"," >> $@
|
||||
@cat $< | xxd -include >> $@
|
||||
@echo "};" >> $@
|
||||
|
||||
offload_target_main: $(liboffload_dir)/ofldbegin.o offload_target_main.o $(liboffload_dir)/ofldend.o
|
||||
$(CXX) $(AM_LDFLAGS) $^ -o $@
|
||||
|
||||
offload_target_main.o: offload_target_main.cpp
|
||||
$(CXX) $(AM_CXXFLAGS) $(AM_CPPFLAGS) -c $< -o $@
|
||||
|
||||
# GNU Make needs to see an explicit $(MAKE) variable in the command it
|
||||
# runs to enable its job server during parallel builds. Hence the
|
||||
# comments below.
|
||||
all-multi:
|
||||
$(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)
|
||||
install-multi:
|
||||
$(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE)
|
||||
mostlyclean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE)
|
||||
clean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE)
|
||||
distclean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE)
|
||||
maintainer-clean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE)
|
||||
|
||||
.MAKE .PHONY: all-multi clean-multi distclean-multi install-am \
|
||||
install-multi maintainer-clean-multi mostlyclean-multi
|
||||
|
||||
install-exec-local: install-multi
|
||||
|
||||
all-local: all-multi
|
||||
mostlyclean-local: mostlyclean-multi
|
||||
clean-local: clean-multi
|
||||
distclean-local: distclean-multi
|
||||
maintainer-clean-local: maintainer-clean-multi
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
1180
liboffloadmic/plugin/aclocal.m4
vendored
1180
liboffloadmic/plugin/aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
17000
liboffloadmic/plugin/configure
vendored
17000
liboffloadmic/plugin/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,147 +0,0 @@
|
|||
# Plugin for offload execution on Intel MIC devices.
|
||||
#
|
||||
# Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# Contributed by Andrey Turetskiy <andrey.turetskiy@intel.com>.
|
||||
#
|
||||
# This file is part of the GNU Offloading and Multi Processing Library
|
||||
# (libgomp).
|
||||
#
|
||||
# Libgomp is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the GCC Runtime Library Exception, version
|
||||
# 3.1, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License and
|
||||
# a copy of the GCC Runtime Library Exception along with this program;
|
||||
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Process this file with autoconf to produce a configure script, like so:
|
||||
# aclocal -I ../.. -I ../../config && autoconf && automake
|
||||
|
||||
AC_INIT([Intel MIC Offload Plugin], [1.0], ,[libgomp-plugin-intelmic])
|
||||
|
||||
AC_CONFIG_AUX_DIR(../..)
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
target_alias=${target_alias-$host_alias}
|
||||
AC_SUBST(target_alias)
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9.0 foreign no-dist])
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AM_ENABLE_MULTILIB(, ../..)
|
||||
|
||||
if test "${multilib}" = "yes"; then
|
||||
multilib_arg="--enable-multilib"
|
||||
else
|
||||
multilib_arg=
|
||||
fi
|
||||
|
||||
# Make sure liboffloadmic is enabled
|
||||
case "$enable_liboffloadmic" in
|
||||
host | target)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Liboffloadmic is disabled]) ;;
|
||||
esac
|
||||
AM_CONDITIONAL(PLUGIN_HOST, [test x"$enable_liboffloadmic" = xhost])
|
||||
|
||||
# Get accel target and path to build or install tree of accel compiler
|
||||
accel_search_dir=
|
||||
accel_target=
|
||||
if test x"$enable_liboffloadmic" = xhost; then
|
||||
for accel in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
|
||||
accel_name=`echo $accel | sed 's/=.*//'`
|
||||
accel_dir=`echo $accel | grep '=' | sed 's/.*=//'`
|
||||
case "$accel_name" in
|
||||
*-intelmic-* | *-intelmicemul-*)
|
||||
accel_target=$accel_name
|
||||
accel_search_dir=$accel_dir
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if test x"$accel_target" = x; then
|
||||
AC_MSG_ERROR([--enable-offload-targets does not contain intelmic target])
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(accel_search_dir)
|
||||
AC_SUBST(accel_target)
|
||||
|
||||
AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
|
||||
AC_ARG_ENABLE([version-specific-runtime-libs],
|
||||
AC_HELP_STRING([--enable-version-specific-runtime-libs],
|
||||
[Specify that runtime libraries should be installed in a compiler-specific directory]),
|
||||
[case "$enableval" in
|
||||
yes) enable_version_specific_runtime_libs=yes ;;
|
||||
no) enable_version_specific_runtime_libs=no ;;
|
||||
*) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
|
||||
esac],
|
||||
[enable_version_specific_runtime_libs=no])
|
||||
AC_MSG_RESULT($enable_version_specific_runtime_libs)
|
||||
|
||||
|
||||
GCC_WITH_TOOLEXECLIBDIR
|
||||
|
||||
# Calculate toolexeclibdir.
|
||||
# Also toolexecdir, though it's only used in toolexeclibdir.
|
||||
case ${enable_version_specific_runtime_libs} in
|
||||
yes)
|
||||
# Need the gcc compiler version to know where to install libraries
|
||||
# and header files if --enable-version-specific-runtime-libs option
|
||||
# is selected.
|
||||
toolexecdir='$(libdir)/gcc/$(target_alias)'
|
||||
toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
|
||||
;;
|
||||
no)
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
# Install a library built with a cross compiler in tooldir, not libdir.
|
||||
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||
case ${with_toolexeclibdir} in
|
||||
no)
|
||||
toolexeclibdir='$(toolexecdir)/lib'
|
||||
;;
|
||||
*)
|
||||
toolexeclibdir=${with_toolexeclibdir}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
multi_os_directory=`$CC -print-multi-os-directory`
|
||||
case $multi_os_directory in
|
||||
.) ;; # Avoid trailing /.
|
||||
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_LIBTOOL_DLOPEN
|
||||
AM_PROG_LIBTOOL
|
||||
# Forbid libtool to hardcode RPATH, because we want to be able to specify
|
||||
# library search directory using LD_LIBRARY_PATH
|
||||
hardcode_into_libs=no
|
||||
AC_SUBST(toolexecdir)
|
||||
AC_SUBST(toolexeclibdir)
|
||||
|
||||
# Determine what GCC version number to use in filesystem paths.
|
||||
GCC_BASE_VER
|
||||
|
||||
# Must be last
|
||||
AC_OUTPUT
|
|
@ -1,545 +0,0 @@
|
|||
/* Plugin for offload execution on Intel MIC devices.
|
||||
|
||||
Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Ilya Verbin <ilya.verbin@intel.com>.
|
||||
|
||||
This file is part of the GNU Offloading and Multi Processing Library
|
||||
(libgomp).
|
||||
|
||||
Libgomp is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Host side part of a libgomp plugin. */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "libgomp-plugin.h"
|
||||
#include "compiler_if_host.h"
|
||||
#include "main_target_image.h"
|
||||
#include "gomp-constants.h"
|
||||
|
||||
#define OFFLOAD_ACTIVE_WAIT_ENV "OFFLOAD_ACTIVE_WAIT"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TRACE(...) \
|
||||
{ \
|
||||
fprintf (stderr, "HOST:\t%s:%s ", __FILE__, __FUNCTION__); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define TRACE { }
|
||||
#endif
|
||||
|
||||
|
||||
/* Start/end addresses of functions and global variables on a device. */
|
||||
typedef std::vector<addr_pair> AddrVect;
|
||||
|
||||
/* Addresses for one image and all devices. */
|
||||
typedef std::vector<AddrVect> DevAddrVect;
|
||||
|
||||
/* Addresses for all images and all devices. */
|
||||
typedef std::map<const void *, DevAddrVect> ImgDevAddrMap;
|
||||
|
||||
/* Image descriptor needed by __offload_[un]register_image. */
|
||||
struct TargetImageDesc {
|
||||
int64_t size;
|
||||
/* 10 characters is enough for max int value. */
|
||||
char name[sizeof ("lib0000000000.so")];
|
||||
char data[];
|
||||
};
|
||||
|
||||
/* Image descriptors, indexed by a pointer obtained from libgomp. */
|
||||
typedef std::map<const void *, TargetImageDesc *> ImgDescMap;
|
||||
|
||||
|
||||
/* Total number of available devices. */
|
||||
static int num_devices;
|
||||
|
||||
/* Total number of shared libraries with offloading to Intel MIC. */
|
||||
static int num_images;
|
||||
|
||||
/* Two dimensional array: one key is a pointer to image,
|
||||
second key is number of device. Contains a vector of pointer pairs. */
|
||||
static ImgDevAddrMap *address_table;
|
||||
|
||||
/* Descriptors of all images, registered in liboffloadmic. */
|
||||
static ImgDescMap *image_descriptors;
|
||||
|
||||
/* Thread-safe registration of the main image. */
|
||||
static pthread_once_t main_image_is_registered = PTHREAD_ONCE_INIT;
|
||||
|
||||
static VarDesc vd_host2tgt = {
|
||||
{ 1, 1 }, /* dst, src */
|
||||
{ 1, 0 }, /* in, out */
|
||||
1, /* alloc_if */
|
||||
1, /* free_if */
|
||||
4, /* align */
|
||||
0, /* mic_offset */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* is_static, is_static_dstn, has_length,
|
||||
is_stack_buf, sink_addr, alloc_disp,
|
||||
is_noncont_src, is_noncont_dst */
|
||||
0, /* offset */
|
||||
0, /* size */
|
||||
1, /* count */
|
||||
0, /* alloc */
|
||||
0, /* into */
|
||||
0 /* ptr */
|
||||
};
|
||||
|
||||
static VarDesc vd_tgt2host = {
|
||||
{ 1, 1 }, /* dst, src */
|
||||
{ 0, 1 }, /* in, out */
|
||||
1, /* alloc_if */
|
||||
1, /* free_if */
|
||||
4, /* align */
|
||||
0, /* mic_offset */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* is_static, is_static_dstn, has_length,
|
||||
is_stack_buf, sink_addr, alloc_disp,
|
||||
is_noncont_src, is_noncont_dst */
|
||||
0, /* offset */
|
||||
0, /* size */
|
||||
1, /* count */
|
||||
0, /* alloc */
|
||||
0, /* into */
|
||||
0 /* ptr */
|
||||
};
|
||||
|
||||
|
||||
__attribute__((constructor))
|
||||
static void
|
||||
init (void)
|
||||
{
|
||||
const char *active_wait = getenv (OFFLOAD_ACTIVE_WAIT_ENV);
|
||||
|
||||
/* Disable active wait by default to avoid useless CPU usage. */
|
||||
if (!active_wait)
|
||||
setenv (OFFLOAD_ACTIVE_WAIT_ENV, "0", 0);
|
||||
|
||||
address_table = new ImgDevAddrMap;
|
||||
image_descriptors = new ImgDescMap;
|
||||
num_devices = _Offload_number_of_devices ();
|
||||
}
|
||||
|
||||
extern "C" const char *
|
||||
GOMP_OFFLOAD_get_name (void)
|
||||
{
|
||||
const char *res = "intelmic";
|
||||
TRACE ("(): return %s", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" unsigned int
|
||||
GOMP_OFFLOAD_get_caps (void)
|
||||
{
|
||||
unsigned int res = GOMP_OFFLOAD_CAP_OPENMP_400;
|
||||
TRACE ("(): return %x", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
GOMP_OFFLOAD_get_type (void)
|
||||
{
|
||||
enum offload_target_type res = OFFLOAD_TARGET_TYPE_INTEL_MIC;
|
||||
TRACE ("(): return %d", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask)
|
||||
{
|
||||
/* Return -1 if no omp_requires_mask cannot be fulfilled but
|
||||
devices were present. */
|
||||
if (num_devices > 0 && omp_requires_mask != 0)
|
||||
return -1;
|
||||
TRACE ("(): return %d", num_devices);
|
||||
return num_devices;
|
||||
}
|
||||
|
||||
static bool
|
||||
offload (const char *file, uint64_t line, int device, const char *name,
|
||||
int num_vars, VarDesc *vars, const void **async_data)
|
||||
{
|
||||
OFFLOAD ofld = __offload_target_acquire1 (&device, file, line);
|
||||
if (ofld)
|
||||
{
|
||||
if (async_data == NULL)
|
||||
return __offload_offload1 (ofld, name, 0, num_vars, vars, NULL, 0,
|
||||
NULL, NULL);
|
||||
else
|
||||
{
|
||||
OffloadFlags flags;
|
||||
flags.flags = 0;
|
||||
flags.bits.omp_async = 1;
|
||||
return __offload_offload3 (ofld, name, 0, num_vars, vars, NULL, 0,
|
||||
NULL, async_data, 0, NULL, flags, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GOMP_PLUGIN_error ("%s:%d: Offload target acquire failed\n", file, line);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
register_main_image ()
|
||||
{
|
||||
/* Do not check the return value, because old versions of liboffloadmic did
|
||||
not have return values. */
|
||||
__offload_register_image (&main_target_image);
|
||||
|
||||
/* liboffloadmic will call GOMP_PLUGIN_target_task_completion when
|
||||
asynchronous task on target is completed. */
|
||||
__offload_register_task_callback (GOMP_PLUGIN_target_task_completion);
|
||||
}
|
||||
|
||||
/* liboffloadmic loads and runs offload_target_main on all available devices
|
||||
during a first call to offload (). */
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_init_device (int device)
|
||||
{
|
||||
TRACE ("(device = %d)", device);
|
||||
pthread_once (&main_image_is_registered, register_main_image);
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_init_proc", 0,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_fini_device (int device)
|
||||
{
|
||||
TRACE ("(device = %d)", device);
|
||||
|
||||
/* liboffloadmic will finalize target processes on all available devices. */
|
||||
__offload_unregister_image (&main_target_image);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
get_target_table (int device, int &num_funcs, int &num_vars, void **&table)
|
||||
{
|
||||
VarDesc vd1[2] = { vd_tgt2host, vd_tgt2host };
|
||||
vd1[0].ptr = &num_funcs;
|
||||
vd1[0].size = sizeof (num_funcs);
|
||||
vd1[1].ptr = &num_vars;
|
||||
vd1[1].size = sizeof (num_vars);
|
||||
|
||||
if (!offload (__FILE__, __LINE__, device, "__offload_target_table_p1", 2,
|
||||
vd1, NULL))
|
||||
return false;
|
||||
|
||||
int table_size = num_funcs + 2 * num_vars;
|
||||
if (table_size > 0)
|
||||
{
|
||||
table = new void * [table_size];
|
||||
|
||||
VarDesc vd2;
|
||||
vd2 = vd_tgt2host;
|
||||
vd2.ptr = table;
|
||||
vd2.size = table_size * sizeof (void *);
|
||||
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_table_p2",
|
||||
1, &vd2, NULL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Offload TARGET_IMAGE to all available devices and fill address_table with
|
||||
corresponding target addresses. */
|
||||
|
||||
static bool
|
||||
offload_image (const void *target_image)
|
||||
{
|
||||
void *image_start = ((void **) target_image)[0];
|
||||
void *image_end = ((void **) target_image)[1];
|
||||
|
||||
TRACE ("(target_image = %p { %p, %p })",
|
||||
target_image, image_start, image_end);
|
||||
|
||||
int64_t image_size = (uintptr_t) image_end - (uintptr_t) image_start;
|
||||
TargetImageDesc *image = (TargetImageDesc *) malloc (offsetof (TargetImageDesc, data)
|
||||
+ image_size);
|
||||
if (!image)
|
||||
{
|
||||
GOMP_PLUGIN_error ("%s: Can't allocate memory\n", __FILE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
image->size = image_size;
|
||||
sprintf (image->name, "lib%010d.so", num_images++);
|
||||
memcpy (image->data, image_start, image->size);
|
||||
|
||||
TRACE ("() __offload_register_image %s { %p, %d }",
|
||||
image->name, image_start, image->size);
|
||||
/* Do not check the return value, because old versions of liboffloadmic did
|
||||
not have return values. */
|
||||
__offload_register_image (image);
|
||||
|
||||
/* Receive tables for target_image from all devices. */
|
||||
DevAddrVect dev_table;
|
||||
bool ret = true;
|
||||
for (int dev = 0; dev < num_devices; dev++)
|
||||
{
|
||||
int num_funcs = 0;
|
||||
int num_vars = 0;
|
||||
void **table = NULL;
|
||||
|
||||
ret &= get_target_table (dev, num_funcs, num_vars, table);
|
||||
|
||||
AddrVect curr_dev_table;
|
||||
|
||||
for (int i = 0; i < num_funcs; i++)
|
||||
{
|
||||
addr_pair tgt_addr;
|
||||
tgt_addr.start = (uintptr_t) table[i];
|
||||
tgt_addr.end = tgt_addr.start + 1;
|
||||
TRACE ("() func %d:\t0x%llx..0x%llx", i,
|
||||
tgt_addr.start, tgt_addr.end);
|
||||
curr_dev_table.push_back (tgt_addr);
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_vars; i++)
|
||||
{
|
||||
addr_pair tgt_addr;
|
||||
tgt_addr.start = (uintptr_t) table[num_funcs+i*2];
|
||||
tgt_addr.end = tgt_addr.start + (uintptr_t) table[num_funcs+i*2+1];
|
||||
TRACE ("() var %d:\t0x%llx..0x%llx", i, tgt_addr.start, tgt_addr.end);
|
||||
curr_dev_table.push_back (tgt_addr);
|
||||
}
|
||||
|
||||
dev_table.push_back (curr_dev_table);
|
||||
delete [] table;
|
||||
}
|
||||
|
||||
address_table->insert (std::make_pair (target_image, dev_table));
|
||||
image_descriptors->insert (std::make_pair (target_image, image));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return the libgomp version number we're compatible with. There is
|
||||
no requirement for cross-version compatibility. */
|
||||
|
||||
extern "C" unsigned
|
||||
GOMP_OFFLOAD_version (void)
|
||||
{
|
||||
return GOMP_VERSION;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
GOMP_OFFLOAD_load_image (int device, const unsigned version,
|
||||
const void *target_image, addr_pair **result,
|
||||
uint64_t ** /* rev_fn_table */)
|
||||
{
|
||||
TRACE ("(device = %d, target_image = %p)", device, target_image);
|
||||
|
||||
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_INTEL_MIC)
|
||||
{
|
||||
GOMP_PLUGIN_error ("Offload data incompatible with intelmic plugin"
|
||||
" (expected %u, received %u)",
|
||||
GOMP_VERSION_INTEL_MIC, GOMP_VERSION_DEV (version));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If target_image is already present in address_table, then there is no need
|
||||
to offload it. */
|
||||
if (address_table->count (target_image) == 0)
|
||||
{
|
||||
/* If fail, return -1 as error code. */
|
||||
if (!offload_image (target_image))
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddrVect *curr_dev_table = &(*address_table)[target_image][device];
|
||||
int table_size = curr_dev_table->size ();
|
||||
addr_pair *table = (addr_pair *) malloc (table_size * sizeof (addr_pair));
|
||||
if (table == NULL)
|
||||
{
|
||||
GOMP_PLUGIN_error ("%s: Can't allocate memory\n", __FILE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::copy (curr_dev_table->begin (), curr_dev_table->end (), table);
|
||||
*result = table;
|
||||
return table_size;
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_unload_image (int device, unsigned version,
|
||||
const void *target_image)
|
||||
{
|
||||
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_INTEL_MIC)
|
||||
{
|
||||
GOMP_PLUGIN_error ("Offload data incompatible with intelmic plugin"
|
||||
" (expected %u, received %u)",
|
||||
GOMP_VERSION_INTEL_MIC, GOMP_VERSION_DEV (version));
|
||||
return false;
|
||||
}
|
||||
|
||||
TRACE ("(device = %d, target_image = %p)", device, target_image);
|
||||
|
||||
/* liboffloadmic unloads the image from all available devices. */
|
||||
if (image_descriptors->count (target_image) > 0)
|
||||
{
|
||||
TargetImageDesc *image_desc = (*image_descriptors)[target_image];
|
||||
__offload_unregister_image (image_desc);
|
||||
free (image_desc);
|
||||
|
||||
address_table->erase (target_image);
|
||||
image_descriptors->erase (target_image);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
GOMP_OFFLOAD_alloc (int device, size_t size)
|
||||
{
|
||||
TRACE ("(device = %d, size = %d)", device, size);
|
||||
|
||||
void *tgt_ptr;
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_tgt2host };
|
||||
vd[0].ptr = &size;
|
||||
vd[0].size = sizeof (size);
|
||||
vd[1].ptr = &tgt_ptr;
|
||||
vd[1].size = sizeof (void *);
|
||||
|
||||
if (!offload (__FILE__, __LINE__, device, "__offload_target_alloc", 2,
|
||||
vd, NULL))
|
||||
return NULL;
|
||||
|
||||
return tgt_ptr;
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_free (int device, void *tgt_ptr)
|
||||
{
|
||||
TRACE ("(device = %d, tgt_ptr = %p)", device, tgt_ptr);
|
||||
|
||||
VarDesc vd = vd_host2tgt;
|
||||
vd.ptr = &tgt_ptr;
|
||||
vd.size = sizeof (void *);
|
||||
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_free", 1,
|
||||
&vd, NULL);
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_host2dev (int device, void *tgt_ptr, const void *host_ptr,
|
||||
size_t size)
|
||||
{
|
||||
TRACE ("(device = %d, tgt_ptr = %p, host_ptr = %p, size = %d)",
|
||||
device, tgt_ptr, host_ptr, size);
|
||||
if (!size)
|
||||
return true;
|
||||
|
||||
VarDesc vd1[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd1[0].ptr = &tgt_ptr;
|
||||
vd1[0].size = sizeof (void *);
|
||||
vd1[1].ptr = &size;
|
||||
vd1[1].size = sizeof (size);
|
||||
|
||||
if (!offload (__FILE__, __LINE__, device, "__offload_target_host2tgt_p1", 2,
|
||||
vd1, NULL))
|
||||
return false;
|
||||
|
||||
VarDesc vd2 = vd_host2tgt;
|
||||
vd2.ptr = (void *) host_ptr;
|
||||
vd2.size = size;
|
||||
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_host2tgt_p2", 1,
|
||||
&vd2, NULL);
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_dev2host (int device, void *host_ptr, const void *tgt_ptr,
|
||||
size_t size)
|
||||
{
|
||||
TRACE ("(device = %d, host_ptr = %p, tgt_ptr = %p, size = %d)",
|
||||
device, host_ptr, tgt_ptr, size);
|
||||
if (!size)
|
||||
return true;
|
||||
|
||||
VarDesc vd1[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd1[0].ptr = &tgt_ptr;
|
||||
vd1[0].size = sizeof (void *);
|
||||
vd1[1].ptr = &size;
|
||||
vd1[1].size = sizeof (size);
|
||||
|
||||
if (!offload (__FILE__, __LINE__, device, "__offload_target_tgt2host_p1", 2,
|
||||
vd1, NULL))
|
||||
return false;
|
||||
|
||||
VarDesc vd2 = vd_tgt2host;
|
||||
vd2.ptr = (void *) host_ptr;
|
||||
vd2.size = size;
|
||||
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_tgt2host_p2", 1,
|
||||
&vd2, NULL);
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
GOMP_OFFLOAD_dev2dev (int device, void *dst_ptr, const void *src_ptr,
|
||||
size_t size)
|
||||
{
|
||||
TRACE ("(device = %d, dst_ptr = %p, src_ptr = %p, size = %d)",
|
||||
device, dst_ptr, src_ptr, size);
|
||||
if (!size)
|
||||
return true;
|
||||
|
||||
VarDesc vd[3] = { vd_host2tgt, vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &dst_ptr;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &src_ptr;
|
||||
vd[1].size = sizeof (void *);
|
||||
vd[2].ptr = &size;
|
||||
vd[2].size = sizeof (size);
|
||||
|
||||
return offload (__FILE__, __LINE__, device, "__offload_target_tgt2tgt", 3,
|
||||
vd, NULL);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
GOMP_OFFLOAD_async_run (int device, void *tgt_fn, void *tgt_vars,
|
||||
void **, void *async_data)
|
||||
{
|
||||
TRACE ("(device = %d, tgt_fn = %p, tgt_vars = %p, async_data = %p)", device,
|
||||
tgt_fn, tgt_vars, async_data);
|
||||
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &tgt_fn;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &tgt_vars;
|
||||
vd[1].size = sizeof (void *);
|
||||
|
||||
offload (__FILE__, __LINE__, device, "__offload_target_run", 2, vd,
|
||||
(const void **) async_data);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
GOMP_OFFLOAD_run (int device, void *tgt_fn, void *tgt_vars, void **)
|
||||
{
|
||||
TRACE ("(device = %d, tgt_fn = %p, tgt_vars = %p)", device, tgt_fn, tgt_vars);
|
||||
|
||||
GOMP_OFFLOAD_async_run (device, tgt_fn, tgt_vars, NULL, NULL);
|
||||
}
|
|
@ -1,380 +0,0 @@
|
|||
/* Plugin for offload execution on Intel MIC devices.
|
||||
|
||||
Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Ilya Verbin <ilya.verbin@intel.com>.
|
||||
|
||||
This file is part of the GNU Offloading and Multi Processing Library
|
||||
(libgomp).
|
||||
|
||||
Libgomp is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Target side part of a libgomp plugin. */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "compiler_if_target.h"
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TRACE(...) \
|
||||
{ \
|
||||
fprintf (stderr, "TARGET:\t%s:%s ", __FILE__, __FUNCTION__); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define TRACE { }
|
||||
#endif
|
||||
|
||||
|
||||
static VarDesc vd_host2tgt = {
|
||||
{ 1, 1 }, /* dst, src */
|
||||
{ 1, 0 }, /* in, out */
|
||||
1, /* alloc_if */
|
||||
1, /* free_if */
|
||||
4, /* align */
|
||||
0, /* mic_offset */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* is_static, is_static_dstn, has_length,
|
||||
is_stack_buf, sink_addr, alloc_disp,
|
||||
is_noncont_src, is_noncont_dst */
|
||||
0, /* offset */
|
||||
0, /* size */
|
||||
1, /* count */
|
||||
0, /* alloc */
|
||||
0, /* into */
|
||||
0 /* ptr */
|
||||
};
|
||||
|
||||
static VarDesc vd_tgt2host = {
|
||||
{ 1, 1 }, /* dst, src */
|
||||
{ 0, 1 }, /* in, out */
|
||||
1, /* alloc_if */
|
||||
1, /* free_if */
|
||||
4, /* align */
|
||||
0, /* mic_offset */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* is_static, is_static_dstn, has_length,
|
||||
is_stack_buf, sink_addr, alloc_disp,
|
||||
is_noncont_src, is_noncont_dst */
|
||||
0, /* offset */
|
||||
0, /* size */
|
||||
1, /* count */
|
||||
0, /* alloc */
|
||||
0, /* into */
|
||||
0 /* ptr */
|
||||
};
|
||||
|
||||
/* Pointer to the descriptor of the last loaded shared library. */
|
||||
static void *last_loaded_library = NULL;
|
||||
|
||||
/* Pointer and size of the variable, used in __offload_target_host2tgt_p[12]
|
||||
and __offload_target_tgt2host_p[12]. */
|
||||
static void *last_var_ptr = NULL;
|
||||
static int last_var_size = 0;
|
||||
|
||||
|
||||
/* Override the corresponding functions from libgomp. */
|
||||
extern "C" int
|
||||
omp_is_initial_device (void) __GOMP_NOTHROW
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int32_t
|
||||
omp_is_initial_device_ (void)
|
||||
{
|
||||
return omp_is_initial_device ();
|
||||
}
|
||||
|
||||
|
||||
/* Dummy function needed for the initialization of target process during the
|
||||
first call to __offload_offload1. */
|
||||
static void
|
||||
__offload_target_init_proc (OFFLOAD ofldt)
|
||||
{
|
||||
TRACE ("");
|
||||
}
|
||||
|
||||
/* Collect addresses of the offload functions and of the global variables from
|
||||
the library descriptor and send them to host.
|
||||
Part 1: Send num_funcs and num_vars to host. */
|
||||
static void
|
||||
__offload_target_table_p1 (OFFLOAD ofldt)
|
||||
{
|
||||
void ***lib_descr = (void ***) last_loaded_library;
|
||||
|
||||
if (lib_descr == NULL)
|
||||
{
|
||||
TRACE ("");
|
||||
fprintf (stderr, "Error! No shared libraries loaded on target.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
void **func_table_begin = lib_descr[0];
|
||||
void **func_table_end = lib_descr[1];
|
||||
void **var_table_begin = lib_descr[2];
|
||||
void **var_table_end = lib_descr[3];
|
||||
|
||||
/* The func table contains only addresses, the var table contains addresses
|
||||
and corresponding sizes. */
|
||||
int num_funcs = func_table_end - func_table_begin;
|
||||
int num_vars = (var_table_end - var_table_begin) / 2;
|
||||
TRACE ("(num_funcs = %d, num_vars = %d)", num_funcs, num_vars);
|
||||
|
||||
VarDesc vd[2] = { vd_tgt2host, vd_tgt2host };
|
||||
vd[0].ptr = &num_funcs;
|
||||
vd[0].size = sizeof (num_funcs);
|
||||
vd[1].ptr = &num_vars;
|
||||
vd[1].size = sizeof (num_vars);
|
||||
|
||||
__offload_target_enter (ofldt, 2, vd, NULL);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Part 2: Send the table with addresses to host. */
|
||||
static void
|
||||
__offload_target_table_p2 (OFFLOAD ofldt)
|
||||
{
|
||||
void ***lib_descr = (void ***) last_loaded_library;
|
||||
void **func_table_begin = lib_descr[0];
|
||||
void **func_table_end = lib_descr[1];
|
||||
void **var_table_begin = lib_descr[2];
|
||||
void **var_table_end = lib_descr[3];
|
||||
|
||||
int num_funcs = func_table_end - func_table_begin;
|
||||
int num_vars = (var_table_end - var_table_begin) / 2;
|
||||
int table_size = (num_funcs + 2 * num_vars) * sizeof (void *);
|
||||
void **table = (void **) malloc (table_size);
|
||||
TRACE ("(table_size = %d)", table_size);
|
||||
|
||||
VarDesc vd = vd_tgt2host;
|
||||
vd.ptr = table;
|
||||
vd.size = table_size;
|
||||
|
||||
__offload_target_enter (ofldt, 1, &vd, NULL);
|
||||
|
||||
void **p;
|
||||
int i = 0;
|
||||
for (p = func_table_begin; p < func_table_end; p++, i++)
|
||||
table[i] = *p;
|
||||
|
||||
for (p = var_table_begin; p < var_table_end; p++, i++)
|
||||
table[i] = *p;
|
||||
|
||||
__offload_target_leave (ofldt);
|
||||
free (table);
|
||||
}
|
||||
|
||||
/* Allocate size bytes and send a pointer to the allocated memory to host. */
|
||||
static void
|
||||
__offload_target_alloc (OFFLOAD ofldt)
|
||||
{
|
||||
size_t size = 0;
|
||||
void *ptr = NULL;
|
||||
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_tgt2host };
|
||||
vd[0].ptr = &size;
|
||||
vd[0].size = sizeof (size);
|
||||
vd[1].ptr = &ptr;
|
||||
vd[1].size = sizeof (void *);
|
||||
|
||||
__offload_target_enter (ofldt, 2, vd, NULL);
|
||||
ptr = malloc (size);
|
||||
TRACE ("(size = %d): ptr = %p", size, ptr);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Free the memory space pointed to by ptr. */
|
||||
static void
|
||||
__offload_target_free (OFFLOAD ofldt)
|
||||
{
|
||||
void *ptr = 0;
|
||||
|
||||
VarDesc vd = vd_host2tgt;
|
||||
vd.ptr = &ptr;
|
||||
vd.size = sizeof (void *);
|
||||
|
||||
__offload_target_enter (ofldt, 1, &vd, NULL);
|
||||
TRACE ("(ptr = %p)", ptr);
|
||||
free (ptr);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Receive var_size bytes from host and store to var_ptr.
|
||||
Part 1: Receive var_ptr and var_size from host. */
|
||||
static void
|
||||
__offload_target_host2tgt_p1 (OFFLOAD ofldt)
|
||||
{
|
||||
void *var_ptr = NULL;
|
||||
size_t var_size = 0;
|
||||
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &var_ptr;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &var_size;
|
||||
vd[1].size = sizeof (var_size);
|
||||
|
||||
__offload_target_enter (ofldt, 2, vd, NULL);
|
||||
TRACE ("(var_ptr = %p, var_size = %d)", var_ptr, var_size);
|
||||
last_var_ptr = var_ptr;
|
||||
last_var_size = var_size;
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Part 2: Receive the data from host. */
|
||||
static void
|
||||
__offload_target_host2tgt_p2 (OFFLOAD ofldt)
|
||||
{
|
||||
TRACE ("(last_var_ptr = %p, last_var_size = %d)",
|
||||
last_var_ptr, last_var_size);
|
||||
|
||||
VarDesc vd = vd_host2tgt;
|
||||
vd.ptr = last_var_ptr;
|
||||
vd.size = last_var_size;
|
||||
|
||||
__offload_target_enter (ofldt, 1, &vd, NULL);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Send var_size bytes from var_ptr to host.
|
||||
Part 1: Receive var_ptr and var_size from host. */
|
||||
static void
|
||||
__offload_target_tgt2host_p1 (OFFLOAD ofldt)
|
||||
{
|
||||
void *var_ptr = NULL;
|
||||
size_t var_size = 0;
|
||||
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &var_ptr;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &var_size;
|
||||
vd[1].size = sizeof (var_size);
|
||||
|
||||
__offload_target_enter (ofldt, 2, vd, NULL);
|
||||
TRACE ("(var_ptr = %p, var_size = %d)", var_ptr, var_size);
|
||||
last_var_ptr = var_ptr;
|
||||
last_var_size = var_size;
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Part 2: Send the data to host. */
|
||||
static void
|
||||
__offload_target_tgt2host_p2 (OFFLOAD ofldt)
|
||||
{
|
||||
TRACE ("(last_var_ptr = %p, last_var_size = %d)",
|
||||
last_var_ptr, last_var_size);
|
||||
|
||||
VarDesc vd = vd_tgt2host;
|
||||
vd.ptr = last_var_ptr;
|
||||
vd.size = last_var_size;
|
||||
|
||||
__offload_target_enter (ofldt, 1, &vd, NULL);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Copy SIZE bytes from SRC_PTR to DST_PTR. */
|
||||
static void
|
||||
__offload_target_tgt2tgt (OFFLOAD ofldt)
|
||||
{
|
||||
void *src_ptr = NULL;
|
||||
void *dst_ptr = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
VarDesc vd[3] = { vd_host2tgt, vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &dst_ptr;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &src_ptr;
|
||||
vd[1].size = sizeof (void *);
|
||||
vd[2].ptr = &size;
|
||||
vd[2].size = sizeof (size);
|
||||
|
||||
__offload_target_enter (ofldt, 3, vd, NULL);
|
||||
TRACE ("(dst_ptr = %p, src_ptr = %p, size = %d)", dst_ptr, src_ptr, size);
|
||||
memcpy (dst_ptr, src_ptr, size);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
/* Call offload function by the address fn_ptr and pass vars_ptr to it. */
|
||||
static void
|
||||
__offload_target_run (OFFLOAD ofldt)
|
||||
{
|
||||
void *fn_ptr;
|
||||
void *vars_ptr;
|
||||
|
||||
VarDesc vd[2] = { vd_host2tgt, vd_host2tgt };
|
||||
vd[0].ptr = &fn_ptr;
|
||||
vd[0].size = sizeof (void *);
|
||||
vd[1].ptr = &vars_ptr;
|
||||
vd[1].size = sizeof (void *);
|
||||
|
||||
__offload_target_enter (ofldt, 2, vd, NULL);
|
||||
TRACE ("(fn_ptr = %p, vars_ptr = %p)", fn_ptr, vars_ptr);
|
||||
void (*fn)(void *) = (void (*)(void *)) fn_ptr;
|
||||
fn (vars_ptr);
|
||||
__offload_target_leave (ofldt);
|
||||
}
|
||||
|
||||
|
||||
/* This should be called from every library with offloading. */
|
||||
extern "C" void
|
||||
target_register_lib (const void *target_table)
|
||||
{
|
||||
TRACE ("(target_table = %p { %p, %p, %p, %p })", target_table,
|
||||
((void **) target_table)[0], ((void **) target_table)[1],
|
||||
((void **) target_table)[2], ((void **) target_table)[3]);
|
||||
|
||||
last_loaded_library = (void *) target_table;
|
||||
}
|
||||
|
||||
/* Use __offload_target_main from liboffload. */
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
__offload_target_main ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Register offload_target_main's functions in the liboffload. */
|
||||
|
||||
struct Entry {
|
||||
const char *name;
|
||||
void *func;
|
||||
};
|
||||
|
||||
#define REGISTER(f) \
|
||||
extern "C" const Entry __offload_target_##f##_$entry \
|
||||
__attribute__ ((section(".OffloadEntryTable."))) = { \
|
||||
"__offload_target_"#f, \
|
||||
(void *) __offload_target_##f \
|
||||
}
|
||||
REGISTER (init_proc);
|
||||
REGISTER (table_p1);
|
||||
REGISTER (table_p2);
|
||||
REGISTER (alloc);
|
||||
REGISTER (free);
|
||||
REGISTER (host2tgt_p1);
|
||||
REGISTER (host2tgt_p2);
|
||||
REGISTER (tgt2host_p1);
|
||||
REGISTER (tgt2host_p2);
|
||||
REGISTER (tgt2tgt);
|
||||
REGISTER (run);
|
||||
#undef REGISTER
|
|
@ -1,421 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "cean_util.h"
|
||||
#include "offload_common.h"
|
||||
|
||||
// 1. allocate element of CeanReadRanges type
|
||||
// 2. initialized it for reading consequently contiguous ranges
|
||||
// described by "ap" argument
|
||||
CeanReadRanges * init_read_ranges_arr_desc(const Arr_Desc *ap)
|
||||
{
|
||||
CeanReadRanges * res;
|
||||
|
||||
// find the max contiguous range
|
||||
int64_t rank = ap->rank - 1;
|
||||
int64_t length = ap->dim[rank].size;
|
||||
for (; rank >= 0; rank--) {
|
||||
if (ap->dim[rank].stride == 1) {
|
||||
length *= (ap->dim[rank].upper - ap->dim[rank].lower + 1);
|
||||
if (rank > 0 && length != ap->dim[rank - 1].size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
res =(CeanReadRanges *)malloc(sizeof(CeanReadRanges) +
|
||||
(ap->rank - rank) * sizeof(CeanReadDim));
|
||||
if (res == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
|
||||
res->arr_desc = const_cast<Arr_Desc*>(ap);
|
||||
res->current_number = 0;
|
||||
res->range_size = length;
|
||||
res->last_noncont_ind = rank;
|
||||
|
||||
// calculate number of contiguous ranges inside noncontiguous dimensions
|
||||
int count = 1;
|
||||
bool prev_is_cont = true;
|
||||
int64_t offset = 0;
|
||||
|
||||
for (; rank >= 0; rank--) {
|
||||
res->Dim[rank].count = count;
|
||||
res->Dim[rank].size = ap->dim[rank].stride * ap->dim[rank].size;
|
||||
count *= (prev_is_cont && ap->dim[rank].stride == 1? 1 :
|
||||
(ap->dim[rank].upper - ap->dim[rank].lower +
|
||||
ap->dim[rank].stride) / ap->dim[rank].stride);
|
||||
prev_is_cont = false;
|
||||
offset +=(ap->dim[rank].lower - ap->dim[rank].lindex) *
|
||||
ap->dim[rank].size;
|
||||
}
|
||||
res->range_max_number = count;
|
||||
res -> ptr = (void*)ap->base;
|
||||
res -> init_offset = offset;
|
||||
return res;
|
||||
}
|
||||
|
||||
// check if ranges described by 1 argument could be transferred into ranges
|
||||
// described by 2-nd one
|
||||
bool cean_ranges_match(
|
||||
CeanReadRanges * read_rng1,
|
||||
CeanReadRanges * read_rng2
|
||||
)
|
||||
{
|
||||
return ( read_rng1 == NULL || read_rng2 == NULL ||
|
||||
(read_rng1->range_size % read_rng2->range_size == 0 ||
|
||||
read_rng2->range_size % read_rng1->range_size == 0));
|
||||
}
|
||||
|
||||
// Set next offset and length and returns true for next range.
|
||||
// Returns false if the ranges are over.
|
||||
bool get_next_range(
|
||||
CeanReadRanges * read_rng,
|
||||
int64_t *offset
|
||||
)
|
||||
{
|
||||
if (++read_rng->current_number > read_rng->range_max_number) {
|
||||
read_rng->current_number = 0;
|
||||
return false;
|
||||
}
|
||||
int rank = 0;
|
||||
int num = read_rng->current_number - 1;
|
||||
int64_t cur_offset = 0;
|
||||
int num_loc;
|
||||
for (; rank <= read_rng->last_noncont_ind; rank++) {
|
||||
num_loc = num / read_rng->Dim[rank].count;
|
||||
cur_offset += num_loc * read_rng->Dim[rank].size;
|
||||
num = num % read_rng->Dim[rank].count;
|
||||
}
|
||||
*offset = cur_offset + read_rng->init_offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_arr_desc_contiguous(const Arr_Desc *ap)
|
||||
{
|
||||
int64_t rank = ap->rank - 1;
|
||||
int64_t length = ap->dim[rank].size;
|
||||
for (; rank >= 0; rank--) {
|
||||
if (ap->dim[rank].stride > 1 &&
|
||||
ap->dim[rank].upper - ap->dim[rank].lower != 0) {
|
||||
return false;
|
||||
}
|
||||
else if (length != ap->dim[rank].size) {
|
||||
for (; rank >= 0; rank--) {
|
||||
if (ap->dim[rank].upper - ap->dim[rank].lower != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
length *= (ap->dim[rank].upper - ap->dim[rank].lower + 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t cean_get_transf_size(CeanReadRanges * read_rng)
|
||||
{
|
||||
return(read_rng->range_max_number * read_rng->range_size);
|
||||
}
|
||||
|
||||
static uint64_t last_left, last_right;
|
||||
|
||||
typedef void (*fpp)(
|
||||
const char *spaces,
|
||||
uint64_t low,
|
||||
uint64_t high,
|
||||
int esize,
|
||||
bool print_values
|
||||
);
|
||||
|
||||
static void generate_one_range(
|
||||
const char *spaces,
|
||||
uint64_t lrange,
|
||||
uint64_t rrange,
|
||||
fpp fp,
|
||||
int esize,
|
||||
bool print_values
|
||||
)
|
||||
{
|
||||
OFFLOAD_TRACE(3,
|
||||
"%s generate_one_range(lrange=%p, rrange=%p, esize=%d)\n",
|
||||
spaces, (void*)lrange, (void*)rrange, esize);
|
||||
if (last_left == -1) {
|
||||
// First range
|
||||
last_left = lrange;
|
||||
}
|
||||
else {
|
||||
if (lrange == last_right+1) {
|
||||
// Extend previous range, don't print
|
||||
}
|
||||
else {
|
||||
(*fp)(spaces, last_left, last_right, esize, print_values);
|
||||
last_left = lrange;
|
||||
}
|
||||
}
|
||||
last_right = rrange;
|
||||
}
|
||||
|
||||
static bool element_is_contiguous(
|
||||
uint64_t rank,
|
||||
const struct Dim_Desc *ddp
|
||||
)
|
||||
{
|
||||
if (rank == 1) {
|
||||
return (ddp[0].lower == ddp[0].upper || ddp[0].stride == 1);
|
||||
}
|
||||
else {
|
||||
return ((ddp[0].size == (ddp[1].upper-ddp[1].lower+1)*ddp[1].size) &&
|
||||
element_is_contiguous(rank-1, ddp++));
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_mem_ranges_one_rank(
|
||||
const char *spaces,
|
||||
uint64_t base,
|
||||
uint64_t rank,
|
||||
const struct Dim_Desc *ddp,
|
||||
fpp fp,
|
||||
int esize,
|
||||
bool print_values
|
||||
)
|
||||
{
|
||||
uint64_t lindex = ddp->lindex;
|
||||
uint64_t lower = ddp->lower;
|
||||
uint64_t upper = ddp->upper;
|
||||
uint64_t stride = ddp->stride;
|
||||
uint64_t size = ddp->size;
|
||||
OFFLOAD_TRACE(3,
|
||||
"%s "
|
||||
"generate_mem_ranges_one_rank(base=%p, rank=%lld, lindex=%lld, "
|
||||
"lower=%lld, upper=%lld, stride=%lld, size=%lld, esize=%d)\n",
|
||||
spaces, (void*)base, rank, lindex, lower, upper, stride, size, esize);
|
||||
|
||||
if (element_is_contiguous(rank, ddp)) {
|
||||
uint64_t lrange, rrange;
|
||||
lrange = base + (lower-lindex)*size;
|
||||
rrange = lrange + (upper-lower+1)*size - 1;
|
||||
generate_one_range(spaces, lrange, rrange, fp, esize, print_values);
|
||||
}
|
||||
else {
|
||||
if (rank == 1) {
|
||||
for (int i=lower-lindex; i<=upper-lindex; i+=stride) {
|
||||
uint64_t lrange, rrange;
|
||||
lrange = base + i*size;
|
||||
rrange = lrange + size - 1;
|
||||
generate_one_range(spaces, lrange, rrange,
|
||||
fp, esize, print_values);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i=lower-lindex; i<=upper-lindex; i+=stride) {
|
||||
generate_mem_ranges_one_rank(
|
||||
spaces, base+i*size, rank-1, ddp+1,
|
||||
fp, esize, print_values);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_mem_ranges(
|
||||
const char *spaces,
|
||||
const Arr_Desc *adp,
|
||||
bool deref,
|
||||
fpp fp,
|
||||
bool print_values
|
||||
)
|
||||
{
|
||||
uint64_t esize;
|
||||
|
||||
OFFLOAD_TRACE(3,
|
||||
"%s "
|
||||
"generate_mem_ranges(adp=%p, deref=%d, fp)\n",
|
||||
spaces, adp, deref);
|
||||
last_left = -1;
|
||||
last_right = -2;
|
||||
|
||||
// Element size is derived from last dimension
|
||||
esize = adp->dim[adp->rank-1].size;
|
||||
|
||||
generate_mem_ranges_one_rank(
|
||||
// For c_cean_var the base addr is the address of the data
|
||||
// For c_cean_var_ptr the base addr is dereferenced to get to the data
|
||||
spaces, deref ? *((uint64_t*)(adp->base)) : adp->base,
|
||||
adp->rank, &adp->dim[0], fp, esize, print_values);
|
||||
(*fp)(spaces, last_left, last_right, esize, print_values);
|
||||
}
|
||||
|
||||
// returns offset and length of the data to be transferred
|
||||
void __arr_data_offset_and_length(
|
||||
const Arr_Desc *adp,
|
||||
int64_t &offset,
|
||||
int64_t &length
|
||||
)
|
||||
{
|
||||
int64_t rank = adp->rank - 1;
|
||||
int64_t size = adp->dim[rank].size;
|
||||
int64_t r_off = 0; // offset from right boundary
|
||||
|
||||
// find the rightmost dimension which takes just part of its
|
||||
// range. We define it if the size of left rank is not equal
|
||||
// the range's length between upper and lower boungaries
|
||||
while (rank > 0) {
|
||||
size *= (adp->dim[rank].upper - adp->dim[rank].lower + 1);
|
||||
if (size != adp->dim[rank - 1].size) {
|
||||
break;
|
||||
}
|
||||
rank--;
|
||||
}
|
||||
|
||||
offset = (adp->dim[rank].lower - adp->dim[rank].lindex) *
|
||||
adp->dim[rank].size;
|
||||
|
||||
// find gaps both from the left - offset and from the right - r_off
|
||||
for (rank--; rank >= 0; rank--) {
|
||||
offset += (adp->dim[rank].lower - adp->dim[rank].lindex) *
|
||||
adp->dim[rank].size;
|
||||
r_off += adp->dim[rank].size -
|
||||
(adp->dim[rank + 1].upper - adp->dim[rank + 1].lindex + 1) *
|
||||
adp->dim[rank + 1].size;
|
||||
}
|
||||
length = (adp->dim[0].upper - adp->dim[0].lindex + 1) *
|
||||
adp->dim[0].size - offset - r_off;
|
||||
}
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
|
||||
static void print_range(
|
||||
const char *spaces,
|
||||
uint64_t low,
|
||||
uint64_t high,
|
||||
int esize,
|
||||
bool print_values
|
||||
)
|
||||
{
|
||||
char buffer[1024];
|
||||
char number[32];
|
||||
|
||||
OFFLOAD_TRACE(3, "%s print_range(low=%p, high=%p, esize=%d)\n",
|
||||
spaces, (void*)low, (void*)high, esize);
|
||||
|
||||
if (console_enabled < 4 || !print_values) {
|
||||
return;
|
||||
}
|
||||
OFFLOAD_TRACE(4, "%s values:\n", spaces);
|
||||
int count = 0;
|
||||
buffer[0] = '\0';
|
||||
while (low <= high)
|
||||
{
|
||||
switch (esize)
|
||||
{
|
||||
case 1:
|
||||
sprintf(number, "%d ", *((char *)low));
|
||||
low += 1;
|
||||
break;
|
||||
case 2:
|
||||
sprintf(number, "%d ", *((short *)low));
|
||||
low += 2;
|
||||
break;
|
||||
case 4:
|
||||
sprintf(number, "%d ", *((int *)low));
|
||||
low += 4;
|
||||
break;
|
||||
default:
|
||||
sprintf(number, "0x%016x ", *((uint64_t *)low));
|
||||
low += 8;
|
||||
break;
|
||||
}
|
||||
strcat(buffer, number);
|
||||
count++;
|
||||
if (count == 10) {
|
||||
OFFLOAD_TRACE(4, "%s %s\n", spaces, buffer);
|
||||
count = 0;
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
}
|
||||
if (count != 0) {
|
||||
OFFLOAD_TRACE(4, "%s %s\n", spaces, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void __arr_desc_dump(
|
||||
const char *spaces,
|
||||
const char *name,
|
||||
const Arr_Desc *adp,
|
||||
bool deref,
|
||||
bool print_values
|
||||
)
|
||||
{
|
||||
OFFLOAD_TRACE(2, "%s%s CEAN expression %p\n", spaces, name, adp);
|
||||
|
||||
if (adp != 0) {
|
||||
OFFLOAD_TRACE(2, "%s base=%llx, rank=%lld\n",
|
||||
spaces, adp->base, adp->rank);
|
||||
|
||||
for (int i = 0; i < adp->rank; i++) {
|
||||
OFFLOAD_TRACE(2,
|
||||
"%s dimension %d: size=%lld, lindex=%lld, "
|
||||
"lower=%lld, upper=%lld, stride=%lld\n",
|
||||
spaces, i, adp->dim[i].size, adp->dim[i].lindex,
|
||||
adp->dim[i].lower, adp->dim[i].upper,
|
||||
adp->dim[i].stride);
|
||||
}
|
||||
// For c_cean_var the base addr is the address of the data
|
||||
// For c_cean_var_ptr the base addr is dereferenced to get to the data
|
||||
generate_mem_ranges(spaces, adp, deref, &print_range, print_values);
|
||||
}
|
||||
}
|
||||
|
||||
void noncont_struct_dump(
|
||||
const char *spaces,
|
||||
const char *name,
|
||||
struct NonContigDesc *desc_p)
|
||||
{
|
||||
OFFLOAD_TRACE(2, "%s%s NonCont Struct expression %p\n",
|
||||
spaces, name, desc_p->base);
|
||||
if (desc_p) {
|
||||
OFFLOAD_TRACE(2, "%s%s base=%p\n", spaces, name, desc_p->base);
|
||||
for (int i = 0; i < desc_p->interval_cnt; i++) {
|
||||
OFFLOAD_TRACE(2,"%s dimension %d: lower=%lld, size=%lld\n",
|
||||
spaces, i, desc_p->interval[i].lower, desc_p->interval[i].size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t get_noncont_struct_size(struct NonContigDesc *desc_p)
|
||||
{
|
||||
int index = desc_p->interval_cnt - 1;
|
||||
return(desc_p->interval[index].lower + desc_p->interval[index].size);
|
||||
}
|
||||
|
||||
#endif // OFFLOAD_DEBUG
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEAN_UTIL_H_INCLUDED
|
||||
#define CEAN_UTIL_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include "offload_util.h"
|
||||
|
||||
// CEAN expression representation
|
||||
struct Dim_Desc {
|
||||
int64_t size; // Length of data type
|
||||
int64_t lindex; // Lower index
|
||||
int64_t lower; // Lower section bound
|
||||
int64_t upper; // Upper section bound
|
||||
int64_t stride; // Stride
|
||||
};
|
||||
|
||||
struct Arr_Desc {
|
||||
int64_t base; // Base address
|
||||
int64_t rank; // Rank of array
|
||||
Dim_Desc dim[1];
|
||||
};
|
||||
|
||||
struct CeanReadDim {
|
||||
int64_t count; // The number of elements in this dimension
|
||||
int64_t size; // The number of bytes between successive
|
||||
// elements in this dimension.
|
||||
};
|
||||
|
||||
struct CeanReadRanges {
|
||||
Arr_Desc* arr_desc;
|
||||
void * ptr;
|
||||
int64_t current_number; // the number of ranges read
|
||||
int64_t range_max_number; // number of contiguous ranges
|
||||
int64_t range_size; // size of max contiguous range
|
||||
int last_noncont_ind; // size of Dim array
|
||||
int64_t init_offset; // offset of 1-st element from array left bound
|
||||
CeanReadDim Dim[1];
|
||||
};
|
||||
|
||||
struct IntervalDesc {
|
||||
int64_t lower; // Lower index
|
||||
int64_t size; // Size of each element at this interval
|
||||
};
|
||||
|
||||
struct NonContigDesc {
|
||||
int64_t base; // Base address
|
||||
int64_t interval_cnt; // Number of intervals
|
||||
struct IntervalDesc interval[1];
|
||||
};
|
||||
|
||||
// array descriptor length
|
||||
#define __arr_desc_length(rank) \
|
||||
(sizeof(int64_t) + sizeof(Dim_Desc) * (rank))
|
||||
|
||||
// returns offset and length of the data to be transferred
|
||||
DLL_LOCAL void __arr_data_offset_and_length(const Arr_Desc *adp,
|
||||
int64_t &offset,
|
||||
int64_t &length);
|
||||
|
||||
// define if data array described by argument is contiguous one
|
||||
DLL_LOCAL bool is_arr_desc_contiguous(const Arr_Desc *ap);
|
||||
|
||||
// allocate element of CeanReadRanges type initialized
|
||||
// to read consequently contiguous ranges described by "ap" argument
|
||||
DLL_LOCAL CeanReadRanges * init_read_ranges_arr_desc(const Arr_Desc *ap);
|
||||
|
||||
// check if ranges described by 1 argument could be transferred into ranges
|
||||
// described by 2-nd one
|
||||
DLL_LOCAL bool cean_ranges_match(
|
||||
CeanReadRanges * read_rng1,
|
||||
CeanReadRanges * read_rng2
|
||||
);
|
||||
|
||||
// first argument - returned value by call to init_read_ranges_arr_desc.
|
||||
// returns true if offset and length of next range is set successfuly.
|
||||
// returns false if the ranges is over.
|
||||
DLL_LOCAL bool get_next_range(
|
||||
CeanReadRanges * read_rng,
|
||||
int64_t *offset
|
||||
);
|
||||
|
||||
// returns number of transferred bytes
|
||||
DLL_LOCAL int64_t cean_get_transf_size(CeanReadRanges * read_rng);
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
// prints array descriptor contents to stderr
|
||||
DLL_LOCAL void __arr_desc_dump(
|
||||
const char *spaces,
|
||||
const char *name,
|
||||
const Arr_Desc *adp,
|
||||
bool dereference,
|
||||
bool print_values);
|
||||
|
||||
DLL_LOCAL void noncont_struct_dump(
|
||||
const char *spaces,
|
||||
const char *name,
|
||||
struct NonContigDesc *desc_p);
|
||||
|
||||
DLL_LOCAL int64_t get_noncont_struct_size(struct NonContigDesc *desc_p);
|
||||
|
||||
#define ARRAY_DESC_DUMP(spaces, name, adp, dereference, print_values) \
|
||||
if (console_enabled >= 2) \
|
||||
__arr_desc_dump(spaces, name, adp, dereference, print_values);
|
||||
#else
|
||||
#define ARRAY_DESC_DUMP(spaces, name, adp, dereference, print_values)
|
||||
#endif // OFFLOAD_DEBUG
|
||||
|
||||
#endif // CEAN_UTIL_H_INCLUDED
|
|
@ -1,494 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// The COI host interface
|
||||
|
||||
#include "coi_client.h"
|
||||
#include "../offload_common.h"
|
||||
|
||||
namespace COI {
|
||||
|
||||
#define COI_VERSION1 "COI_1.0"
|
||||
#define COI_VERSION2 "COI_2.0"
|
||||
|
||||
bool is_available;
|
||||
static void* lib_handle;
|
||||
|
||||
// pointers to functions from COI library
|
||||
COIRESULT (*EngineGetCount)(COI_ISA_TYPE, uint32_t*);
|
||||
COIRESULT (*EngineGetHandle)(COI_ISA_TYPE, uint32_t, COIENGINE*);
|
||||
|
||||
COIRESULT (*ProcessCreateFromMemory)(COIENGINE, const char*, const void*,
|
||||
uint64_t, int, const char**, uint8_t,
|
||||
const char**, uint8_t, const char*,
|
||||
uint64_t, const char*, const char*,
|
||||
uint64_t, COIPROCESS*);
|
||||
COIRESULT (*ProcessCreateFromFile)(COIENGINE, const char*,
|
||||
int, const char**, uint8_t,
|
||||
const char**, uint8_t, const char*,
|
||||
uint64_t, const char*,COIPROCESS*);
|
||||
COIRESULT (*ProcessSetCacheSize)(COIPROCESS, uint64_t, uint32_t,
|
||||
uint64_t, uint32_t, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*ProcessDestroy)(COIPROCESS, int32_t, uint8_t, int8_t*, uint32_t*);
|
||||
COIRESULT (*ProcessGetFunctionHandles)(COIPROCESS, uint32_t, const char**,
|
||||
COIFUNCTION*);
|
||||
COIRESULT (*ProcessLoadLibraryFromMemory)(COIPROCESS, const void*, uint64_t,
|
||||
const char*, const char*,
|
||||
const char*, uint64_t, uint32_t,
|
||||
COILIBRARY*);
|
||||
COIRESULT (*ProcessUnloadLibrary)(COIPROCESS,
|
||||
COILIBRARY);
|
||||
COIRESULT (*ProcessRegisterLibraries)(uint32_t, const void**, const uint64_t*,
|
||||
const char**, const uint64_t*);
|
||||
|
||||
COIRESULT (*PipelineCreate)(COIPROCESS, COI_CPU_MASK, uint32_t, COIPIPELINE*);
|
||||
COIRESULT (*PipelineDestroy)(COIPIPELINE);
|
||||
COIRESULT (*PipelineRunFunction)(COIPIPELINE, COIFUNCTION, uint32_t,
|
||||
const COIBUFFER*, const COI_ACCESS_FLAGS*,
|
||||
uint32_t, const COIEVENT*, const void*,
|
||||
uint16_t, void*, uint16_t, COIEVENT*);
|
||||
|
||||
COIRESULT (*BufferCreate)(uint64_t, COI_BUFFER_TYPE, uint32_t, const void*,
|
||||
uint32_t, const COIPROCESS*, COIBUFFER*);
|
||||
COIRESULT (*BufferCreateFromMemory)(uint64_t, COI_BUFFER_TYPE, uint32_t,
|
||||
void*, uint32_t, const COIPROCESS*,
|
||||
COIBUFFER*);
|
||||
COIRESULT (*BufferDestroy)(COIBUFFER);
|
||||
COIRESULT (*BufferMap)(COIBUFFER, uint64_t, uint64_t, COI_MAP_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*, COIMAPINSTANCE*, void**);
|
||||
COIRESULT (*BufferUnmap)(COIMAPINSTANCE, uint32_t, const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*BufferWrite)(COIBUFFER, uint64_t, const void*, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*BufferRead)(COIBUFFER, uint64_t, void*, uint64_t, COI_COPY_TYPE,
|
||||
uint32_t, const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*BufferReadMultiD)(COIBUFFER, uint64_t,
|
||||
void *, void *, COI_COPY_TYPE,
|
||||
uint32_t, const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*BufferWriteMultiD)(COIBUFFER, const COIPROCESS,
|
||||
uint64_t, void *, void *,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*, COIEVENT*);
|
||||
|
||||
COIRESULT (*BufferCopy)(COIBUFFER, COIBUFFER, uint64_t, uint64_t, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*, COIEVENT*);
|
||||
COIRESULT (*BufferGetSinkAddress)(COIBUFFER, uint64_t*);
|
||||
COIRESULT (*BufferSetState)(COIBUFFER, COIPROCESS, COI_BUFFER_STATE,
|
||||
COI_BUFFER_MOVE_FLAG, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
|
||||
COIRESULT (*EventWait)(uint16_t, const COIEVENT*, int32_t, uint8_t, uint32_t*,
|
||||
uint32_t*);
|
||||
|
||||
uint64_t (*PerfGetCycleFrequency)(void);
|
||||
|
||||
COIRESULT (*PipelineClearCPUMask) (COI_CPU_MASK);
|
||||
|
||||
COIRESULT (*PipelineSetCPUMask) (COIPROCESS, uint32_t,
|
||||
uint8_t, COI_CPU_MASK);
|
||||
COIRESULT (*EngineGetInfo)(COIENGINE, uint32_t, COI_ENGINE_INFO*);
|
||||
|
||||
COIRESULT (*EventRegisterCallback)(
|
||||
const COIEVENT,
|
||||
void (*)(COIEVENT, const COIRESULT, const void*),
|
||||
const void*,
|
||||
const uint64_t);
|
||||
|
||||
COIRESULT (*ProcessConfigureDMA)(const uint64_t, const int);
|
||||
|
||||
bool init(void)
|
||||
{
|
||||
#ifndef TARGET_WINNT
|
||||
const char *lib_name = "libcoi_host.so.0";
|
||||
#else // TARGET_WINNT
|
||||
const char *lib_name = "coi_host.dll";
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Loading COI library %s ...\n", lib_name);
|
||||
lib_handle = DL_open(lib_name);
|
||||
if (lib_handle == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to load the library\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
EngineGetCount =
|
||||
(COIRESULT (*)(COI_ISA_TYPE, uint32_t*))
|
||||
DL_sym(lib_handle, "COIEngineGetCount", COI_VERSION1);
|
||||
if (EngineGetCount == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIEngineGetCount");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
EngineGetHandle =
|
||||
(COIRESULT (*)(COI_ISA_TYPE, uint32_t, COIENGINE*))
|
||||
DL_sym(lib_handle, "COIEngineGetHandle", COI_VERSION1);
|
||||
if (EngineGetHandle == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIEngineGetHandle");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessCreateFromMemory =
|
||||
(COIRESULT (*)(COIENGINE, const char*, const void*, uint64_t, int,
|
||||
const char**, uint8_t, const char**, uint8_t,
|
||||
const char*, uint64_t, const char*, const char*,
|
||||
uint64_t, COIPROCESS*))
|
||||
DL_sym(lib_handle, "COIProcessCreateFromMemory", COI_VERSION1);
|
||||
if (ProcessCreateFromMemory == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessCreateFromMemory");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessSetCacheSize =
|
||||
(COIRESULT (*)(COIPROCESS, uint64_t, uint32_t,
|
||||
uint64_t, uint32_t, uint32_t,
|
||||
const COIEVENT*, COIEVENT*))
|
||||
DL_sym(lib_handle, "COIProcessSetCacheSize", COI_VERSION1);
|
||||
if (ProcessSetCacheSize == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessSetCacheSize");
|
||||
#if 0 // for now disable as ProcessSetCacheSize is not available on < MPSS 3.4
|
||||
fini();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ProcessCreateFromFile =
|
||||
(COIRESULT (*)(COIENGINE, const char*, int, const char**, uint8_t,
|
||||
const char**, uint8_t, const char*, uint64_t,
|
||||
const char*, COIPROCESS*))
|
||||
DL_sym(lib_handle, "COIProcessCreateFromFile", COI_VERSION1);
|
||||
if (ProcessCreateFromFile == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessCreateFromFile");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessDestroy =
|
||||
(COIRESULT (*)(COIPROCESS, int32_t, uint8_t, int8_t*,
|
||||
uint32_t*))
|
||||
DL_sym(lib_handle, "COIProcessDestroy", COI_VERSION1);
|
||||
if (ProcessDestroy == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessDestroy");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessGetFunctionHandles =
|
||||
(COIRESULT (*)(COIPROCESS, uint32_t, const char**, COIFUNCTION*))
|
||||
DL_sym(lib_handle, "COIProcessGetFunctionHandles", COI_VERSION1);
|
||||
if (ProcessGetFunctionHandles == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessGetFunctionHandles");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessLoadLibraryFromMemory =
|
||||
(COIRESULT (*)(COIPROCESS, const void*, uint64_t, const char*,
|
||||
const char*, const char*, uint64_t, uint32_t,
|
||||
COILIBRARY*))
|
||||
DL_sym(lib_handle, "COIProcessLoadLibraryFromMemory", COI_VERSION2);
|
||||
if (ProcessLoadLibraryFromMemory == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessLoadLibraryFromMemory");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessUnloadLibrary =
|
||||
(COIRESULT (*)(COIPROCESS,
|
||||
COILIBRARY))
|
||||
DL_sym(lib_handle, "COIProcessUnloadLibrary", COI_VERSION1);
|
||||
if (ProcessUnloadLibrary == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessUnloadLibrary");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessRegisterLibraries =
|
||||
(COIRESULT (*)(uint32_t, const void**, const uint64_t*, const char**,
|
||||
const uint64_t*))
|
||||
DL_sym(lib_handle, "COIProcessRegisterLibraries", COI_VERSION1);
|
||||
if (ProcessRegisterLibraries == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIProcessRegisterLibraries");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PipelineCreate =
|
||||
(COIRESULT (*)(COIPROCESS, COI_CPU_MASK, uint32_t, COIPIPELINE*))
|
||||
DL_sym(lib_handle, "COIPipelineCreate", COI_VERSION1);
|
||||
if (PipelineCreate == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPipelineCreate");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PipelineDestroy =
|
||||
(COIRESULT (*)(COIPIPELINE))
|
||||
DL_sym(lib_handle, "COIPipelineDestroy", COI_VERSION1);
|
||||
if (PipelineDestroy == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPipelineDestroy");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PipelineRunFunction =
|
||||
(COIRESULT (*)(COIPIPELINE, COIFUNCTION, uint32_t, const COIBUFFER*,
|
||||
const COI_ACCESS_FLAGS*, uint32_t, const COIEVENT*,
|
||||
const void*, uint16_t, void*, uint16_t, COIEVENT*))
|
||||
DL_sym(lib_handle, "COIPipelineRunFunction", COI_VERSION1);
|
||||
if (PipelineRunFunction == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPipelineRunFunction");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferCreate =
|
||||
(COIRESULT (*)(uint64_t, COI_BUFFER_TYPE, uint32_t, const void*,
|
||||
uint32_t, const COIPROCESS*, COIBUFFER*))
|
||||
DL_sym(lib_handle, "COIBufferCreate", COI_VERSION1);
|
||||
if (BufferCreate == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferCreate");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferCreateFromMemory =
|
||||
(COIRESULT (*)(uint64_t, COI_BUFFER_TYPE, uint32_t, void*,
|
||||
uint32_t, const COIPROCESS*, COIBUFFER*))
|
||||
DL_sym(lib_handle, "COIBufferCreateFromMemory", COI_VERSION1);
|
||||
if (BufferCreateFromMemory == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferCreateFromMemory");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferDestroy =
|
||||
(COIRESULT (*)(COIBUFFER))
|
||||
DL_sym(lib_handle, "COIBufferDestroy", COI_VERSION1);
|
||||
if (BufferDestroy == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferDestroy");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferMap =
|
||||
(COIRESULT (*)(COIBUFFER, uint64_t, uint64_t, COI_MAP_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*, COIMAPINSTANCE*,
|
||||
void**))
|
||||
DL_sym(lib_handle, "COIBufferMap", COI_VERSION1);
|
||||
if (BufferMap == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferMap");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferUnmap =
|
||||
(COIRESULT (*)(COIMAPINSTANCE, uint32_t, const COIEVENT*,
|
||||
COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferUnmap", COI_VERSION1);
|
||||
if (BufferUnmap == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferUnmap");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferWrite =
|
||||
(COIRESULT (*)(COIBUFFER, uint64_t, const void*, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*,
|
||||
COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferWrite", COI_VERSION1);
|
||||
if (BufferWrite == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferWrite");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferRead =
|
||||
(COIRESULT (*)(COIBUFFER, uint64_t, void*, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferRead", COI_VERSION1);
|
||||
if (BufferRead == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferRead");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferReadMultiD =
|
||||
(COIRESULT (*)(COIBUFFER, uint64_t,
|
||||
void *, void *, COI_COPY_TYPE,
|
||||
uint32_t, const COIEVENT*, COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferReadMultiD", COI_VERSION1);
|
||||
// We accept that coi library has no COIBufferReadMultiD routine.
|
||||
// So there is no check for zero value
|
||||
|
||||
BufferWriteMultiD =
|
||||
(COIRESULT (*)(COIBUFFER, const COIPROCESS,
|
||||
uint64_t, void *, void *,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*, COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferWriteMultiD", COI_VERSION1);
|
||||
// We accept that coi library has no COIBufferWriteMultiD routine.
|
||||
// So there is no check for zero value
|
||||
|
||||
BufferCopy =
|
||||
(COIRESULT (*)(COIBUFFER, COIBUFFER, uint64_t, uint64_t, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*,
|
||||
COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferCopy", COI_VERSION1);
|
||||
if (BufferCopy == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferCopy");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferGetSinkAddress =
|
||||
(COIRESULT (*)(COIBUFFER, uint64_t*))
|
||||
DL_sym(lib_handle, "COIBufferGetSinkAddress", COI_VERSION1);
|
||||
if (BufferGetSinkAddress == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferGetSinkAddress");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferSetState =
|
||||
(COIRESULT(*)(COIBUFFER, COIPROCESS, COI_BUFFER_STATE,
|
||||
COI_BUFFER_MOVE_FLAG, uint32_t, const COIEVENT*,
|
||||
COIEVENT*))
|
||||
DL_sym(lib_handle, "COIBufferSetState", COI_VERSION1);
|
||||
if (BufferSetState == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIBufferSetState");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
EventWait =
|
||||
(COIRESULT (*)(uint16_t, const COIEVENT*, int32_t, uint8_t,
|
||||
uint32_t*, uint32_t*))
|
||||
DL_sym(lib_handle, "COIEventWait", COI_VERSION1);
|
||||
if (EventWait == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIEventWait");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PerfGetCycleFrequency =
|
||||
(uint64_t (*)(void))
|
||||
DL_sym(lib_handle, "COIPerfGetCycleFrequency", COI_VERSION1);
|
||||
if (PerfGetCycleFrequency == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPerfGetCycleFrequency");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PipelineClearCPUMask =
|
||||
(COIRESULT (*)(COI_CPU_MASK))
|
||||
DL_sym(lib_handle, "COIPipelineClearCPUMask", COI_VERSION1);
|
||||
if (PipelineClearCPUMask == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPipelineClearCPUMask");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
PipelineSetCPUMask =
|
||||
(COIRESULT (*)(COIPROCESS, uint32_t,uint8_t, COI_CPU_MASK))
|
||||
DL_sym(lib_handle, "COIPipelineSetCPUMask", COI_VERSION1);
|
||||
if (PipelineSetCPUMask == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIPipelineSetCPUMask");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
EngineGetInfo =
|
||||
(COIRESULT (*)(COIENGINE, uint32_t, COI_ENGINE_INFO*))
|
||||
DL_sym(lib_handle, "COIEngineGetInfo", COI_VERSION1);
|
||||
if (EngineGetInfo == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
|
||||
"COIEngineGetInfo");
|
||||
fini();
|
||||
return false;
|
||||
}
|
||||
|
||||
EventRegisterCallback =
|
||||
(COIRESULT (*)(COIEVENT,
|
||||
void (*)(COIEVENT, const COIRESULT, const void*),
|
||||
const void*,
|
||||
const uint64_t))
|
||||
DL_sym(lib_handle, "COIEventRegisterCallback", COI_VERSION1);
|
||||
|
||||
ProcessConfigureDMA =
|
||||
(COIRESULT (*)(const uint64_t, const int))
|
||||
DL_sym(lib_handle, "COIProcessConfigureDMA", COI_VERSION1);
|
||||
|
||||
is_available = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void fini(void)
|
||||
{
|
||||
is_available = false;
|
||||
|
||||
if (lib_handle != 0) {
|
||||
#ifndef TARGET_WINNT
|
||||
DL_close(lib_handle);
|
||||
#endif // TARGET_WINNT
|
||||
lib_handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace COI
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// The interface between offload library and the COI API on the host
|
||||
|
||||
#ifndef COI_CLIENT_H_INCLUDED
|
||||
#define COI_CLIENT_H_INCLUDED
|
||||
|
||||
#include <common/COIPerf_common.h>
|
||||
#include <common/COIMacros_common.h>
|
||||
#include <source/COIEngine_source.h>
|
||||
#include <source/COIProcess_source.h>
|
||||
#include <source/COIPipeline_source.h>
|
||||
#include <source/COIBuffer_source.h>
|
||||
#include <source/COIEvent_source.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../liboffload_error_codes.h"
|
||||
#include "../offload_util.h"
|
||||
|
||||
#define MIC_ENGINES_MAX 128
|
||||
|
||||
#if MIC_ENGINES_MAX < COI_MAX_ISA_MIC_DEVICES
|
||||
#error MIC_ENGINES_MAX need to be increased
|
||||
#endif
|
||||
|
||||
// COI library interface
|
||||
namespace COI {
|
||||
|
||||
DLL_LOCAL extern bool init(void);
|
||||
DLL_LOCAL extern void fini(void);
|
||||
|
||||
DLL_LOCAL extern bool is_available;
|
||||
|
||||
// pointers to functions from COI library
|
||||
DLL_LOCAL extern COIRESULT (*EngineGetCount)(COI_ISA_TYPE, uint32_t*);
|
||||
DLL_LOCAL extern COIRESULT (*EngineGetHandle)(COI_ISA_TYPE, uint32_t, COIENGINE*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*ProcessCreateFromMemory)(COIENGINE, const char*,
|
||||
const void*, uint64_t, int,
|
||||
const char**, uint8_t,
|
||||
const char**, uint8_t,
|
||||
const char*, uint64_t,
|
||||
const char*,
|
||||
const char*, uint64_t,
|
||||
COIPROCESS*);
|
||||
DLL_LOCAL extern COIRESULT (*ProcessCreateFromFile)(COIENGINE, const char*, int,
|
||||
const char**, uint8_t,
|
||||
const char**,
|
||||
uint8_t,
|
||||
const char*,
|
||||
uint64_t,
|
||||
const char*,
|
||||
COIPROCESS*);
|
||||
DLL_LOCAL extern COIRESULT (*ProcessSetCacheSize)(COIPROCESS, uint64_t, uint32_t,
|
||||
uint64_t, uint32_t, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*ProcessDestroy)(COIPROCESS, int32_t, uint8_t,
|
||||
int8_t*, uint32_t*);
|
||||
DLL_LOCAL extern COIRESULT (*ProcessGetFunctionHandles)(COIPROCESS, uint32_t,
|
||||
const char**,
|
||||
COIFUNCTION*);
|
||||
DLL_LOCAL extern COIRESULT (*ProcessLoadLibraryFromMemory)(COIPROCESS,
|
||||
const void*,
|
||||
uint64_t,
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
uint64_t,
|
||||
uint32_t,
|
||||
COILIBRARY*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*ProcessUnloadLibrary)(COIPROCESS,
|
||||
COILIBRARY);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*ProcessRegisterLibraries)(uint32_t,
|
||||
const void**,
|
||||
const uint64_t*,
|
||||
const char**,
|
||||
const uint64_t*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*PipelineCreate)(COIPROCESS, COI_CPU_MASK, uint32_t,
|
||||
COIPIPELINE*);
|
||||
DLL_LOCAL extern COIRESULT (*PipelineDestroy)(COIPIPELINE);
|
||||
DLL_LOCAL extern COIRESULT (*PipelineRunFunction)(COIPIPELINE, COIFUNCTION,
|
||||
uint32_t, const COIBUFFER*,
|
||||
const COI_ACCESS_FLAGS*,
|
||||
uint32_t, const COIEVENT*,
|
||||
const void*, uint16_t, void*,
|
||||
uint16_t, COIEVENT*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*BufferCreate)(uint64_t, COI_BUFFER_TYPE, uint32_t,
|
||||
const void*, uint32_t,
|
||||
const COIPROCESS*, COIBUFFER*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferCreateFromMemory)(uint64_t, COI_BUFFER_TYPE,
|
||||
uint32_t, void*,
|
||||
uint32_t, const COIPROCESS*,
|
||||
COIBUFFER*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferDestroy)(COIBUFFER);
|
||||
DLL_LOCAL extern COIRESULT (*BufferMap)(COIBUFFER, uint64_t, uint64_t,
|
||||
COI_MAP_TYPE, uint32_t, const COIEVENT*,
|
||||
COIEVENT*, COIMAPINSTANCE*, void**);
|
||||
DLL_LOCAL extern COIRESULT (*BufferUnmap)(COIMAPINSTANCE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferWrite)(COIBUFFER, uint64_t, const void*,
|
||||
uint64_t, COI_COPY_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferRead)(COIBUFFER, uint64_t, void*, uint64_t,
|
||||
COI_COPY_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferReadMultiD)(COIBUFFER, uint64_t,
|
||||
void *, void *, COI_COPY_TYPE,
|
||||
uint32_t, const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferWriteMultiD)(COIBUFFER, const COIPROCESS,
|
||||
uint64_t, void *, void *,
|
||||
COI_COPY_TYPE, uint32_t, const COIEVENT*, COIEVENT*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*BufferCopy)(COIBUFFER, COIBUFFER, uint64_t, uint64_t,
|
||||
uint64_t, COI_COPY_TYPE, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferGetSinkAddress)(COIBUFFER, uint64_t*);
|
||||
DLL_LOCAL extern COIRESULT (*BufferSetState)(COIBUFFER, COIPROCESS, COI_BUFFER_STATE,
|
||||
COI_BUFFER_MOVE_FLAG, uint32_t,
|
||||
const COIEVENT*, COIEVENT*);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*EventWait)(uint16_t, const COIEVENT*, int32_t,
|
||||
uint8_t, uint32_t*, uint32_t*);
|
||||
|
||||
DLL_LOCAL extern uint64_t (*PerfGetCycleFrequency)(void);
|
||||
|
||||
DLL_LOCAL extern COIRESULT (*ProcessConfigureDMA)(const uint64_t, const int);
|
||||
|
||||
extern COIRESULT (*PipelineClearCPUMask)(COI_CPU_MASK);
|
||||
|
||||
extern COIRESULT (*PipelineSetCPUMask)(COIPROCESS, uint32_t,
|
||||
uint8_t, COI_CPU_MASK);
|
||||
extern COIRESULT (*EngineGetInfo)(COIENGINE, uint32_t, COI_ENGINE_INFO*);
|
||||
|
||||
extern COIRESULT (*EventRegisterCallback)(
|
||||
const COIEVENT,
|
||||
void (*)(COIEVENT, const COIRESULT, const void*),
|
||||
const void*,
|
||||
const uint64_t);
|
||||
|
||||
const int DMA_MODE_READ_WRITE = 1;
|
||||
} // namespace COI
|
||||
|
||||
#endif // COI_CLIENT_H_INCLUDED
|
|
@ -1,180 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// The COI interface on the target
|
||||
|
||||
#include "coi_server.h"
|
||||
|
||||
#include "../offload_target.h"
|
||||
#include "../offload_timer.h"
|
||||
#ifdef MYO_SUPPORT
|
||||
#include "../offload_myo_target.h" // for __offload_myoLibInit/Fini
|
||||
#endif // MYO_SUPPORT
|
||||
|
||||
#if !defined(CPU_COUNT)
|
||||
// if CPU_COUNT is not defined count number of CPUs manually
|
||||
static
|
||||
int my_cpu_count(cpu_set_t const *cpu_set)
|
||||
{
|
||||
int res = 0;
|
||||
for (int i = 0; i < sizeof(cpu_set_t) / sizeof(__cpu_mask); ++i) {
|
||||
res += __builtin_popcountl(cpu_set->__bits[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Map CPU_COUNT to our function
|
||||
#define CPU_COUNT(x) my_cpu_count(x)
|
||||
|
||||
#endif
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_compute(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
OffloadDescriptor::offload(buffer_count, buffers,
|
||||
misc_data, misc_data_len,
|
||||
return_data, return_data_len);
|
||||
}
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_init(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
struct init_data {
|
||||
int device_index;
|
||||
int devices_total;
|
||||
int console_level;
|
||||
int offload_report_level;
|
||||
} *data = (struct init_data*) misc_data;
|
||||
|
||||
// set device index and number of total devices
|
||||
mic_index = data->device_index;
|
||||
mic_engines_total = data->devices_total;
|
||||
|
||||
// initialize trace level
|
||||
console_enabled = data->console_level;
|
||||
offload_report_level = data->offload_report_level;
|
||||
|
||||
// return back the process id
|
||||
*((pid_t*) return_data) = getpid();
|
||||
}
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_var_table_size(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
struct Params {
|
||||
int64_t nelems;
|
||||
int64_t length;
|
||||
} *params;
|
||||
|
||||
params = static_cast<Params*>(return_data);
|
||||
params->length = __offload_vars.table_size(params->nelems);
|
||||
}
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_var_table_copy(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
__offload_vars.table_copy(buffers[0], *static_cast<int64_t*>(misc_data));
|
||||
}
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_set_stream_affinity(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
/* kmp affinity is not supported by GCC. */
|
||||
}
|
||||
|
||||
#ifdef MYO_SUPPORT
|
||||
// temporary workaround for blocking behavior of myoiLibInit/Fini calls
|
||||
COINATIVELIBEXPORT
|
||||
void server_myoinit(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
__offload_myoLibInit();
|
||||
}
|
||||
|
||||
COINATIVELIBEXPORT
|
||||
void server_myofini(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
uint64_t* buffers_len,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
__offload_myoLibFini();
|
||||
}
|
||||
#endif // MYO_SUPPORT
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// The interface between offload library and the COI API on the target
|
||||
|
||||
#ifndef COI_SERVER_H_INCLUDED
|
||||
#define COI_SERVER_H_INCLUDED
|
||||
|
||||
#include <common/COIEngine_common.h>
|
||||
#include <common/COIPerf_common.h>
|
||||
#include <sink/COIProcess_sink.h>
|
||||
#include <sink/COIPipeline_sink.h>
|
||||
#include <sink/COIBuffer_sink.h>
|
||||
#include <list>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../liboffload_error_codes.h"
|
||||
|
||||
// wrappers for COI API
|
||||
#define PipelineStartExecutingRunFunctions() \
|
||||
{ \
|
||||
COIRESULT res = COIPipelineStartExecutingRunFunctions(); \
|
||||
if (res != COI_SUCCESS) { \
|
||||
LIBOFFLOAD_ERROR(c_pipeline_start_run_funcs, mic_index, res); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ProcessWaitForShutdown() \
|
||||
{ \
|
||||
COIRESULT res = COIProcessWaitForShutdown(); \
|
||||
if (res != COI_SUCCESS) { \
|
||||
LIBOFFLOAD_ERROR(c_process_wait_shutdown, mic_index, res); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BufferAddRef(buf) \
|
||||
{ \
|
||||
COIRESULT res = COIBufferAddRef(buf); \
|
||||
if (res != COI_SUCCESS) { \
|
||||
LIBOFFLOAD_ERROR(c_buf_add_ref, mic_index, res); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BufferReleaseRef(buf) \
|
||||
{ \
|
||||
COIRESULT res = COIBufferReleaseRef(buf); \
|
||||
if (res != COI_SUCCESS) { \
|
||||
LIBOFFLOAD_ERROR(c_buf_release_ref, mic_index, res); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EngineGetIndex(index) \
|
||||
{ \
|
||||
COI_ISA_TYPE isa_type; \
|
||||
COIRESULT res = COIEngineGetIndex(&isa_type, index); \
|
||||
if (res != COI_SUCCESS) { \
|
||||
LIBOFFLOAD_ERROR(c_get_engine_index, mic_index, res); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // COI_SERVER_H_INCLUDED
|
|
@ -1,501 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "compiler_if_host.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#ifndef TARGET_WINNT
|
||||
#include <alloca.h>
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
// Global counter on host.
|
||||
// This variable is used if P2OPT_offload_do_data_persistence == 2.
|
||||
// The variable used to identify offload constructs contained in one procedure.
|
||||
// Increment of OFFLOAD_CALL_COUNT is inserted at entries of HOST routines with
|
||||
// offload constructs.
|
||||
static int offload_call_count = 0;
|
||||
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int is_optional,
|
||||
_Offload_status* status,
|
||||
const char* file,
|
||||
uint64_t line
|
||||
)
|
||||
{
|
||||
bool retval;
|
||||
OFFLOAD ofld;
|
||||
|
||||
// initialize status
|
||||
if (status != 0) {
|
||||
status->result = OFFLOAD_UNAVAILABLE;
|
||||
status->device_number = -1;
|
||||
status->data_sent = 0;
|
||||
status->data_received = 0;
|
||||
}
|
||||
|
||||
// make sure libray is initialized
|
||||
retval = __offload_init_library();
|
||||
|
||||
// OFFLOAD_TIMER_INIT must follow call to __offload_init_library
|
||||
OffloadHostTimerData * timer_data = OFFLOAD_TIMER_INIT(file, line);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_total_offload);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
|
||||
// initialize all devices is init_type is on_offload_all
|
||||
if (retval && __offload_init_type == c_init_on_offload_all) {
|
||||
for (int i = 0; i < mic_engines_total; i++) {
|
||||
mic_engines[i].init();
|
||||
}
|
||||
}
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_target_acquire);
|
||||
|
||||
if (target_type == TARGET_HOST) {
|
||||
// Host always available
|
||||
retval = true;
|
||||
}
|
||||
else if (target_type == TARGET_MIC) {
|
||||
if (target_number >= -1) {
|
||||
if (retval) {
|
||||
if (target_number >= 0) {
|
||||
// User provided the device number
|
||||
target_number = target_number % mic_engines_total;
|
||||
}
|
||||
else {
|
||||
// use device 0
|
||||
target_number = 0;
|
||||
}
|
||||
|
||||
// reserve device in ORSL
|
||||
if (is_optional) {
|
||||
if (!ORSL::try_reserve(target_number)) {
|
||||
target_number = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!ORSL::reserve(target_number)) {
|
||||
target_number = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// initialize device
|
||||
if (target_number >= 0 &&
|
||||
__offload_init_type == c_init_on_offload) {
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
mic_engines[target_number].init();
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// fallback to CPU
|
||||
target_number = -1;
|
||||
}
|
||||
|
||||
if (target_number < 0 || !retval) {
|
||||
if (!is_optional && status == 0) {
|
||||
LIBOFFLOAD_ERROR(c_device_is_not_available);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LIBOFFLOAD_ERROR(c_invalid_device_number);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (retval) {
|
||||
ofld = new OffloadDescriptor(target_number, status,
|
||||
!is_optional, false, timer_data);
|
||||
OFFLOAD_TIMER_HOST_MIC_NUM(timer_data, target_number);
|
||||
Offload_Report_Prolog(timer_data);
|
||||
OFFLOAD_DEBUG_TRACE_1(2, timer_data->offload_number, c_offload_start,
|
||||
"Starting offload: target_type = %d, "
|
||||
"number = %d, is_optional = %d\n",
|
||||
target_type, target_number, is_optional);
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_target_acquire);
|
||||
}
|
||||
else {
|
||||
ofld = NULL;
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_target_acquire);
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_total_offload);
|
||||
offload_report_free_data(timer_data);
|
||||
}
|
||||
|
||||
return ofld;
|
||||
}
|
||||
|
||||
// This routine is called for OpenMP4.5 offload calls
|
||||
// OpenMP 4.5 offload is always optional.
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
|
||||
const int* device_num,
|
||||
const char* file,
|
||||
uint64_t line
|
||||
)
|
||||
{
|
||||
int target_number;
|
||||
|
||||
// make sure libray is initialized and at least one device is available
|
||||
if (!__offload_init_library()) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "No device available, fall back to host\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// OFFLOAD_TIMER_INIT must follow call to __offload_init_library
|
||||
|
||||
OffloadHostTimerData * timer_data = OFFLOAD_TIMER_INIT(file, line);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_total_offload);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
|
||||
if (__offload_init_type == c_init_on_offload_all) {
|
||||
for (int i = 0; i < mic_engines_total; i++) {
|
||||
mic_engines[i].init();
|
||||
}
|
||||
}
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_target_acquire);
|
||||
|
||||
// use default device number if it is not provided
|
||||
if (device_num != 0) {
|
||||
target_number = *device_num;
|
||||
}
|
||||
else {
|
||||
target_number = __omp_device_num;
|
||||
}
|
||||
|
||||
// device number should be a non-negative integer value
|
||||
if (target_number < 0) {
|
||||
LIBOFFLOAD_ERROR(c_omp_invalid_device_num);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// should we do this for OpenMP?
|
||||
target_number %= mic_engines_total;
|
||||
|
||||
// reserve device in ORSL
|
||||
if (!ORSL::reserve(target_number)) {
|
||||
LIBOFFLOAD_ERROR(c_device_is_not_available);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// initialize device(s)
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
|
||||
if (__offload_init_type == c_init_on_offload) {
|
||||
mic_engines[target_number].init();
|
||||
}
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
|
||||
OFFLOAD ofld =
|
||||
new OffloadDescriptor(target_number, 0, true, true, timer_data);
|
||||
|
||||
OFFLOAD_TIMER_HOST_MIC_NUM(timer_data, target_number);
|
||||
|
||||
Offload_Report_Prolog(timer_data);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE_1(2, timer_data->offload_number, c_offload_start,
|
||||
"Starting OpenMP offload, device = %d\n",
|
||||
target_number);
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_target_acquire);
|
||||
|
||||
return ofld;
|
||||
}
|
||||
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE2(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int is_optional,
|
||||
_Offload_status* status,
|
||||
const char* file,
|
||||
uint64_t line,
|
||||
const void** stream
|
||||
)
|
||||
{
|
||||
bool retval;
|
||||
OFFLOAD ofld;
|
||||
|
||||
// initialize status
|
||||
if (status != 0) {
|
||||
status->result = OFFLOAD_UNAVAILABLE;
|
||||
status->device_number = -1;
|
||||
status->data_sent = 0;
|
||||
status->data_received = 0;
|
||||
}
|
||||
|
||||
// make sure libray is initialized
|
||||
retval = __offload_init_library();
|
||||
// OFFLOAD_TIMER_INIT must follow call to __offload_init_library
|
||||
OffloadHostTimerData * timer_data = OFFLOAD_TIMER_INIT(file, line);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_total_offload);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
|
||||
// initalize all devices if init_type is on_offload_all
|
||||
if (retval && __offload_init_type == c_init_on_offload_all) {
|
||||
for (int i = 0; i < mic_engines_total; i++) {
|
||||
mic_engines[i].init();
|
||||
}
|
||||
}
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_target_acquire);
|
||||
|
||||
if (target_type == TARGET_HOST) {
|
||||
// Host always available
|
||||
retval = true;
|
||||
}
|
||||
else if (target_type == TARGET_MIC) {
|
||||
_Offload_stream handle = *(reinterpret_cast<_Offload_stream*>(stream));
|
||||
Stream * stream = handle ? Stream::find_stream(handle, false) : NULL;
|
||||
if (target_number >= -1) {
|
||||
if (retval) {
|
||||
// device number is defined by stream
|
||||
if (stream) {
|
||||
target_number = stream->get_device();
|
||||
target_number = target_number % mic_engines_total;
|
||||
}
|
||||
|
||||
// reserve device in ORSL
|
||||
if (target_number != -1) {
|
||||
if (is_optional) {
|
||||
if (!ORSL::try_reserve(target_number)) {
|
||||
target_number = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!ORSL::reserve(target_number)) {
|
||||
target_number = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize device
|
||||
if (target_number >= 0 &&
|
||||
__offload_init_type == c_init_on_offload) {
|
||||
OFFLOAD_TIMER_START(timer_data, c_offload_host_initialize);
|
||||
mic_engines[target_number].init();
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_initialize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// fallback to CPU
|
||||
target_number = -1;
|
||||
}
|
||||
if (!(target_number == -1 && handle == 0)) {
|
||||
if (target_number < 0 || !retval) {
|
||||
if (!is_optional && status == 0) {
|
||||
LIBOFFLOAD_ERROR(c_device_is_not_available);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
LIBOFFLOAD_ERROR(c_invalid_device_number);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (retval) {
|
||||
ofld = new OffloadDescriptor(target_number, status,
|
||||
!is_optional, false, timer_data);
|
||||
OFFLOAD_TIMER_HOST_MIC_NUM(timer_data, target_number);
|
||||
Offload_Report_Prolog(timer_data);
|
||||
OFFLOAD_DEBUG_TRACE_1(2, timer_data->offload_number, c_offload_start,
|
||||
"Starting offload: target_type = %d, "
|
||||
"number = %d, is_optional = %d\n",
|
||||
target_type, target_number, is_optional);
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_target_acquire);
|
||||
}
|
||||
else {
|
||||
ofld = NULL;
|
||||
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_target_acquire);
|
||||
OFFLOAD_TIMER_STOP(timer_data, c_offload_host_total_offload);
|
||||
offload_report_free_data(timer_data);
|
||||
}
|
||||
|
||||
return ofld;
|
||||
}
|
||||
|
||||
static int offload_offload_wrap(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void **waits,
|
||||
const void **signal,
|
||||
int entry_id,
|
||||
const void *stack_addr,
|
||||
OffloadFlags offload_flags
|
||||
)
|
||||
{
|
||||
if (signal) {
|
||||
ofld->set_signal(*signal);
|
||||
}
|
||||
|
||||
bool ret = ofld->offload(name, is_empty, vars, vars2, num_vars,
|
||||
waits, num_waits, signal, entry_id,
|
||||
stack_addr, offload_flags);
|
||||
if (!ret || (signal == 0 && ofld->get_stream() == 0 &&
|
||||
!offload_flags.bits.omp_async)) {
|
||||
delete ofld;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" int OFFLOAD_OFFLOAD1(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void **waits,
|
||||
const void **signal
|
||||
)
|
||||
{
|
||||
return offload_offload_wrap(ofld, name, is_empty,
|
||||
num_vars, vars, vars2,
|
||||
num_waits, waits,
|
||||
signal, 0, NULL, {0});
|
||||
}
|
||||
|
||||
extern "C" int OFFLOAD_OFFLOAD2(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void** signal,
|
||||
int entry_id,
|
||||
const void *stack_addr
|
||||
)
|
||||
{
|
||||
return offload_offload_wrap(ofld, name, is_empty,
|
||||
num_vars, vars, vars2,
|
||||
num_waits, waits,
|
||||
signal, entry_id, stack_addr, {0});
|
||||
}
|
||||
|
||||
extern "C" int OFFLOAD_OFFLOAD3(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void** signal,
|
||||
int entry_id,
|
||||
const void *stack_addr,
|
||||
OffloadFlags offload_flags,
|
||||
const void** stream
|
||||
)
|
||||
{
|
||||
// 1. if the source is compiled with -traceback then stream is 0
|
||||
// 2. if offload has a stream clause then stream is address of stream value
|
||||
if (stream) {
|
||||
ofld->set_stream(*(reinterpret_cast<_Offload_stream *>(stream)));
|
||||
}
|
||||
|
||||
return offload_offload_wrap(ofld, name, is_empty,
|
||||
num_vars, vars, vars2,
|
||||
num_waits, waits,
|
||||
signal, entry_id, stack_addr, offload_flags);
|
||||
}
|
||||
|
||||
extern "C" int OFFLOAD_OFFLOAD(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void **waits,
|
||||
const void *signal,
|
||||
int entry_id,
|
||||
const void *stack_addr
|
||||
)
|
||||
{
|
||||
// signal is passed by reference now
|
||||
const void **signal_new = (signal != 0) ? &signal : 0;
|
||||
const void **waits_new = 0;
|
||||
int num_waits_new = 0;
|
||||
|
||||
// remove NULL values from the list of signals to wait for
|
||||
if (num_waits > 0) {
|
||||
waits_new = (const void**) alloca(sizeof(void*) * num_waits);
|
||||
for (int i = 0; i < num_waits; i++) {
|
||||
if (waits[i] != 0) {
|
||||
waits_new[num_waits_new++] = waits[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OFFLOAD_OFFLOAD1(ofld, name, is_empty,
|
||||
num_vars, vars, vars2,
|
||||
num_waits_new, waits_new,
|
||||
signal_new);
|
||||
}
|
||||
|
||||
extern "C" int OFFLOAD_CALL_COUNT()
|
||||
{
|
||||
offload_call_count++;
|
||||
return offload_call_count;
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief The interface between compiler-generated host code and runtime library
|
||||
*/
|
||||
|
||||
#ifndef COMPILER_IF_HOST_H_INCLUDED
|
||||
#define COMPILER_IF_HOST_H_INCLUDED
|
||||
|
||||
#include "offload_host.h"
|
||||
|
||||
#define OFFLOAD_TARGET_ACQUIRE OFFLOAD_PREFIX(target_acquire)
|
||||
#define OFFLOAD_TARGET_ACQUIRE1 OFFLOAD_PREFIX(target_acquire1)
|
||||
#define OFFLOAD_TARGET_ACQUIRE2 OFFLOAD_PREFIX(target_acquire2)
|
||||
#define OFFLOAD_OFFLOAD OFFLOAD_PREFIX(offload)
|
||||
#define OFFLOAD_OFFLOAD1 OFFLOAD_PREFIX(offload1)
|
||||
#define OFFLOAD_OFFLOAD2 OFFLOAD_PREFIX(offload2)
|
||||
#define OFFLOAD_OFFLOAD3 OFFLOAD_PREFIX(offload3)
|
||||
#define OFFLOAD_CALL_COUNT OFFLOAD_PREFIX(offload_call_count)
|
||||
|
||||
|
||||
/*! \fn OFFLOAD_TARGET_ACQUIRE
|
||||
\brief Attempt to acquire the target.
|
||||
\param target_type The type of target.
|
||||
\param target_number The device number.
|
||||
\param is_optional Whether CPU fall-back is allowed.
|
||||
\param status Address of variable to hold offload status.
|
||||
\param file Filename in which this offload occurred.
|
||||
\param line Line number in the file where this offload occurred.
|
||||
*/
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int is_optional,
|
||||
_Offload_status* status,
|
||||
const char* file,
|
||||
uint64_t line
|
||||
);
|
||||
|
||||
/*! \fn OFFLOAD_TARGET_ACQUIRE1
|
||||
\brief Acquire the target for offload (OpenMP).
|
||||
\param device_number Device number or null if not specified.
|
||||
\param file Filename in which this offload occurred
|
||||
\param line Line number in the file where this offload occurred.
|
||||
*/
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
|
||||
const int* device_number,
|
||||
const char* file,
|
||||
uint64_t line
|
||||
);
|
||||
|
||||
/*! \fn OFFLOAD_TARGET_ACQUIRE2
|
||||
\brief Attempt to acquire the target.
|
||||
\param target_type The type of target.
|
||||
\param target_number The device number.
|
||||
\param is_optional Whether CPU fall-back is allowed.
|
||||
\param status Address of variable to hold offload status.
|
||||
\param file Filename in which this offload occurred.
|
||||
\param line Line number in the file where this offload occurred.
|
||||
\param stream Pointer to stream value.
|
||||
*/
|
||||
extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE2(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int is_optional,
|
||||
_Offload_status* status,
|
||||
const char* file,
|
||||
uint64_t line,
|
||||
const void** stream
|
||||
);
|
||||
|
||||
/*! \fn OFFLOAD_OFFLOAD1
|
||||
\brief Run function on target using interface for old data persistence.
|
||||
\param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
|
||||
\param name Name of offload entry point.
|
||||
\param is_empty If no code to execute (e.g. offload_transfer)
|
||||
\param num_vars Number of variable descriptors.
|
||||
\param vars Pointer to VarDesc array.
|
||||
\param vars2 Pointer to VarDesc2 array.
|
||||
\param num_waits Number of "wait" values.
|
||||
\param waits Pointer to array of wait values.
|
||||
\param signal Pointer to signal value or NULL.
|
||||
*/
|
||||
extern "C" int OFFLOAD_OFFLOAD1(
|
||||
OFFLOAD o,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void** signal
|
||||
);
|
||||
|
||||
/*! \fn OFFLOAD_OFFLOAD2
|
||||
\brief Run function on target using interface for new data persistence.
|
||||
\param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
|
||||
\param name Name of offload entry point.
|
||||
\param is_empty If no code to execute (e.g. offload_transfer)
|
||||
\param num_vars Number of variable descriptors.
|
||||
\param vars Pointer to VarDesc array.
|
||||
\param vars2 Pointer to VarDesc2 array.
|
||||
\param num_waits Number of "wait" values.
|
||||
\param waits Pointer to array of wait values.
|
||||
\param signal Pointer to signal value or NULL.
|
||||
\param entry_id A signature for the function doing the offload.
|
||||
\param stack_addr The stack frame address of the function doing offload.
|
||||
*/
|
||||
extern "C" int OFFLOAD_OFFLOAD2(
|
||||
OFFLOAD o,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void** signal,
|
||||
int entry_id,
|
||||
const void *stack_addr
|
||||
);
|
||||
|
||||
|
||||
/*! \fn OFFLOAD_OFFLOAD3
|
||||
\brief Run function on target, API introduced in 15.0 Update 1
|
||||
\brief when targetptr, preallocated feature was introduced.
|
||||
\param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
|
||||
\param name Name of offload entry point.
|
||||
\param is_empty If no code to execute (e.g. offload_transfer)
|
||||
\param num_vars Number of variable descriptors.
|
||||
\param vars Pointer to VarDesc array.
|
||||
\param vars2 Pointer to VarDesc2 array.
|
||||
\param num_waits Number of "wait" values.
|
||||
\param waits Pointer to array of wait values.
|
||||
\param signal Pointer to signal value or NULL.
|
||||
\param entry_id A signature for the function doing the offload.
|
||||
\param stack_addr The stack frame address of the function doing offload.
|
||||
\param offload_flags Flags to indicate Fortran traceback, OpenMP async.
|
||||
\param stream Pointer to stream value or NULL.
|
||||
*/
|
||||
extern "C" int OFFLOAD_OFFLOAD3(
|
||||
OFFLOAD ofld,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void** signal,
|
||||
int entry_id,
|
||||
const void *stack_addr,
|
||||
OffloadFlags offload_flags,
|
||||
const void** stream
|
||||
);
|
||||
|
||||
// Run function on target (obsolete).
|
||||
// @param o OFFLOAD object
|
||||
// @param name function name
|
||||
extern "C" int OFFLOAD_OFFLOAD(
|
||||
OFFLOAD o,
|
||||
const char *name,
|
||||
int is_empty,
|
||||
int num_vars,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int num_waits,
|
||||
const void** waits,
|
||||
const void* signal,
|
||||
int entry_id = 0,
|
||||
const void *stack_addr = NULL
|
||||
);
|
||||
|
||||
// Global counter on host.
|
||||
// This variable is used if P2OPT_offload_do_data_persistence == 2.
|
||||
// The variable used to identify offload constructs contained in one procedure.
|
||||
// Call to OFFLOAD_CALL_COUNT() is inserted at HOST on entry of the routine.
|
||||
extern "C" int OFFLOAD_CALL_COUNT();
|
||||
|
||||
#endif // COMPILER_IF_HOST_H_INCLUDED
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "compiler_if_target.h"
|
||||
|
||||
extern "C" void OFFLOAD_TARGET_ENTER(
|
||||
OFFLOAD ofld,
|
||||
int vars_total,
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "%s(%p, %d, %p, %p)\n", __func__, ofld,
|
||||
vars_total, vars, vars2);
|
||||
ofld->merge_var_descs(vars, vars2, vars_total);
|
||||
ofld->scatter_copyin_data();
|
||||
}
|
||||
|
||||
extern "C" void OFFLOAD_TARGET_LEAVE(
|
||||
OFFLOAD ofld
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, ofld);
|
||||
ofld->gather_copyout_data();
|
||||
}
|
||||
|
||||
extern "C" void OFFLOAD_TARGET_MAIN(void)
|
||||
{
|
||||
// initialize target part
|
||||
__offload_target_init();
|
||||
|
||||
// pass control to COI
|
||||
PipelineStartExecutingRunFunctions();
|
||||
ProcessWaitForShutdown();
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Exiting main...\n");
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief The interface between compiler-generated target code and runtime library
|
||||
*/
|
||||
|
||||
#ifndef COMPILER_IF_TARGET_H_INCLUDED
|
||||
#define COMPILER_IF_TARGET_H_INCLUDED
|
||||
|
||||
#include "offload_target.h"
|
||||
|
||||
#define OFFLOAD_TARGET_ENTER OFFLOAD_PREFIX(target_enter)
|
||||
#define OFFLOAD_TARGET_LEAVE OFFLOAD_PREFIX(target_leave)
|
||||
#define OFFLOAD_TARGET_MAIN OFFLOAD_PREFIX(target_main)
|
||||
|
||||
/*! \fn OFFLOAD_TARGET_ENTER
|
||||
\brief Fill in variable addresses using VarDesc array.
|
||||
\brief Then call back the runtime library to fetch data.
|
||||
\param ofld Offload descriptor created by runtime.
|
||||
\param var_desc_num Number of variable descriptors.
|
||||
\param var_desc Pointer to VarDesc array.
|
||||
\param var_desc2 Pointer to VarDesc2 array.
|
||||
*/
|
||||
extern "C" void OFFLOAD_TARGET_ENTER(
|
||||
OFFLOAD ofld,
|
||||
int var_desc_num,
|
||||
VarDesc *var_desc,
|
||||
VarDesc2 *var_desc2
|
||||
);
|
||||
|
||||
/*! \fn OFFLOAD_TARGET_LEAVE
|
||||
\brief Call back the runtime library to gather outputs using VarDesc array.
|
||||
\param ofld Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
|
||||
*/
|
||||
extern "C" void OFFLOAD_TARGET_LEAVE(
|
||||
OFFLOAD ofld
|
||||
);
|
||||
|
||||
// Entry point for the target application.
|
||||
extern "C" void OFFLOAD_TARGET_MAIN(void);
|
||||
|
||||
#endif // COMPILER_IF_TARGET_H_INCLUDED
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_common.h"
|
||||
|
||||
bool __dv_is_contiguous(const ArrDesc *dvp)
|
||||
{
|
||||
if (dvp->Flags & ArrDescFlagsContiguous) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dvp->Rank != 0) {
|
||||
if (dvp->Dim[0].Mult != dvp->Len) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 1; i < dvp->Rank; i++) {
|
||||
if (dvp->Dim[i].Mult !=
|
||||
dvp->Dim[i-1].Extent * dvp->Dim[i-1].Mult) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __dv_is_allocated(const ArrDesc *dvp)
|
||||
{
|
||||
return (dvp->Flags & ArrDescFlagsDefined);
|
||||
}
|
||||
|
||||
uint64_t __dv_data_length(const ArrDesc *dvp)
|
||||
{
|
||||
uint64_t size;
|
||||
|
||||
if (dvp->Rank == 0) {
|
||||
size = dvp->Len;
|
||||
return size;
|
||||
}
|
||||
|
||||
size = dvp->Len;
|
||||
for (int i = 0; i < dvp->Rank; ++i) {
|
||||
size += (dvp->Dim[i].Extent-1) * dvp->Dim[i].Mult;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
uint64_t __dv_data_length(const ArrDesc *dvp, int64_t count)
|
||||
{
|
||||
if (dvp->Rank == 0) {
|
||||
return count;
|
||||
}
|
||||
|
||||
return count * dvp->Dim[0].Mult;
|
||||
}
|
||||
|
||||
// Create CeanReadRanges data for reading contiguous ranges of
|
||||
// noncontiguous array defined by the argument
|
||||
CeanReadRanges * init_read_ranges_dv(const ArrDesc *dvp)
|
||||
{
|
||||
int64_t len;
|
||||
int count;
|
||||
int rank = dvp->Rank;
|
||||
CeanReadRanges *res = NULL;
|
||||
|
||||
if (rank != 0) {
|
||||
int i = 0;
|
||||
len = dvp->Len;
|
||||
if (dvp->Dim[0].Mult == len) {
|
||||
for (i = 1; i < rank; i++) {
|
||||
len *= dvp->Dim[i-1].Extent;
|
||||
if (dvp->Dim[i].Mult != len) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
res = (CeanReadRanges *)malloc(
|
||||
sizeof(CeanReadRanges) + (rank - i) * sizeof(CeanReadDim));
|
||||
if (res == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
res -> last_noncont_ind = rank - i - 1;
|
||||
count = 1;
|
||||
for (; i < rank; i++) {
|
||||
res->Dim[rank - i - 1].count = count;
|
||||
res->Dim[rank - i - 1].size = dvp->Dim[i].Mult;
|
||||
count *= dvp->Dim[i].Extent;
|
||||
}
|
||||
res -> range_max_number = count;
|
||||
res -> range_size = len;
|
||||
res -> ptr = (void*)dvp->Base;
|
||||
res -> current_number = 0;
|
||||
res -> init_offset = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
void __dv_desc_dump(const char *name, const ArrDesc *dvp)
|
||||
{
|
||||
OFFLOAD_TRACE(3, "%s DV %p\n", name, dvp);
|
||||
|
||||
if (dvp != 0) {
|
||||
OFFLOAD_TRACE(3,
|
||||
" dv->Base = 0x%lx\n"
|
||||
" dv->Len = 0x%lx\n"
|
||||
" dv->Offset = 0x%lx\n"
|
||||
" dv->Flags = 0x%lx\n"
|
||||
" dv->Rank = 0x%lx\n"
|
||||
" dv->Resrvd = 0x%lx\n",
|
||||
dvp->Base,
|
||||
dvp->Len,
|
||||
dvp->Offset,
|
||||
dvp->Flags,
|
||||
dvp->Rank,
|
||||
dvp->Reserved);
|
||||
|
||||
for (int i = 0 ; i < dvp->Rank; i++) {
|
||||
OFFLOAD_TRACE(3,
|
||||
" (%d) Extent=%ld, Multiplier=%ld, LowerBound=%ld\n",
|
||||
i,
|
||||
dvp->Dim[i].Extent,
|
||||
dvp->Dim[i].Mult,
|
||||
dvp->Dim[i].LowerBound);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // OFFLOAD_DEBUG > 0
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DV_UTIL_H_INCLUDED
|
||||
#define DV_UTIL_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include "offload_util.h"
|
||||
|
||||
// Dope vector declarations
|
||||
#define ArrDescMaxArrayRank 31
|
||||
|
||||
// Dope vector flags
|
||||
#define ArrDescFlagsDefined 1
|
||||
#define ArrDescFlagsNodealloc 2
|
||||
#define ArrDescFlagsContiguous 4
|
||||
|
||||
typedef int64_t dv_size;
|
||||
|
||||
typedef struct DimDesc {
|
||||
dv_size Extent; // Number of elements in this dimension
|
||||
dv_size Mult; // Multiplier for this dimension.
|
||||
// The number of bytes between successive
|
||||
// elements in this dimension.
|
||||
dv_size LowerBound; // LowerBound of this dimension
|
||||
} DimDesc ;
|
||||
|
||||
typedef struct ArrDesc {
|
||||
dv_size Base; // Base address
|
||||
dv_size Len; // Length of data type, used only for
|
||||
// character strings.
|
||||
dv_size Offset;
|
||||
dv_size Flags; // Flags
|
||||
dv_size Rank; // Rank of pointer
|
||||
dv_size Reserved; // reserved for openmp requests
|
||||
DimDesc Dim[ArrDescMaxArrayRank];
|
||||
} ArrDesc ;
|
||||
|
||||
typedef ArrDesc* pArrDesc;
|
||||
|
||||
DLL_LOCAL bool __dv_is_contiguous(const ArrDesc *dvp);
|
||||
|
||||
DLL_LOCAL bool __dv_is_allocated(const ArrDesc *dvp);
|
||||
|
||||
DLL_LOCAL uint64_t __dv_data_length(const ArrDesc *dvp);
|
||||
|
||||
DLL_LOCAL uint64_t __dv_data_length(const ArrDesc *dvp, int64_t nelems);
|
||||
|
||||
DLL_LOCAL CeanReadRanges * init_read_ranges_dv(const ArrDesc *dvp);
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
DLL_LOCAL void __dv_desc_dump(const char *name, const ArrDesc *dvp);
|
||||
#else // OFFLOAD_DEBUG
|
||||
#define __dv_desc_dump(name, dvp)
|
||||
#endif // OFFLOAD_DEBUG
|
||||
|
||||
#endif // DV_UTIL_H_INCLUDED
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef COI_COMMON_H_INCLUDED
|
||||
#define COI_COMMON_H_INCLUDED
|
||||
|
||||
#include <common/COIMacros_common.h>
|
||||
#include <common/COIPerf_common.h>
|
||||
#include <source/COIEngine_source.h>
|
||||
#include <source/COIProcess_source.h>
|
||||
#include <source/COIPipeline_source.h>
|
||||
#include <source/COIBuffer_source.h>
|
||||
#include <source/COIEvent_source.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* Environment variable for path to 'target' files. */
|
||||
#define MIC_DIR_ENV "OFFLOAD_MIC_DIR"
|
||||
|
||||
/* Environment variable for engine index. */
|
||||
#define MIC_INDEX_ENV "OFFLOAD_MIC_INDEX"
|
||||
|
||||
/* Environment variable for target executable run command. */
|
||||
#define OFFLOAD_EMUL_RUN_ENV "OFFLOAD_EMUL_RUN"
|
||||
|
||||
/* Environment variable for number of emulated devices. */
|
||||
#define OFFLOAD_EMUL_NUM_ENV "OFFLOAD_EMUL_NUM"
|
||||
|
||||
|
||||
/* Path to engine directory. */
|
||||
#define ENGINE_PATH "/tmp/offload_XXXXXX"
|
||||
|
||||
/* Relative path to directory with pipes. */
|
||||
#define PIPES_PATH "/pipes"
|
||||
|
||||
/* Non-numerical part of host-to-target pipe file name. */
|
||||
#define PIPE_HOST2TGT_NAME PIPES_PATH "/host2tgt_"
|
||||
|
||||
/* Non-numerical part of target-to-host pipe file name. */
|
||||
#define PIPE_TGT2HOST_NAME PIPES_PATH "/tgt2host_"
|
||||
|
||||
/* Non-numerical part of shared memory file name. */
|
||||
#define SHM_NAME "/offload_shm_"
|
||||
|
||||
|
||||
/* Use secure getenv if it's supported. */
|
||||
#ifdef HAVE_SECURE_GETENV
|
||||
#define getenv(x) secure_getenv(x)
|
||||
#elif HAVE___SECURE_GETENV
|
||||
#define getenv(x) __secure_getenv(x)
|
||||
#endif
|
||||
|
||||
|
||||
/* Wrapper for malloc. */
|
||||
#define MALLOC(type, ptr, size) \
|
||||
{ \
|
||||
type p = (type) malloc (size); \
|
||||
if (p == NULL) \
|
||||
COIERROR ("Cannot allocate memory."); \
|
||||
ptr = p; \
|
||||
}
|
||||
|
||||
/* Like MALLOC, but return NULL instead of COIRESULT. */
|
||||
#define MALLOCN(type, ptr, size) \
|
||||
{ \
|
||||
type p = (type) malloc (size); \
|
||||
if (p == NULL) \
|
||||
COIERRORN ("Cannot allocate memory."); \
|
||||
ptr = p; \
|
||||
}
|
||||
|
||||
/* Wrapper for strdup. */
|
||||
#define STRDUP(ptr, str) \
|
||||
{ \
|
||||
char *p = strdup (str); \
|
||||
if (p == NULL) \
|
||||
COIERROR ("Cannot allocate memory."); \
|
||||
ptr = p; \
|
||||
}
|
||||
|
||||
/* Wrapper for pipe reading. */
|
||||
#define READ(pipe, ptr, size) \
|
||||
{ \
|
||||
int s = (int) size; \
|
||||
if (read (pipe, ptr, s) != s) \
|
||||
COIERROR ("Cannot read from pipe."); \
|
||||
}
|
||||
|
||||
/* Like READ, but return NULL instead of COIRESULT. */
|
||||
#define READN(pipe, ptr, size) \
|
||||
{ \
|
||||
int s = (int) size; \
|
||||
if (read (pipe, ptr, s) != s) \
|
||||
COIERRORN ("Cannot read from pipe."); \
|
||||
}
|
||||
|
||||
/* Wrapper for pipe writing. */
|
||||
#define WRITE(pipe, ptr, size) \
|
||||
{ \
|
||||
int s = (int) size; \
|
||||
if (write (pipe, ptr, s) != s) \
|
||||
COIERROR ("Cannot write in pipe."); \
|
||||
}
|
||||
|
||||
/* Like WRITE, but return NULL instead of COIRESULT. */
|
||||
#define WRITEN(pipe, ptr, size) \
|
||||
{ \
|
||||
int s = (int) size; \
|
||||
if (write (pipe, ptr, s) != s) \
|
||||
COIERRORN ("Cannot write in pipe."); \
|
||||
}
|
||||
|
||||
|
||||
/* Command codes enum. */
|
||||
typedef enum
|
||||
{
|
||||
CMD_BUFFER_COPY,
|
||||
CMD_BUFFER_MAP,
|
||||
CMD_BUFFER_UNMAP,
|
||||
CMD_GET_FUNCTION_HANDLE,
|
||||
CMD_OPEN_LIBRARY,
|
||||
CMD_CLOSE_LIBRARY,
|
||||
CMD_PIPELINE_CREATE,
|
||||
CMD_PIPELINE_DESTROY,
|
||||
CMD_PIPELINE_RUN_FUNCTION,
|
||||
CMD_SHUTDOWN
|
||||
} cmd_t;
|
||||
|
||||
#endif // COI_COMMON_H_INCLUDED
|
|
@ -1,401 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "coi_device.h"
|
||||
|
||||
#include "coi_version_asm.h"
|
||||
|
||||
#define CYCLE_FREQUENCY 1000000000
|
||||
|
||||
|
||||
static uint32_t engine_index;
|
||||
static char *engine_dir;
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
COIRESULT
|
||||
SYMBOL_VERSION (COIBufferAddRef, 1) (void *ptr)
|
||||
{
|
||||
COITRACE ("COIBufferAddRef");
|
||||
|
||||
/* Looks like we have nothing to do here. */
|
||||
|
||||
return COI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
COIRESULT
|
||||
SYMBOL_VERSION (COIBufferReleaseRef, 1) (void *ptr)
|
||||
{
|
||||
COITRACE ("COIBufferReleaseRef");
|
||||
|
||||
/* Looks like we have nothing to do here. */
|
||||
|
||||
return COI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
COIRESULT
|
||||
SYMBOL_VERSION (COIEngineGetIndex, 1) (COI_ISA_TYPE *type,
|
||||
uint32_t *index)
|
||||
{
|
||||
COITRACE ("COIEngineGetIndex");
|
||||
|
||||
/* type is not used in liboffloadmic. */
|
||||
*index = engine_index;
|
||||
|
||||
return COI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
COIRESULT
|
||||
SYMBOL_VERSION (COIPipelineStartExecutingRunFunctions, 1) ()
|
||||
{
|
||||
COITRACE ("COIPipelineStartExecutingRunFunctions");
|
||||
|
||||
/* Looks like we have nothing to do here. */
|
||||
|
||||
return COI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* The start routine for the COI pipeline thread. */
|
||||
|
||||
static void *
|
||||
pipeline_thread_routine (void *in_pipeline_num)
|
||||
{
|
||||
uint32_t pipeline_num = *(uint32_t *) in_pipeline_num;
|
||||
free (in_pipeline_num);
|
||||
|
||||
/* Open pipes. */
|
||||
char *pipe_host2tgt_path, *pipe_tgt2host_path;
|
||||
MALLOCN (char *, pipe_host2tgt_path,
|
||||
strlen (engine_dir) + sizeof (PIPE_HOST2TGT_NAME "0000000000"));
|
||||
MALLOCN (char *, pipe_tgt2host_path,
|
||||
strlen (engine_dir) + sizeof (PIPE_TGT2HOST_NAME "0000000000"));
|
||||
sprintf (pipe_host2tgt_path, "%s" PIPE_HOST2TGT_NAME "%010d", engine_dir,
|
||||
pipeline_num);
|
||||
sprintf (pipe_tgt2host_path, "%s" PIPE_TGT2HOST_NAME "%010d", engine_dir,
|
||||
pipeline_num);
|
||||
int pipe_host2tgt = open (pipe_host2tgt_path, O_CLOEXEC | O_RDONLY);
|
||||
if (pipe_host2tgt < 0)
|
||||
COIERRORN ("Cannot open host-to-target pipe.");
|
||||
int pipe_tgt2host = open (pipe_tgt2host_path, O_CLOEXEC | O_WRONLY);
|
||||
if (pipe_tgt2host < 0)
|
||||
COIERRORN ("Cannot open target-to-host pipe.");
|
||||
|
||||
free (pipe_host2tgt_path);
|
||||
free (pipe_tgt2host_path);
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Read and execute command. */
|
||||
cmd_t cmd = CMD_PIPELINE_DESTROY;
|
||||
int cmd_len = read (pipe_host2tgt, &cmd, sizeof (cmd_t));
|
||||
if (cmd_len != sizeof (cmd_t) && cmd_len != 0)
|
||||
COIERRORN ("Cannot read from pipe.");
|
||||
|
||||
if (cmd == CMD_PIPELINE_DESTROY)
|
||||
break;
|
||||
else if (cmd == CMD_PIPELINE_RUN_FUNCTION)
|
||||
{
|
||||
/* Receive data from host. */
|
||||
void (*func) (uint32_t, void **, uint64_t *, void *, uint16_t, void *,
|
||||
uint16_t);
|
||||
uint32_t buffer_count;
|
||||
READN (pipe_host2tgt, &func, sizeof (void *));
|
||||
READN (pipe_host2tgt, &buffer_count, sizeof (uint32_t));
|
||||
void **buffers;
|
||||
uint64_t *buffers_len;
|
||||
MALLOCN (void **, buffers, buffer_count * sizeof (void *));
|
||||
MALLOCN (uint64_t *, buffers_len, buffer_count * sizeof (uint64_t));
|
||||
for (uint32_t i = 0; i < buffer_count; i++)
|
||||
{
|
||||
READN (pipe_host2tgt, &buffers_len[i], sizeof (uint64_t));
|
||||
READN (pipe_host2tgt, &buffers[i], sizeof (void *));
|
||||
}
|
||||
uint16_t misc_data_len;
|
||||
READN (pipe_host2tgt, &misc_data_len, sizeof (uint16_t));
|
||||
void *misc_data = NULL;
|
||||
if (misc_data_len > 0)
|
||||
{
|
||||
MALLOCN (void *, misc_data, misc_data_len);
|
||||
READN (pipe_host2tgt, misc_data, misc_data_len);
|
||||
}
|
||||
uint16_t return_data_len;
|
||||
READN (pipe_host2tgt, &return_data_len, sizeof (uint16_t));
|
||||
void *return_data;
|
||||
if (return_data_len > 0)
|
||||
MALLOCN (void *, return_data, return_data_len);
|
||||
|
||||
/* Run function. */
|
||||
func (buffer_count, buffers, buffers_len, misc_data,
|
||||
misc_data_len, return_data, return_data_len);
|
||||
|
||||
/* Send data to host if any or just send notification. */
|
||||
WRITEN (pipe_tgt2host, return_data_len > 0 ? return_data : &cmd,
|
||||
return_data_len > 0 ? return_data_len : sizeof (cmd_t));
|
||||
|
||||
/* Clean up. */
|
||||
free (buffers);
|
||||
free (buffers_len);
|
||||
if (misc_data_len > 0)
|
||||
free (misc_data);
|
||||
if (return_data_len > 0)
|
||||
free (return_data);
|
||||
}
|
||||
else
|
||||
COIERRORN ("Unrecognizable command from host.");
|
||||
}
|
||||
|
||||
/* Close pipes. */
|
||||
if (close (pipe_host2tgt) < 0)
|
||||
COIERRORN ("Cannot close host-to-target pipe.");
|
||||
if (close (pipe_tgt2host) < 0)
|
||||
COIERRORN ("Cannot close target-to-host pipe.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
COIRESULT
|
||||
SYMBOL_VERSION (COIProcessWaitForShutdown, 1) ()
|
||||
{
|
||||
COITRACE ("COIProcessWaitForShutdown");
|
||||
|
||||
engine_dir = getenv (MIC_DIR_ENV);
|
||||
char *mic_index = getenv (MIC_INDEX_ENV);
|
||||
assert (engine_dir != NULL && mic_index != NULL);
|
||||
|
||||
/* Get engine index. */
|
||||
engine_index = atoi (mic_index);
|
||||
|
||||
/* Open main pipes. */
|
||||
char *pipe_host2tgt_path, *pipe_tgt2host_path;
|
||||
MALLOC (char *, pipe_host2tgt_path,
|
||||
strlen (engine_dir) + sizeof (PIPE_HOST2TGT_NAME "mainpipe"));
|
||||
MALLOC (char *, pipe_tgt2host_path,
|
||||
strlen (engine_dir) + sizeof (PIPE_TGT2HOST_NAME "mainpipe"));
|
||||
sprintf (pipe_host2tgt_path, "%s" PIPE_HOST2TGT_NAME "mainpipe", engine_dir);
|
||||
sprintf (pipe_tgt2host_path, "%s" PIPE_TGT2HOST_NAME "mainpipe", engine_dir);
|
||||
int pipe_host2tgt = open (pipe_host2tgt_path, O_CLOEXEC | O_RDONLY);
|
||||
if (pipe_host2tgt < 0)
|
||||
COIERROR ("Cannot open host-to-target main pipe.");
|
||||
int pipe_tgt2host = open (pipe_tgt2host_path, O_CLOEXEC | O_WRONLY);
|
||||
if (pipe_tgt2host < 0)
|
||||
COIERROR ("Cannot open target-to-host main pipe.");
|
||||
|
||||
/* Clean up. */
|
||||
free (pipe_host2tgt_path);
|
||||
free (pipe_tgt2host_path);
|
||||
|
||||
/* Handler. */
|
||||
while (1)
|
||||
{
|
||||
/* Read and execute command. */
|
||||
cmd_t cmd = CMD_SHUTDOWN;
|
||||
int cmd_len = read (pipe_host2tgt, &cmd, sizeof (cmd_t));
|
||||
if (cmd_len != sizeof (cmd_t) && cmd_len != 0)
|
||||
COIERROR ("Cannot read from main pipe.");
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_BUFFER_COPY:
|
||||
{
|
||||
uint64_t len;
|
||||
void *dest, *source;
|
||||
|
||||
/* Receive data from host. */
|
||||
READ (pipe_host2tgt, &dest, sizeof (void *));
|
||||
READ (pipe_host2tgt, &source, sizeof (void *));
|
||||
READ (pipe_host2tgt, &len, sizeof (uint64_t));
|
||||
|
||||
/* Copy. */
|
||||
memcpy (dest, source, len);
|
||||
|
||||
/* Notify host about completion. */
|
||||
WRITE (pipe_tgt2host, &cmd, sizeof (cmd_t));
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_BUFFER_MAP:
|
||||
{
|
||||
char *name;
|
||||
size_t len;
|
||||
uint64_t buffer_len;
|
||||
void *buffer;
|
||||
|
||||
/* Receive data from host. */
|
||||
READ (pipe_host2tgt, &len, sizeof (size_t));
|
||||
MALLOC (char *, name, len);
|
||||
READ (pipe_host2tgt, name, len);
|
||||
READ (pipe_host2tgt, &buffer_len, sizeof (uint64_t));
|
||||
|
||||
/* Open shared memory. */
|
||||
int fd = shm_open (name, O_CLOEXEC | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (fd < 0)
|
||||
COIERROR ("Cannot open shared memory.");
|
||||
|
||||
/* Map shared memory. */
|
||||
buffer = mmap (NULL, buffer_len, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, fd, 0);
|
||||
if (buffer == NULL)
|
||||
COIERROR ("Cannot map shared memory.");
|
||||
|
||||
/* Send data to host. */
|
||||
WRITE (pipe_tgt2host, &fd, sizeof (int));
|
||||
WRITE (pipe_tgt2host, &buffer, sizeof (void *));
|
||||
|
||||
/* Clean up. */
|
||||
free (name);
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_BUFFER_UNMAP:
|
||||
{
|
||||
int fd;
|
||||
uint64_t buffer_len;
|
||||
void *buffer;
|
||||
|
||||
/* Receive data from host. */
|
||||
READ (pipe_host2tgt, &fd, sizeof (int));
|
||||
READ (pipe_host2tgt, &buffer, sizeof (void *));
|
||||
READ (pipe_host2tgt, &buffer_len, sizeof (uint64_t));
|
||||
|
||||
/* Unmap buffer. */
|
||||
if (munmap (buffer, buffer_len) < 0)
|
||||
COIERROR ("Cannot unmap shared memory.");
|
||||
|
||||
/* Close shared memory. */
|
||||
if (close (fd) < 0)
|
||||
COIERROR ("Cannot close shared memory file.");
|
||||
|
||||
/* Notify host about completion. */
|
||||
WRITE (pipe_tgt2host, &cmd, sizeof (cmd_t));
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_GET_FUNCTION_HANDLE:
|
||||
{
|
||||
char *name;
|
||||
size_t len;
|
||||
|
||||
/* Receive data from host. */
|
||||
READ (pipe_host2tgt, &len, sizeof (size_t));
|
||||
MALLOC (char *, name, len);
|
||||
READ (pipe_host2tgt, name, len);
|
||||
|
||||
/* Find function. */
|
||||
void *ptr = dlsym (RTLD_DEFAULT, name);
|
||||
if (ptr == NULL)
|
||||
COIERROR ("Cannot find symbol %s.", name);
|
||||
|
||||
/* Send data to host. */
|
||||
WRITE (pipe_tgt2host, &ptr, sizeof (void *));
|
||||
|
||||
/* Clean up. */
|
||||
free (name);
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_OPEN_LIBRARY:
|
||||
{
|
||||
char *lib_path;
|
||||
size_t len;
|
||||
|
||||
/* Receive data from host. */
|
||||
READ (pipe_host2tgt, &len, sizeof (size_t));
|
||||
MALLOC (char *, lib_path, len);
|
||||
READ (pipe_host2tgt, lib_path, len);
|
||||
|
||||
/* Open library. */
|
||||
void *handle = dlopen (lib_path, RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (handle == NULL)
|
||||
COIERROR ("Cannot load %s: %s", lib_path, dlerror ());
|
||||
|
||||
/* Send data to host. */
|
||||
WRITE (pipe_tgt2host, &handle, sizeof (void *));
|
||||
|
||||
/* Clean up. */
|
||||
free (lib_path);
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_CLOSE_LIBRARY:
|
||||
{
|
||||
/* Receive data from host. */
|
||||
void *handle;
|
||||
READ (pipe_host2tgt, &handle, sizeof (void *));
|
||||
|
||||
dlclose (handle);
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_PIPELINE_CREATE:
|
||||
{
|
||||
/* Receive data from host. */
|
||||
uint32_t *pipeline_num;
|
||||
MALLOC (uint32_t *, pipeline_num, sizeof (uint32_t));
|
||||
READ (pipe_host2tgt, pipeline_num, sizeof (*pipeline_num));
|
||||
|
||||
/* Create a new thread for the pipeline. */
|
||||
pthread_t thread;
|
||||
if (pthread_create (&thread, NULL, pipeline_thread_routine,
|
||||
pipeline_num))
|
||||
COIERROR ("Cannot create new thread.");
|
||||
break;
|
||||
}
|
||||
case CMD_SHUTDOWN:
|
||||
if (close (pipe_host2tgt) < 0)
|
||||
COIERROR ("Cannot close host-to-target main pipe.");
|
||||
if (close (pipe_tgt2host) < 0)
|
||||
COIERROR ("Cannot close target-to-host main pipe.");
|
||||
return COI_SUCCESS;
|
||||
default:
|
||||
COIERROR ("Unrecognizable command from host.");
|
||||
}
|
||||
}
|
||||
|
||||
return COI_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint64_t
|
||||
SYMBOL_VERSION (COIPerfGetCycleFrequency, 1) ()
|
||||
{
|
||||
COITRACE ("COIPerfGetCycleFrequency");
|
||||
|
||||
return (uint64_t) CYCLE_FREQUENCY;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef COI_DEVICE_H_INCLUDED
|
||||
#define COI_DEVICE_H_INCLUDED
|
||||
|
||||
#include "coi_common.h"
|
||||
|
||||
#define COIERROR(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI ERROR - TARGET: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
perror (NULL); \
|
||||
return COI_ERROR; \
|
||||
}
|
||||
|
||||
/* Like COIERROR, but return NULL instead of COIRESULT. */
|
||||
#define COIERRORN(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI ERROR - TARGET: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
perror (NULL); \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#define COITRACE(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI TRACE - TARGET: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define COITRACE(...) {}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // COI_DEVICE_H_INCLUDED
|
File diff suppressed because it is too large
Load diff
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef COI_HOST_H_INCLUDED
|
||||
#define COI_HOST_H_INCLUDED
|
||||
|
||||
#include "coi_common.h"
|
||||
|
||||
#define COIERROR(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI ERROR - HOST: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
perror (NULL); \
|
||||
return COI_ERROR; \
|
||||
}
|
||||
|
||||
/* Like COIERROR, but return NULL instead of COIRESULT. */
|
||||
#define COIERRORN(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI ERROR - HOST: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
perror (NULL); \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#define COITRACE(...) \
|
||||
{ \
|
||||
fprintf (stderr, "COI TRACE - HOST: "); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
fprintf (stderr, "\n"); \
|
||||
}
|
||||
#else
|
||||
#define COITRACE(...) {}
|
||||
#endif
|
||||
|
||||
#endif // COI_HOST_H_INCLUDED
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
// Originally generated via:
|
||||
// cd include;
|
||||
// ctags -x --c-kinds=fp -R sink/ source/ common/ | grep -v COIX | awk '{print "__asm__(\".symver "$1"1,"$1"@@COI_1.0\");"}'
|
||||
//
|
||||
// These directives must have an associated linker script with VERSION stuff.
|
||||
// See coi_version_linker_script.map
|
||||
// Passed in as
|
||||
// -Wl,--version-script coi_version_linker_script.map
|
||||
// when building Intel(R) Coprocessor Offload Infrastructure (Intel(R) COI)
|
||||
//
|
||||
// See http://sourceware.org/binutils/docs/ld/VERSION.html#VERSION for more info
|
||||
//
|
||||
// This is not strictly a .h file, so no need to #pragma once or anything.
|
||||
// You must include these asm directives in the same translation unit as the
|
||||
// one where the function body is.
|
||||
// Otherwise we'd have add this file to the list of files needed to build
|
||||
// libcoi*, instead of including it in each of the api/*/*cpp files.
|
||||
//
|
||||
__asm__(".symver COIBufferAddRef1,COIBufferAddRef@@COI_1.0");
|
||||
__asm__(".symver COIBufferCopy1,COIBufferCopy@@COI_1.0");
|
||||
__asm__(".symver COIBufferCreate1,COIBufferCreate@@COI_1.0");
|
||||
__asm__(".symver COIBufferCreateFromMemory1,COIBufferCreateFromMemory@@COI_1.0");
|
||||
__asm__(".symver COIBufferDestroy1,COIBufferDestroy@@COI_1.0");
|
||||
__asm__(".symver COIBufferGetSinkAddress1,COIBufferGetSinkAddress@@COI_1.0");
|
||||
__asm__(".symver COIBufferMap1,COIBufferMap@@COI_1.0");
|
||||
__asm__(".symver COIBufferRead1,COIBufferRead@@COI_1.0");
|
||||
__asm__(".symver COIBufferReleaseRef1,COIBufferReleaseRef@@COI_1.0");
|
||||
__asm__(".symver COIBufferSetState1,COIBufferSetState@@COI_1.0");
|
||||
__asm__(".symver COIBufferUnmap1,COIBufferUnmap@@COI_1.0");
|
||||
__asm__(".symver COIBufferWrite1,COIBufferWrite@@COI_1.0");
|
||||
__asm__(".symver COIEngineGetCount1,COIEngineGetCount@@COI_1.0");
|
||||
__asm__(".symver COIEngineGetHandle1,COIEngineGetHandle@@COI_1.0");
|
||||
__asm__(".symver COIEngineGetIndex1,COIEngineGetIndex@@COI_1.0");
|
||||
__asm__(".symver COIEngineGetInfo1,COIEngineGetInfo@@COI_1.0");
|
||||
__asm__(".symver COIEventRegisterCallback1,COIEventRegisterCallback@@COI_1.0");
|
||||
__asm__(".symver COIEventWait1,COIEventWait@@COI_1.0");
|
||||
__asm__(".symver COIPerfGetCycleFrequency1,COIPerfGetCycleFrequency@@COI_1.0");
|
||||
__asm__(".symver COIPipelineClearCPUMask1,COIPipelineClearCPUMask@@COI_1.0");
|
||||
__asm__(".symver COIPipelineCreate1,COIPipelineCreate@@COI_1.0");
|
||||
__asm__(".symver COIPipelineDestroy1,COIPipelineDestroy@@COI_1.0");
|
||||
__asm__(".symver COIPipelineRunFunction1,COIPipelineRunFunction@@COI_1.0");
|
||||
__asm__(".symver COIPipelineSetCPUMask1,COIPipelineSetCPUMask@@COI_1.0");
|
||||
__asm__(".symver COIPipelineStartExecutingRunFunctions1,COIPipelineStartExecutingRunFunctions@@COI_1.0");
|
||||
__asm__(".symver COIProcessCreateFromFile1,COIProcessCreateFromFile@@COI_1.0");
|
||||
__asm__(".symver COIProcessCreateFromMemory1,COIProcessCreateFromMemory@@COI_1.0");
|
||||
__asm__(".symver COIProcessDestroy1,COIProcessDestroy@@COI_1.0");
|
||||
__asm__(".symver COIProcessGetFunctionHandles1,COIProcessGetFunctionHandles@@COI_1.0");
|
||||
__asm__(".symver COIProcessLoadLibraryFromMemory2,COIProcessLoadLibraryFromMemory@COI_2.0");
|
||||
__asm__(".symver COIProcessRegisterLibraries1,COIProcessRegisterLibraries@@COI_1.0");
|
||||
__asm__(".symver COIProcessUnloadLibrary1,COIProcessUnloadLibrary@@COI_1.0");
|
||||
__asm__(".symver COIProcessWaitForShutdown1,COIProcessWaitForShutdown@@COI_1.0");
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2016 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, version 2.1.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Disclaimer: The codes contained in these modules may be specific
|
||||
* to the Intel Software Development Platform codenamed Knights Ferry,
|
||||
* and the Intel product codenamed Knights Corner, and are not backward
|
||||
* compatible with other Intel products. Additionally, Intel will NOT
|
||||
* support the codes or instruction set in future products.
|
||||
*
|
||||
* Intel offers no warranty of any kind regarding the code. This code is
|
||||
* licensed on an "AS IS" basis and Intel is not obligated to provide
|
||||
* any support, assistance, installation, training, or other services
|
||||
* of any kind. Intel is also not obligated to provide any updates,
|
||||
* enhancements or extensions. Intel specifically disclaims any warranty
|
||||
* of merchantability, non-infringement, fitness for any particular
|
||||
* purpose, and any other warranty.
|
||||
*
|
||||
* Further, Intel disclaims all liability of any kind, including but
|
||||
* not limited to liability for infringement of any proprietary rights,
|
||||
* relating to the use of the code, even if Intel is notified of the
|
||||
* possibility of such liability. Except as expressly stated in an Intel
|
||||
* license agreement provided with this code and agreed upon with Intel,
|
||||
* no license, express or implied, by estoppel or otherwise, to any
|
||||
* intellectual property rights is granted herein.
|
||||
*/
|
||||
|
||||
/***
|
||||
* See http://sourceware.org/binutils/docs/ld/VERSION.html#VERSION for more info.
|
||||
* Use this in conjunction with coi_version_asm.h.
|
||||
* // Comments don't work in this file.
|
||||
***/
|
||||
|
||||
COI_1.0
|
||||
{
|
||||
global:
|
||||
COIBufferAddRef;
|
||||
COIBufferCopy;
|
||||
COIBufferCreate;
|
||||
COIBufferCreateFromMemory;
|
||||
COIBufferDestroy;
|
||||
COIBufferGetSinkAddress;
|
||||
COIBufferMap;
|
||||
COIBufferRead;
|
||||
COIBufferReleaseRef;
|
||||
COIBufferSetState;
|
||||
COIBufferUnmap;
|
||||
COIBufferWrite;
|
||||
COIEngineGetCount;
|
||||
COIEngineGetHandle;
|
||||
COIEngineGetIndex;
|
||||
COIEngineGetInfo;
|
||||
COIEventWait;
|
||||
COIEventRegisterCallback;
|
||||
COIPerfGetCycleFrequency;
|
||||
COIPipelineClearCPUMask;
|
||||
COIPipelineCreate;
|
||||
COIPipelineDestroy;
|
||||
COIPipelineRunFunction;
|
||||
COIPipelineSetCPUMask;
|
||||
COIPipelineStartExecutingRunFunctions;
|
||||
COIProcessCreateFromFile;
|
||||
COIProcessCreateFromMemory;
|
||||
COIProcessDestroy;
|
||||
COIProcessGetFunctionHandles;
|
||||
COIProcessLoadLibraryFromMemory;
|
||||
COIProcessRegisterLibraries;
|
||||
COIProcessUnloadLibrary;
|
||||
COIProcessWaitForShutdown;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
COI_2.0
|
||||
{
|
||||
|
||||
} COI_1.0;
|
||||
|
|
@ -1,561 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef va_copy
|
||||
#define va_copy(dst, src) ((dst) = (src))
|
||||
#endif
|
||||
|
||||
#include "liboffload_msg.h"
|
||||
|
||||
#include "liboffload_error_codes.h"
|
||||
|
||||
/***********************************************/
|
||||
/* error-handling function, liboffload_error_support */
|
||||
/***********************************************/
|
||||
|
||||
void __liboffload_error_support(error_types input_tag, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, input_tag);
|
||||
|
||||
switch (input_tag) {
|
||||
case c_device_is_not_available:
|
||||
write_message(stderr, msg_c_device_is_not_available, args);
|
||||
break;
|
||||
case c_invalid_device_number:
|
||||
write_message(stderr, msg_c_invalid_device_number, args);
|
||||
break;
|
||||
case c_send_func_ptr:
|
||||
write_message(stderr, msg_c_send_func_ptr, args);
|
||||
break;
|
||||
case c_receive_func_ptr:
|
||||
write_message(stderr, msg_c_receive_func_ptr, args);
|
||||
break;
|
||||
case c_malloc:
|
||||
write_message(stderr, msg_c_malloc, args);
|
||||
break;
|
||||
case c_unknown_mic_device_type:
|
||||
write_message(stderr, msg_c_unknown_mic_device_type, args);
|
||||
break;
|
||||
case c_offload_malloc:
|
||||
write_message(stderr, msg_c_offload_malloc, args);
|
||||
break;
|
||||
case c_offload1:
|
||||
write_message(stderr, msg_c_offload1, args);
|
||||
break;
|
||||
case c_unknown_var_type:
|
||||
write_message(stderr, msg_c_unknown_var_type, args);
|
||||
break;
|
||||
case c_invalid_env_var_value:
|
||||
write_message(stderr, msg_c_invalid_env_var_value, args);
|
||||
break;
|
||||
case c_invalid_env_var_int_value:
|
||||
write_message(stderr, msg_c_invalid_env_var_int_value, args);
|
||||
break;
|
||||
case c_invalid_env_report_value:
|
||||
write_message(stderr, msg_c_invalid_env_report_value, args);
|
||||
break;
|
||||
case c_offload_signaled1:
|
||||
write_message(stderr, msg_c_offload_signaled1, args);
|
||||
break;
|
||||
case c_offload_signaled2:
|
||||
write_message(stderr, msg_c_offload_signaled2, args);
|
||||
break;
|
||||
case c_myowrapper_checkresult:
|
||||
write_message(stderr, msg_c_myowrapper_checkresult, args);
|
||||
break;
|
||||
case c_myotarget_checkresult:
|
||||
write_message(stderr, msg_c_myotarget_checkresult, args);
|
||||
break;
|
||||
case c_offload_descriptor_offload:
|
||||
write_message(stderr, msg_c_offload_descriptor_offload, args);
|
||||
break;
|
||||
case c_merge_var_descs1:
|
||||
write_message(stderr, msg_c_merge_var_descs1, args);
|
||||
break;
|
||||
case c_merge_var_descs2:
|
||||
write_message(stderr, msg_c_merge_var_descs2, args);
|
||||
break;
|
||||
case c_mic_parse_env_var_list1:
|
||||
write_message(stderr, msg_c_mic_parse_env_var_list1, args);
|
||||
break;
|
||||
case c_mic_parse_env_var_list2:
|
||||
write_message(stderr, msg_c_mic_parse_env_var_list2, args);
|
||||
break;
|
||||
case c_mic_process_exit_ret:
|
||||
write_message(stderr, msg_c_mic_process_exit_ret, args);
|
||||
break;
|
||||
case c_mic_process_exit_sig:
|
||||
write_message(stderr, msg_c_mic_process_exit_sig, args);
|
||||
break;
|
||||
case c_mic_process_exit:
|
||||
write_message(stderr, msg_c_mic_process_exit, args);
|
||||
break;
|
||||
case c_mic_init3:
|
||||
write_message(stderr, msg_c_mic_init3, args);
|
||||
break;
|
||||
case c_mic_init4:
|
||||
write_message(stderr, msg_c_mic_init4, args);
|
||||
break;
|
||||
case c_mic_init5:
|
||||
write_message(stderr, msg_c_mic_init5, args);
|
||||
break;
|
||||
case c_mic_init6:
|
||||
write_message(stderr, msg_c_mic_init6, args);
|
||||
break;
|
||||
case c_mic_init7:
|
||||
write_message(stderr, msg_c_mic_init7, args);
|
||||
break;
|
||||
case c_mic_init8:
|
||||
write_message(stderr, msg_c_mic_init8, args);
|
||||
break;
|
||||
case c_mic_init9:
|
||||
write_message(stderr, msg_c_mic_init9, args);
|
||||
break;
|
||||
case c_mic_init10:
|
||||
write_message(stderr, msg_c_mic_init10, args);
|
||||
break;
|
||||
case c_mic_init11:
|
||||
write_message(stderr, msg_c_mic_init11, args);
|
||||
break;
|
||||
case c_no_static_var_data:
|
||||
write_message(stderr, msg_c_no_static_var_data, args);
|
||||
break;
|
||||
case c_no_ptr_data:
|
||||
write_message(stderr, msg_c_no_ptr_data, args);
|
||||
break;
|
||||
case c_get_engine_handle:
|
||||
write_message(stderr, msg_c_get_engine_handle, args);
|
||||
break;
|
||||
case c_get_engine_index:
|
||||
write_message(stderr, msg_c_get_engine_index, args);
|
||||
break;
|
||||
case c_process_create:
|
||||
write_message(stderr, msg_c_process_create, args);
|
||||
break;
|
||||
case c_process_set_cache_size:
|
||||
write_message(stderr, msg_c_process_set_cache_size, args);
|
||||
break;
|
||||
case c_process_wait_shutdown:
|
||||
write_message(stderr, msg_c_process_wait_shutdown, args);
|
||||
break;
|
||||
case c_process_proxy_flush:
|
||||
write_message(stderr, msg_c_process_proxy_flush, args);
|
||||
break;
|
||||
case c_process_get_func_handles:
|
||||
write_message(stderr, msg_c_process_get_func_handles, args);
|
||||
break;
|
||||
case c_load_library:
|
||||
write_message(stderr, msg_c_load_library, args);
|
||||
break;
|
||||
case c_coipipe_max_number:
|
||||
write_message(stderr, msg_c_coi_pipeline_max_number, args);
|
||||
break;
|
||||
case c_pipeline_create:
|
||||
write_message(stderr, msg_c_pipeline_create, args);
|
||||
break;
|
||||
case c_pipeline_run_func:
|
||||
write_message(stderr, msg_c_pipeline_run_func, args);
|
||||
break;
|
||||
case c_pipeline_start_run_funcs:
|
||||
write_message(stderr, msg_c_pipeline_start_run_funcs, args);
|
||||
break;
|
||||
case c_buf_create:
|
||||
write_message(stderr, msg_c_buf_create, args);
|
||||
break;
|
||||
case c_buf_create_out_of_mem:
|
||||
write_message(stderr, msg_c_buf_create_out_of_mem, args);
|
||||
break;
|
||||
case c_buf_create_from_mem:
|
||||
write_message(stderr, msg_c_buf_create_from_mem, args);
|
||||
break;
|
||||
case c_buf_destroy:
|
||||
write_message(stderr, msg_c_buf_destroy, args);
|
||||
break;
|
||||
case c_buf_map:
|
||||
write_message(stderr, msg_c_buf_map, args);
|
||||
break;
|
||||
case c_buf_unmap:
|
||||
write_message(stderr, msg_c_buf_unmap, args);
|
||||
break;
|
||||
case c_buf_read:
|
||||
write_message(stderr, msg_c_buf_read, args);
|
||||
break;
|
||||
case c_buf_write:
|
||||
write_message(stderr, msg_c_buf_write, args);
|
||||
break;
|
||||
case c_buf_copy:
|
||||
write_message(stderr, msg_c_buf_copy, args);
|
||||
break;
|
||||
case c_buf_get_address:
|
||||
write_message(stderr, msg_c_buf_get_address, args);
|
||||
break;
|
||||
case c_buf_add_ref:
|
||||
write_message(stderr, msg_c_buf_add_ref, args);
|
||||
break;
|
||||
case c_buf_release_ref:
|
||||
write_message(stderr, msg_c_buf_release_ref, args);
|
||||
break;
|
||||
case c_buf_set_state:
|
||||
write_message(stderr, msg_c_buf_set_state, args);
|
||||
break;
|
||||
case c_event_wait:
|
||||
write_message(stderr, msg_c_event_wait, args);
|
||||
break;
|
||||
case c_zero_or_neg_ptr_len:
|
||||
write_message(stderr, msg_c_zero_or_neg_ptr_len, args);
|
||||
break;
|
||||
case c_zero_or_neg_transfer_size:
|
||||
write_message(stderr, msg_c_zero_or_neg_transfer_size, args);
|
||||
break;
|
||||
case c_bad_ptr_mem_alloc:
|
||||
write_message(stderr, msg_c_bad_ptr_mem_alloc, args);
|
||||
break;
|
||||
case c_bad_ptr_mem_range:
|
||||
write_message(stderr, msg_c_bad_ptr_mem_range, args);
|
||||
break;
|
||||
case c_different_src_and_dstn_sizes:
|
||||
write_message(stderr, msg_c_different_src_and_dstn_sizes, args);
|
||||
break;
|
||||
case c_ranges_dont_match:
|
||||
write_message(stderr, msg_c_ranges_dont_match, args);
|
||||
break;
|
||||
case c_destination_is_over:
|
||||
write_message(stderr, msg_c_destination_is_over, args);
|
||||
break;
|
||||
case c_slice_of_noncont_array:
|
||||
write_message(stderr, msg_c_slice_of_noncont_array, args);
|
||||
break;
|
||||
case c_non_contiguous_dope_vector:
|
||||
write_message(stderr, msg_c_non_contiguous_dope_vector, args);
|
||||
break;
|
||||
case c_pointer_array_mismatch:
|
||||
write_message(stderr, msg_c_pointer_array_mismatch, args);
|
||||
break;
|
||||
case c_omp_invalid_device_num_env:
|
||||
write_message(stderr, msg_c_omp_invalid_device_num_env, args);
|
||||
break;
|
||||
case c_omp_invalid_device_num:
|
||||
write_message(stderr, msg_c_omp_invalid_device_num, args);
|
||||
break;
|
||||
case c_unknown_binary_type:
|
||||
write_message(stderr, msg_c_unknown_binary_type, args);
|
||||
break;
|
||||
case c_multiple_target_exes:
|
||||
write_message(stderr, msg_c_multiple_target_exes, args);
|
||||
break;
|
||||
case c_no_target_exe:
|
||||
write_message(stderr, msg_c_no_target_exe, args);
|
||||
break;
|
||||
case c_report_unknown_timer_node:
|
||||
write_message(stderr, msg_c_report_unknown_timer_node, args);
|
||||
break;
|
||||
case c_report_unknown_trace_node:
|
||||
write_message(stderr, msg_c_report_unknown_trace_node, args);
|
||||
break;
|
||||
case c_incorrect_affinity:
|
||||
write_message(stderr, msg_c_incorrect_affinity, args);
|
||||
break;
|
||||
case c_cannot_set_affinity:
|
||||
write_message(stderr, msg_c_cannot_set_affinity, args);
|
||||
break;
|
||||
case c_mixed_versions:
|
||||
write_message(stderr, msg_c_mixed_versions, args);
|
||||
break;
|
||||
case c_in_with_preallocated:
|
||||
write_message(stderr, msg_c_in_with_preallocated, args);
|
||||
break;
|
||||
case c_report_no_host_exe:
|
||||
write_message(stderr, msg_c_report_no_host_exe, args);
|
||||
break;
|
||||
case c_report_no_target_exe:
|
||||
write_message(stderr, msg_c_report_no_target_exe, args);
|
||||
break;
|
||||
case c_report_path_buff_overflow:
|
||||
write_message(stderr, msg_c_report_path_buff_overflow, args);
|
||||
break;
|
||||
case c_create_pipeline_for_stream:
|
||||
write_message(stderr, msg_c_create_pipeline_for_stream, args);
|
||||
break;
|
||||
case c_offload_streams_are_absent:
|
||||
write_message(stderr, msg_c_offload_streams_are_absent, args);
|
||||
break;
|
||||
case c_offload_no_stream:
|
||||
write_message(stderr, msg_c_offload_no_stream, args);
|
||||
break;
|
||||
case c_offload_device_doesnt_match_to_stream:
|
||||
write_message(stderr,
|
||||
msg_c_offload_device_doesnt_match_to_stream, args);
|
||||
break;
|
||||
case c_get_engine_info:
|
||||
write_message(stderr, msg_c_get_engine_info, args);
|
||||
break;
|
||||
case c_clear_cpu_mask:
|
||||
write_message(stderr, msg_c_clear_cpu_mask, args);
|
||||
break;
|
||||
case c_set_cpu_mask:
|
||||
write_message(stderr, msg_c_set_cpu_mask, args);
|
||||
break;
|
||||
case c_unload_library:
|
||||
write_message(stderr, msg_c_unload_library, args);
|
||||
break;
|
||||
case c_target_myo_library:
|
||||
write_message(stderr, msg_c_target_myo_library, args);
|
||||
break;
|
||||
case c_myo_dl_sym:
|
||||
write_message(stderr, msg_c_myo_dl_sym, args);
|
||||
break;
|
||||
case c_bad_myo_free:
|
||||
write_message(stderr, msg_c_bad_myo_free, args);
|
||||
break;
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
char const * report_get_message_str(error_types input_tag)
|
||||
{
|
||||
switch (input_tag) {
|
||||
case c_report_title:
|
||||
return (offload_get_message_str(msg_c_report_title));
|
||||
case c_report_from_file:
|
||||
return (offload_get_message_str(msg_c_report_from_file));
|
||||
case c_report_offload:
|
||||
return (offload_get_message_str(msg_c_report_offload));
|
||||
case c_report_mic:
|
||||
return (offload_get_message_str(msg_c_report_mic));
|
||||
case c_report_file:
|
||||
return (offload_get_message_str(msg_c_report_file));
|
||||
case c_report_line:
|
||||
return (offload_get_message_str(msg_c_report_line));
|
||||
case c_report_host:
|
||||
return (offload_get_message_str(msg_c_report_host));
|
||||
case c_report_tag:
|
||||
return (offload_get_message_str(msg_c_report_tag));
|
||||
case c_report_cpu_time:
|
||||
return (offload_get_message_str(msg_c_report_cpu_time));
|
||||
case c_report_seconds:
|
||||
return (offload_get_message_str(msg_c_report_seconds));
|
||||
case c_report_cpu_to_mic_data:
|
||||
return (offload_get_message_str(msg_c_report_cpu_to_mic_data));
|
||||
case c_report_bytes:
|
||||
return (offload_get_message_str(msg_c_report_bytes));
|
||||
case c_report_mic_time:
|
||||
return (offload_get_message_str(msg_c_report_mic_time));
|
||||
case c_report_mic_to_cpu_data:
|
||||
return (offload_get_message_str(msg_c_report_mic_to_cpu_data));
|
||||
case c_report_compute:
|
||||
return (offload_get_message_str(msg_c_report_compute));
|
||||
case c_report_copyin_data:
|
||||
return (offload_get_message_str(msg_c_report_copyin_data));
|
||||
case c_report_copyout_data:
|
||||
return (offload_get_message_str(msg_c_report_copyout_data));
|
||||
case c_report_create_buf_host:
|
||||
return (offload_get_message_str(c_report_create_buf_host));
|
||||
case c_report_create_buf_mic:
|
||||
return (offload_get_message_str(msg_c_report_create_buf_mic));
|
||||
case c_report_destroy:
|
||||
return (offload_get_message_str(msg_c_report_destroy));
|
||||
case c_report_gather_copyin_data:
|
||||
return (offload_get_message_str(msg_c_report_gather_copyin_data));
|
||||
case c_report_gather_copyout_data:
|
||||
return (offload_get_message_str(msg_c_report_gather_copyout_data));
|
||||
case c_report_state_signal:
|
||||
return (offload_get_message_str(msg_c_report_state_signal));
|
||||
case c_report_signal:
|
||||
return (offload_get_message_str(msg_c_report_signal));
|
||||
case c_report_wait:
|
||||
return (offload_get_message_str(msg_c_report_wait));
|
||||
case c_report_init:
|
||||
return (offload_get_message_str(msg_c_report_init));
|
||||
case c_report_init_func:
|
||||
return (offload_get_message_str(msg_c_report_init_func));
|
||||
case c_report_logical_card:
|
||||
return (offload_get_message_str(msg_c_report_logical_card));
|
||||
case c_report_mic_myo_fptr:
|
||||
return (offload_get_message_str(msg_c_report_mic_myo_fptr));
|
||||
case c_report_mic_myo_shared:
|
||||
return (offload_get_message_str(msg_c_report_mic_myo_shared));
|
||||
case c_report_myoacquire:
|
||||
return (offload_get_message_str(msg_c_report_myoacquire));
|
||||
case c_report_myofini:
|
||||
return (offload_get_message_str(msg_c_report_myofini));
|
||||
case c_report_myoinit:
|
||||
return (offload_get_message_str(msg_c_report_myoinit));
|
||||
case c_report_myoregister:
|
||||
return (offload_get_message_str(msg_c_report_myoregister));
|
||||
case c_report_myorelease:
|
||||
return (offload_get_message_str(msg_c_report_myorelease));
|
||||
case c_report_myosharedalignedfree:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_myosharedalignedfree));
|
||||
case c_report_myosharedalignedmalloc:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_myosharedalignedmalloc));
|
||||
case c_report_myosharedfree:
|
||||
return (offload_get_message_str(msg_c_report_myosharedfree));
|
||||
case c_report_myosharedmalloc:
|
||||
return (offload_get_message_str(msg_c_report_myosharedmalloc));
|
||||
case c_report_physical_card:
|
||||
return (offload_get_message_str(msg_c_report_physical_card));
|
||||
case c_report_receive_pointer_data:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_receive_pointer_data));
|
||||
case c_report_received_pointer_data:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_received_pointer_data));
|
||||
case c_report_register:
|
||||
return (offload_get_message_str(msg_c_report_register));
|
||||
case c_report_scatter_copyin_data:
|
||||
return (offload_get_message_str(msg_c_report_scatter_copyin_data));
|
||||
case c_report_scatter_copyout_data:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_scatter_copyout_data));
|
||||
case c_report_send_pointer_data:
|
||||
return (offload_get_message_str(msg_c_report_send_pointer_data));
|
||||
case c_report_sent_pointer_data:
|
||||
return (offload_get_message_str(msg_c_report_sent_pointer_data));
|
||||
case c_report_start:
|
||||
return (offload_get_message_str(msg_c_report_start));
|
||||
case c_report_start_target_func:
|
||||
return (offload_get_message_str(msg_c_report_start_target_func));
|
||||
case c_report_state:
|
||||
return (offload_get_message_str(msg_c_report_state));
|
||||
case c_report_unregister:
|
||||
return (offload_get_message_str(msg_c_report_unregister));
|
||||
case c_report_var:
|
||||
return (offload_get_message_str(msg_c_report_var));
|
||||
case c_report_stream:
|
||||
return (offload_get_message_str(msg_c_report_stream));
|
||||
case c_report_state_stream:
|
||||
return (offload_get_message_str(msg_c_report_state_stream));
|
||||
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_report_unknown_trace_node);
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char const * report_get_host_stage_str(int i)
|
||||
{
|
||||
switch (i) {
|
||||
case c_offload_host_total_offload:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_total_offload_time));
|
||||
case c_offload_host_initialize:
|
||||
return (offload_get_message_str(msg_c_report_host_initialize));
|
||||
case c_offload_host_target_acquire:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_target_acquire));
|
||||
case c_offload_host_wait_deps:
|
||||
return (offload_get_message_str(msg_c_report_host_wait_deps));
|
||||
case c_offload_host_setup_buffers:
|
||||
return (offload_get_message_str(msg_c_report_host_setup_buffers));
|
||||
case c_offload_host_alloc_buffers:
|
||||
return (offload_get_message_str(msg_c_report_host_alloc_buffers));
|
||||
case c_offload_host_setup_misc_data:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_setup_misc_data));
|
||||
case c_offload_host_alloc_data_buffer:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_alloc_data_buffer));
|
||||
case c_offload_host_send_pointers:
|
||||
return (offload_get_message_str(msg_c_report_host_send_pointers));
|
||||
case c_offload_host_gather_inputs:
|
||||
return (offload_get_message_str(msg_c_report_host_gather_inputs));
|
||||
case c_offload_host_map_in_data_buffer:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_map_in_data_buffer));
|
||||
case c_offload_host_unmap_in_data_buffer:
|
||||
return (offload_get_message_str(
|
||||
msg_c_report_host_unmap_in_data_buffer));
|
||||
case c_offload_host_start_compute:
|
||||
return (offload_get_message_str(msg_c_report_host_start_compute));
|
||||
case c_offload_host_wait_compute:
|
||||
return (offload_get_message_str(msg_c_report_host_wait_compute));
|
||||
case c_offload_host_start_buffers_reads:
|
||||
return (offload_get_message_str(
|
||||
msg_c_report_host_start_buffers_reads));
|
||||
case c_offload_host_scatter_outputs:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_scatter_outputs));
|
||||
case c_offload_host_map_out_data_buffer:
|
||||
return (offload_get_message_str(
|
||||
msg_c_report_host_map_out_data_buffer));
|
||||
case c_offload_host_unmap_out_data_buffer:
|
||||
return (offload_get_message_str(
|
||||
msg_c_report_host_unmap_out_data_buffer));
|
||||
case c_offload_host_wait_buffers_reads:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_wait_buffers_reads));
|
||||
case c_offload_host_destroy_buffers:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_host_destroy_buffers));
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char const * report_get_target_stage_str(int i)
|
||||
{
|
||||
switch (i) {
|
||||
case c_offload_target_total_time:
|
||||
return (offload_get_message_str(msg_c_report_target_total_time));
|
||||
case c_offload_target_descriptor_setup:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_target_descriptor_setup));
|
||||
case c_offload_target_func_lookup:
|
||||
return (offload_get_message_str(msg_c_report_target_func_lookup));
|
||||
case c_offload_target_func_time:
|
||||
return (offload_get_message_str(msg_c_report_target_func_time));
|
||||
case c_offload_target_scatter_inputs:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_target_scatter_inputs));
|
||||
case c_offload_target_add_buffer_refs:
|
||||
return (
|
||||
offload_get_message_str(msg_c_report_target_add_buffer_refs));
|
||||
case c_offload_target_compute:
|
||||
return (offload_get_message_str(msg_c_report_target_compute));
|
||||
case c_offload_target_gather_outputs:
|
||||
return (offload_get_message_str
|
||||
(msg_c_report_target_gather_outputs));
|
||||
case c_offload_target_release_buffer_refs:
|
||||
return (offload_get_message_str(
|
||||
msg_c_report_target_release_buffer_refs));
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,337 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(LIBOFFLOAD_ERROR_CODES_H)
|
||||
#define LIBOFFLOAD_ERROR_CODES_H
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
c_device_is_not_available = 0,
|
||||
c_invalid_device_number,
|
||||
c_offload1,
|
||||
c_unknown_var_type,
|
||||
c_send_func_ptr,
|
||||
c_receive_func_ptr,
|
||||
c_malloc,
|
||||
c_unknown_mic_device_type,
|
||||
c_offload_malloc,
|
||||
c_invalid_env_var_value,
|
||||
c_invalid_env_var_int_value,
|
||||
c_invalid_env_report_value,
|
||||
c_offload_signaled1,
|
||||
c_offload_signaled2,
|
||||
c_myotarget_checkresult,
|
||||
c_myowrapper_checkresult,
|
||||
c_offload_descriptor_offload,
|
||||
c_merge_var_descs1,
|
||||
c_merge_var_descs2,
|
||||
c_mic_parse_env_var_list1,
|
||||
c_mic_parse_env_var_list2,
|
||||
c_mic_process_exit_ret,
|
||||
c_mic_process_exit_sig,
|
||||
c_mic_process_exit,
|
||||
c_mic_init3,
|
||||
c_mic_init4,
|
||||
c_mic_init5,
|
||||
c_mic_init6,
|
||||
c_mic_init7,
|
||||
c_mic_init8,
|
||||
c_mic_init9,
|
||||
c_mic_init10,
|
||||
c_mic_init11,
|
||||
c_no_static_var_data,
|
||||
c_no_ptr_data,
|
||||
c_get_engine_handle,
|
||||
c_get_engine_index,
|
||||
c_process_create,
|
||||
c_process_set_cache_size,
|
||||
c_process_get_func_handles,
|
||||
c_process_wait_shutdown,
|
||||
c_process_proxy_flush,
|
||||
c_load_library,
|
||||
c_pipeline_create,
|
||||
c_pipeline_run_func,
|
||||
c_pipeline_start_run_funcs,
|
||||
c_buf_create,
|
||||
c_buf_create_out_of_mem,
|
||||
c_buf_create_from_mem,
|
||||
c_buf_destroy,
|
||||
c_buf_map,
|
||||
c_buf_unmap,
|
||||
c_buf_read,
|
||||
c_buf_write,
|
||||
c_buf_copy,
|
||||
c_buf_get_address,
|
||||
c_buf_add_ref,
|
||||
c_buf_release_ref,
|
||||
c_buf_set_state,
|
||||
c_event_wait,
|
||||
c_zero_or_neg_ptr_len,
|
||||
c_zero_or_neg_transfer_size,
|
||||
c_bad_ptr_mem_alloc,
|
||||
c_bad_ptr_mem_range,
|
||||
c_different_src_and_dstn_sizes,
|
||||
c_ranges_dont_match,
|
||||
c_destination_is_over,
|
||||
c_slice_of_noncont_array,
|
||||
c_non_contiguous_dope_vector,
|
||||
c_pointer_array_mismatch,
|
||||
c_omp_invalid_device_num_env,
|
||||
c_omp_invalid_device_num,
|
||||
c_unknown_binary_type,
|
||||
c_multiple_target_exes,
|
||||
c_no_target_exe,
|
||||
c_incorrect_affinity,
|
||||
c_cannot_set_affinity,
|
||||
c_mixed_versions,
|
||||
c_report_host,
|
||||
c_report_target,
|
||||
c_report_title,
|
||||
c_report_from_file,
|
||||
c_report_file,
|
||||
c_report_line,
|
||||
c_report_tag,
|
||||
c_report_seconds,
|
||||
c_report_bytes,
|
||||
c_report_mic,
|
||||
c_report_cpu_time,
|
||||
c_report_cpu_to_mic_data,
|
||||
c_report_mic_time,
|
||||
c_report_mic_to_cpu_data,
|
||||
c_report_unknown_timer_node,
|
||||
c_report_unknown_trace_node,
|
||||
c_report_offload,
|
||||
c_report_w_tag,
|
||||
c_report_state,
|
||||
c_report_start,
|
||||
c_report_init,
|
||||
c_report_logical_card,
|
||||
c_report_physical_card,
|
||||
c_report_register,
|
||||
c_report_init_func,
|
||||
c_report_create_buf_host,
|
||||
c_report_create_buf_mic,
|
||||
c_report_send_pointer_data,
|
||||
c_report_sent_pointer_data,
|
||||
c_report_gather_copyin_data,
|
||||
c_report_copyin_data,
|
||||
c_report_state_signal,
|
||||
c_report_signal,
|
||||
c_report_wait,
|
||||
c_report_compute,
|
||||
c_report_receive_pointer_data,
|
||||
c_report_received_pointer_data,
|
||||
c_report_start_target_func,
|
||||
c_report_var,
|
||||
c_report_scatter_copyin_data,
|
||||
c_report_gather_copyout_data,
|
||||
c_report_scatter_copyout_data,
|
||||
c_report_copyout_data,
|
||||
c_report_unregister,
|
||||
c_report_destroy,
|
||||
c_report_myoinit,
|
||||
c_report_myoregister,
|
||||
c_report_myofini,
|
||||
c_report_mic_myo_shared,
|
||||
c_report_mic_myo_fptr,
|
||||
c_report_myosharedmalloc,
|
||||
c_report_myosharedfree,
|
||||
c_report_myosharedalignedmalloc,
|
||||
c_report_myosharedalignedfree,
|
||||
c_report_myoacquire,
|
||||
c_report_myorelease,
|
||||
c_report_myosupportsfeature,
|
||||
c_report_myosharedarenacreate,
|
||||
c_report_myosharedalignedarenamalloc,
|
||||
c_report_myosharedalignedarenafree,
|
||||
c_report_myoarenaacquire,
|
||||
c_report_myoarenarelease,
|
||||
c_coipipe_max_number,
|
||||
c_in_with_preallocated,
|
||||
c_report_no_host_exe,
|
||||
c_report_no_target_exe,
|
||||
c_report_path_buff_overflow,
|
||||
c_create_pipeline_for_stream,
|
||||
c_offload_no_stream,
|
||||
c_offload_device_doesnt_match_to_stream,
|
||||
c_offload_streams_are_absent,
|
||||
c_get_engine_info,
|
||||
c_clear_cpu_mask,
|
||||
c_set_cpu_mask,
|
||||
c_report_state_stream,
|
||||
c_report_stream,
|
||||
c_unload_library,
|
||||
c_target_myo_library,
|
||||
c_myo_dl_sym,
|
||||
c_bad_myo_free
|
||||
} error_types;
|
||||
|
||||
enum OffloadHostPhase {
|
||||
// Total time on host for entire offload
|
||||
c_offload_host_total_offload = 0,
|
||||
|
||||
// Time to load target binary
|
||||
c_offload_host_initialize,
|
||||
|
||||
// Time to acquire lrb availability dynamically
|
||||
c_offload_host_target_acquire,
|
||||
|
||||
// Time to wait for dependencies
|
||||
c_offload_host_wait_deps,
|
||||
|
||||
// Time to allocate pointer buffers, initiate writes for pointers
|
||||
// and calculate size of copyin/copyout buffer
|
||||
c_offload_host_setup_buffers,
|
||||
|
||||
// Time to allocate pointer buffers
|
||||
c_offload_host_alloc_buffers,
|
||||
|
||||
// Time to initialize misc data
|
||||
c_offload_host_setup_misc_data,
|
||||
|
||||
// Time to allocate copyin/copyout buffer
|
||||
c_offload_host_alloc_data_buffer,
|
||||
|
||||
// Time to initiate writes from host pointers to buffers
|
||||
c_offload_host_send_pointers,
|
||||
|
||||
// Time to Gather IN data of offload into buffer
|
||||
c_offload_host_gather_inputs,
|
||||
|
||||
// Time to map buffer
|
||||
c_offload_host_map_in_data_buffer,
|
||||
|
||||
// Time to unmap buffer
|
||||
c_offload_host_unmap_in_data_buffer,
|
||||
|
||||
// Time to start remote function call that does computation on lrb
|
||||
c_offload_host_start_compute,
|
||||
|
||||
// Time to wait for compute to finish
|
||||
c_offload_host_wait_compute,
|
||||
|
||||
// Time to initiate reads from pointer buffers
|
||||
c_offload_host_start_buffers_reads,
|
||||
|
||||
// Time to update host variabels with OUT data from buffer
|
||||
c_offload_host_scatter_outputs,
|
||||
|
||||
// Time to map buffer
|
||||
c_offload_host_map_out_data_buffer,
|
||||
|
||||
// Time to unmap buffer
|
||||
c_offload_host_unmap_out_data_buffer,
|
||||
|
||||
// Time to wait reads from buffers to finish
|
||||
c_offload_host_wait_buffers_reads,
|
||||
|
||||
// Time to destroy buffers that are no longer needed
|
||||
c_offload_host_destroy_buffers,
|
||||
|
||||
// LAST TIME MONITOR
|
||||
c_offload_host_max_phase
|
||||
};
|
||||
|
||||
enum OffloadTargetPhase {
|
||||
// Total time spent on the target
|
||||
c_offload_target_total_time = 0,
|
||||
|
||||
// Time to initialize offload descriptor
|
||||
c_offload_target_descriptor_setup,
|
||||
|
||||
// Time to find target entry point in lookup table
|
||||
c_offload_target_func_lookup,
|
||||
|
||||
// Total time spend executing offload entry
|
||||
c_offload_target_func_time,
|
||||
|
||||
// Time to initialize target variables with IN values from buffer
|
||||
c_offload_target_scatter_inputs,
|
||||
|
||||
// Time to add buffer reference for pointer buffers
|
||||
c_offload_target_add_buffer_refs,
|
||||
|
||||
// Total time on lrb for computation
|
||||
c_offload_target_compute,
|
||||
|
||||
// On lrb, time to copy OUT into buffer
|
||||
c_offload_target_gather_outputs,
|
||||
|
||||
// Time to release buffer references
|
||||
c_offload_target_release_buffer_refs,
|
||||
|
||||
// LAST TIME MONITOR
|
||||
c_offload_target_max_phase
|
||||
};
|
||||
|
||||
#ifdef TARGET_WINNT
|
||||
#define DLL_LOCAL
|
||||
#else
|
||||
#define DLL_LOCAL __attribute__((visibility("hidden")))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
DLL_LOCAL void __liboffload_error_support(error_types input_tag, ...);
|
||||
DLL_LOCAL void __liboffload_report_support(error_types input_tag, ...);
|
||||
DLL_LOCAL char const *offload_get_message_str(int msgCode);
|
||||
DLL_LOCAL char const * report_get_message_str(error_types input_tag);
|
||||
DLL_LOCAL char const * report_get_host_stage_str(int i);
|
||||
DLL_LOCAL char const * report_get_target_stage_str(int i);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define test_msg_cat(nm, msg) \
|
||||
fprintf(stderr, "\t TEST for %s \n \t", nm); \
|
||||
__liboffload_error_support(msg);
|
||||
|
||||
#define test_msg_cat1(nm, msg, ...) \
|
||||
fprintf(stderr, "\t TEST for %s \n \t", nm); \
|
||||
__liboffload_error_support(msg, __VA_ARGS__);
|
||||
|
||||
DLL_LOCAL void write_message(FILE * file, int msgCode, va_list args_p);
|
||||
|
||||
#define LIBOFFLOAD_ERROR __liboffload_error_support
|
||||
|
||||
#ifdef TARGET_WINNT
|
||||
#define LIBOFFLOAD_ABORT \
|
||||
_set_abort_behavior(0, _WRITE_ABORT_MSG); \
|
||||
abort()
|
||||
#else
|
||||
#define LIBOFFLOAD_ABORT \
|
||||
abort()
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBOFFLOAD_ERROR_CODES_H)
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// ===========================================================================
|
||||
// Bring in the static string table and the enumerations for indexing into
|
||||
// it.
|
||||
// ===========================================================================
|
||||
|
||||
#include "liboffload_msg.h"
|
||||
|
||||
# define DYNART_STDERR_PUTS(__message_text__) fputs((__message_text__),stderr)
|
||||
|
||||
// ===========================================================================
|
||||
// Now the code for accessing the message catalogs
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
void write_message(FILE * file, int msgCode, va_list args_p) {
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
va_copy(args, args_p);
|
||||
buf[0] = '\n';
|
||||
vsnprintf(buf + 1, sizeof(buf) - 2,
|
||||
MESSAGE_TABLE_NAME[ msgCode ], args);
|
||||
strcat(buf, "\n");
|
||||
va_end(args);
|
||||
fputs(buf, file);
|
||||
fflush(file);
|
||||
}
|
||||
|
||||
char const *offload_get_message_str(int msgCode) {
|
||||
return MESSAGE_TABLE_NAME[ msgCode ];
|
||||
}
|
|
@ -1,416 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// file: liboffload_msg.h
|
||||
enum {
|
||||
__dummy__ = 0,
|
||||
msg_c_device_is_not_available,
|
||||
msg_c_invalid_device_number,
|
||||
msg_c_send_func_ptr,
|
||||
msg_c_receive_func_ptr,
|
||||
msg_c_malloc,
|
||||
msg_c_unknown_mic_device_type,
|
||||
msg_c_offload_malloc,
|
||||
msg_c_offload1,
|
||||
msg_c_unknown_var_type,
|
||||
msg_c_invalid_env_var_value,
|
||||
msg_c_invalid_env_var_int_value,
|
||||
msg_c_invalid_env_report_value,
|
||||
msg_c_offload_signaled1,
|
||||
msg_c_offload_signaled2,
|
||||
msg_c_myowrapper_checkresult,
|
||||
msg_c_myotarget_checkresult,
|
||||
msg_c_offload_descriptor_offload,
|
||||
msg_c_merge_var_descs1,
|
||||
msg_c_merge_var_descs2,
|
||||
msg_c_mic_parse_env_var_list1,
|
||||
msg_c_mic_parse_env_var_list2,
|
||||
msg_c_mic_process_exit_ret,
|
||||
msg_c_mic_process_exit_sig,
|
||||
msg_c_mic_process_exit,
|
||||
msg_c_mic_init3,
|
||||
msg_c_mic_init4,
|
||||
msg_c_mic_init5,
|
||||
msg_c_mic_init6,
|
||||
msg_c_mic_init7,
|
||||
msg_c_mic_init8,
|
||||
msg_c_mic_init9,
|
||||
msg_c_mic_init10,
|
||||
msg_c_mic_init11,
|
||||
msg_c_no_static_var_data,
|
||||
msg_c_no_ptr_data,
|
||||
msg_c_get_engine_handle,
|
||||
msg_c_get_engine_index,
|
||||
msg_c_process_create,
|
||||
msg_c_process_set_cache_size,
|
||||
msg_c_process_get_func_handles,
|
||||
msg_c_process_wait_shutdown,
|
||||
msg_c_process_proxy_flush,
|
||||
msg_c_load_library,
|
||||
msg_c_pipeline_create,
|
||||
msg_c_pipeline_run_func,
|
||||
msg_c_pipeline_start_run_funcs,
|
||||
msg_c_buf_create,
|
||||
msg_c_buf_create_out_of_mem,
|
||||
msg_c_buf_create_from_mem,
|
||||
msg_c_buf_destroy,
|
||||
msg_c_buf_map,
|
||||
msg_c_buf_unmap,
|
||||
msg_c_buf_read,
|
||||
msg_c_buf_write,
|
||||
msg_c_buf_copy,
|
||||
msg_c_buf_get_address,
|
||||
msg_c_buf_add_ref,
|
||||
msg_c_buf_release_ref,
|
||||
msg_c_buf_set_state,
|
||||
msg_c_event_wait,
|
||||
msg_c_zero_or_neg_ptr_len,
|
||||
msg_c_zero_or_neg_transfer_size,
|
||||
msg_c_bad_ptr_mem_alloc,
|
||||
msg_c_bad_ptr_mem_range,
|
||||
msg_c_different_src_and_dstn_sizes,
|
||||
msg_c_non_contiguous_dope_vector,
|
||||
msg_c_omp_invalid_device_num_env,
|
||||
msg_c_omp_invalid_device_num,
|
||||
msg_c_unknown_binary_type,
|
||||
msg_c_multiple_target_exes,
|
||||
msg_c_no_target_exe,
|
||||
msg_c_report_unknown_timer_node,
|
||||
msg_c_report_unknown_trace_node,
|
||||
msg_c_incorrect_affinity,
|
||||
msg_c_cannot_set_affinity,
|
||||
msg_c_mixed_versions,
|
||||
msg_c_report_host,
|
||||
msg_c_report_mic,
|
||||
msg_c_report_title,
|
||||
msg_c_report_seconds,
|
||||
msg_c_report_bytes,
|
||||
msg_c_report_cpu_time,
|
||||
msg_c_report_mic_time,
|
||||
msg_c_report_tag,
|
||||
msg_c_report_from_file,
|
||||
msg_c_report_file,
|
||||
msg_c_report_line,
|
||||
msg_c_report_cpu_to_mic_data,
|
||||
msg_c_report_mic_to_cpu_data,
|
||||
msg_c_report_offload,
|
||||
msg_c_report_w_tag,
|
||||
msg_c_report_state,
|
||||
msg_c_report_start,
|
||||
msg_c_report_init,
|
||||
msg_c_report_logical_card,
|
||||
msg_c_report_physical_card,
|
||||
msg_c_report_register,
|
||||
msg_c_report_init_func,
|
||||
msg_c_report_create_buf_host,
|
||||
msg_c_report_create_buf_mic,
|
||||
msg_c_report_send_pointer_data,
|
||||
msg_c_report_sent_pointer_data,
|
||||
msg_c_report_gather_copyin_data,
|
||||
msg_c_report_copyin_data,
|
||||
msg_c_report_state_signal,
|
||||
msg_c_report_signal,
|
||||
msg_c_report_wait,
|
||||
msg_c_report_compute,
|
||||
msg_c_report_receive_pointer_data,
|
||||
msg_c_report_received_pointer_data,
|
||||
msg_c_report_start_target_func,
|
||||
msg_c_report_var,
|
||||
msg_c_report_scatter_copyin_data,
|
||||
msg_c_report_gather_copyout_data,
|
||||
msg_c_report_scatter_copyout_data,
|
||||
msg_c_report_copyout_data,
|
||||
msg_c_report_unregister,
|
||||
msg_c_report_destroy,
|
||||
msg_c_report_myoinit,
|
||||
msg_c_report_myoregister,
|
||||
msg_c_report_myofini,
|
||||
msg_c_report_mic_myo_shared,
|
||||
msg_c_report_mic_myo_fptr,
|
||||
msg_c_report_myosharedmalloc,
|
||||
msg_c_report_myosharedfree,
|
||||
msg_c_report_myosharedalignedmalloc,
|
||||
msg_c_report_myosharedalignedfree,
|
||||
msg_c_report_myoacquire,
|
||||
msg_c_report_myorelease,
|
||||
msg_c_report_myosupportsfeature,
|
||||
msg_c_report_myosharedarenacreate,
|
||||
msg_c_report_myosharedalignedarenamalloc,
|
||||
msg_c_report_myosharedalignedarenafree,
|
||||
msg_c_report_myoarenaacquire,
|
||||
msg_c_report_myoarenarelease,
|
||||
msg_c_report_host_total_offload_time,
|
||||
msg_c_report_host_initialize,
|
||||
msg_c_report_host_target_acquire,
|
||||
msg_c_report_host_wait_deps,
|
||||
msg_c_report_host_setup_buffers,
|
||||
msg_c_report_host_alloc_buffers,
|
||||
msg_c_report_host_setup_misc_data,
|
||||
msg_c_report_host_alloc_data_buffer,
|
||||
msg_c_report_host_send_pointers,
|
||||
msg_c_report_host_gather_inputs,
|
||||
msg_c_report_host_map_in_data_buffer,
|
||||
msg_c_report_host_unmap_in_data_buffer,
|
||||
msg_c_report_host_start_compute,
|
||||
msg_c_report_host_wait_compute,
|
||||
msg_c_report_host_start_buffers_reads,
|
||||
msg_c_report_host_scatter_outputs,
|
||||
msg_c_report_host_map_out_data_buffer,
|
||||
msg_c_report_host_unmap_out_data_buffer,
|
||||
msg_c_report_host_wait_buffers_reads,
|
||||
msg_c_report_host_destroy_buffers,
|
||||
msg_c_report_target_total_time,
|
||||
msg_c_report_target_descriptor_setup,
|
||||
msg_c_report_target_func_lookup,
|
||||
msg_c_report_target_func_time,
|
||||
msg_c_report_target_scatter_inputs,
|
||||
msg_c_report_target_add_buffer_refs,
|
||||
msg_c_report_target_compute,
|
||||
msg_c_report_target_gather_outputs,
|
||||
msg_c_report_target_release_buffer_refs,
|
||||
msg_c_coi_pipeline_max_number,
|
||||
msg_c_ranges_dont_match,
|
||||
msg_c_destination_is_over,
|
||||
msg_c_slice_of_noncont_array,
|
||||
msg_c_pointer_array_mismatch,
|
||||
msg_c_in_with_preallocated,
|
||||
msg_c_report_no_host_exe,
|
||||
msg_c_report_no_target_exe,
|
||||
msg_c_report_path_buff_overflow,
|
||||
msg_c_create_pipeline_for_stream,
|
||||
msg_c_offload_no_stream,
|
||||
msg_c_offload_device_doesnt_match_to_stream,
|
||||
msg_c_offload_streams_are_absent,
|
||||
msg_c_get_engine_info,
|
||||
msg_c_clear_cpu_mask,
|
||||
msg_c_set_cpu_mask,
|
||||
msg_c_report_state_stream,
|
||||
msg_c_report_stream,
|
||||
msg_c_unload_library,
|
||||
msg_c_target_myo_library,
|
||||
msg_c_myo_dl_sym,
|
||||
msg_c_bad_myo_free,
|
||||
lastMsg = 187,
|
||||
firstMsg = 1
|
||||
};
|
||||
|
||||
|
||||
#if !defined(MESSAGE_TABLE_NAME)
|
||||
# define MESSAGE_TABLE_NAME __liboffload_message_table
|
||||
#endif
|
||||
|
||||
static char const * MESSAGE_TABLE_NAME[] = {
|
||||
/* 0 __dummy__ */ "Un-used message",
|
||||
/* 1 msg_c_device_is_not_available */ "offload error: cannot offload to MIC - device is not available",
|
||||
/* 2 msg_c_invalid_device_number */ "offload error: expected a number greater than or equal to -1",
|
||||
/* 3 msg_c_send_func_ptr */ "offload error: cannot find function name for address %p",
|
||||
/* 4 msg_c_receive_func_ptr */ "offload error: cannot find address of function %s",
|
||||
/* 5 msg_c_malloc */ "offload error: memory allocation failed",
|
||||
/* 6 msg_c_unknown_mic_device_type */ "offload error: unknown mic device type ",
|
||||
/* 7 msg_c_offload_malloc */ "offload error: memory allocation failed (requested=%lld bytes, align %lld)",
|
||||
/* 8 msg_c_offload1 */ "offload error: device %d does not have a pending signal for wait(%p)",
|
||||
/* 9 msg_c_unknown_var_type */ "offload error: unknown variable type %d",
|
||||
/* 10 msg_c_invalid_env_var_value */ "offload warning: ignoring invalid value specified for %s",
|
||||
/* 11 msg_c_invalid_env_var_int_value */ "offload warning: specify an integer value for %s",
|
||||
/* 12 msg_c_invalid_env_report_value */ "offload warning: ignoring %s setting; use a value in range 1-3",
|
||||
/* 13 msg_c_offload_signaled1 */ "offload error: invalid device number %d specified in _Offload_signaled",
|
||||
/* 14 msg_c_offload_signaled2 */ "offload error: invalid signal %p specified for _Offload_signaled",
|
||||
/* 15 msg_c_myowrapper_checkresult */ "offload error: %s failed with error %d",
|
||||
/* 16 msg_c_myotarget_checkresult */ "offload error: %s failed with error %d",
|
||||
/* 17 msg_c_offload_descriptor_offload */ "offload error: cannot find offload entry %s",
|
||||
/* 18 msg_c_merge_var_descs1 */ "offload error: unexpected number of variable descriptors",
|
||||
/* 19 msg_c_merge_var_descs2 */ "offload error: unexpected variable type",
|
||||
/* 20 msg_c_mic_parse_env_var_list1 */ "offload_error: MIC environment variable must begin with an alpabetic character",
|
||||
/* 21 msg_c_mic_parse_env_var_list2 */ "offload_error: MIC environment variable value must be specified with '='",
|
||||
/* 22 msg_c_mic_process_exit_ret */ "offload error: process on the device %d unexpectedly exited with code %d",
|
||||
/* 23 msg_c_mic_process_exit_sig */ "offload error: process on the device %d was terminated by signal %d (%s)",
|
||||
/* 24 msg_c_mic_process_exit */ "offload error: process on the device %d was unexpectedly terminated",
|
||||
/* 25 msg_c_mic_init3 */ "offload warning: ignoring MIC_STACKSIZE setting; use a value >= 16K and a multiple of 4K",
|
||||
/* 26 msg_c_mic_init4 */ "offload error: thread key create failed with error %d",
|
||||
/* 27 msg_c_mic_init5 */ "offload error: specify OFFLOAD_DEVICES as comma-separated physical device numbers or 'none'",
|
||||
/* 28 msg_c_mic_init6 */ "offload error: OFFLOAD_DEVICES device number %d does not correspond to a physical device",
|
||||
/* 29 msg_c_mic_init7 */ "offload error: specify a number as a device in OFFLOAD_DEVICES",
|
||||
/* 30 msg_c_mic_init8 */ "offload error: specify a number as the start of a device range in OFFLOAD_DEVICES",
|
||||
/* 31 msg_c_mic_init9 */ "offload error: specify a number as the end of a device range in OFFLOAD_DEVICES",
|
||||
/* 32 msg_c_mic_init10 */ "offload error: specify a low to high device range in OFFLOAD_DEVICES",
|
||||
/* 33 msg_c_mic_init11 */ "offload error: specify comma-separated device or device ranges in OFFLOAD_DEVICES",
|
||||
/* 34 msg_c_no_static_var_data */ "offload error: cannot find data associated with statically allocated variable %p",
|
||||
/* 35 msg_c_no_ptr_data */ "offload error: cannot find data associated with pointer variable %p",
|
||||
/* 36 msg_c_get_engine_handle */ "offload error: cannot get device %d handle (error code %d)",
|
||||
/* 37 msg_c_get_engine_index */ "offload error: cannot get physical index for logical device %d (error code %d)",
|
||||
/* 38 msg_c_process_create */ "offload error: cannot start process on the device %d (error code %d)",
|
||||
/* 39 msg_c_process_set_cache_size */ "offload error: cannot reserve buffer on the device %d (error code %d)",
|
||||
/* 40 msg_c_process_get_func_handles */ "offload error: cannot get function handles on the device %d (error code %d)",
|
||||
/* 41 msg_c_process_wait_shutdown */ "offload error: wait for process shutdown failed on device %d (error code %d)",
|
||||
/* 42 msg_c_process_proxy_flush */ "offload error: cannot flush process output on device %d (error code %d)",
|
||||
/* 43 msg_c_load_library */ "offload error: cannot load library %s to the device %d (error code %d)",
|
||||
/* 44 msg_c_pipeline_create */ "offload error: cannot create pipeline on the device %d (error code %d)",
|
||||
/* 45 msg_c_pipeline_run_func */ "offload error: cannot execute function on the device %d (error code %d)",
|
||||
/* 46 msg_c_pipeline_start_run_funcs */ "offload error: cannot start executing pipeline function on the device %d (error code %d)",
|
||||
/* 47 msg_c_buf_create */ "offload error: cannot create buffer on device %d (error code %d)",
|
||||
/* 48 msg_c_buf_create_out_of_mem */ "offload error: cannot create buffer on device %d, out of memory",
|
||||
/* 49 msg_c_buf_create_from_mem */ "offload error: cannot create buffer from memory on device %d (error code %d)",
|
||||
/* 50 msg_c_buf_destroy */ "offload error: buffer destroy failed (error code %d)",
|
||||
/* 51 msg_c_buf_map */ "offload error: buffer map failed (error code %d)",
|
||||
/* 52 msg_c_buf_unmap */ "offload error: buffer unmap failed (error code %d)",
|
||||
/* 53 msg_c_buf_read */ "offload error: buffer read failed (error code %d)",
|
||||
/* 54 msg_c_buf_write */ "offload error: buffer write failed (error code %d)",
|
||||
/* 55 msg_c_buf_copy */ "offload error: buffer copy failed (error code %d)",
|
||||
/* 56 msg_c_buf_get_address */ "offload error: cannot get buffer address on device %d (error code %d)",
|
||||
/* 57 msg_c_buf_add_ref */ "offload error: cannot reuse buffer memory on device %d (error code %d)",
|
||||
/* 58 msg_c_buf_release_ref */ "offload error: cannot release buffer memory on device %d (error code %d)",
|
||||
/* 59 msg_c_buf_set_state */ "offload error: buffer set state failed (error code %d)",
|
||||
/* 60 msg_c_event_wait */ "offload error: wait for event to become signaled failed (error code %d)",
|
||||
/* 61 msg_c_zero_or_neg_ptr_len */ "offload error: memory allocation of zero or negative length is not supported",
|
||||
/* 62 msg_c_zero_or_neg_transfer_size */ "offload error: data transfer of zero or negative size is not supported",
|
||||
/* 63 msg_c_bad_ptr_mem_alloc */ "offload error: allocation (base=%p, size=%d) overlaps with existing allocation (base=%p, size=%d)",
|
||||
/* 64 msg_c_bad_ptr_mem_range */ "offload error: data transfer (base=%p, size=%d) not subset of existing allocation (base=%p, size=%d)",
|
||||
/* 65 msg_c_different_src_and_dstn_sizes */ "offload error: size of the source %d differs from size of the destination %d",
|
||||
/* 66 msg_c_non_contiguous_dope_vector */ "offload error: offload data transfer supports only a single contiguous memory range per variable",
|
||||
/* 67 msg_c_omp_invalid_device_num_env */ "offload warning: ignoring %s setting; use a non-negative integer value",
|
||||
/* 68 msg_c_omp_invalid_device_num */ "offload error: device number should be a non-negative integer value",
|
||||
/* 69 msg_c_unknown_binary_type */ "offload error: unexpected embedded target binary type, expected either an executable or shared library",
|
||||
/* 70 msg_c_multiple_target_exes */ "offload error: more that one target executable found",
|
||||
/* 71 msg_c_no_target_exe */ "offload error: target executable is not available",
|
||||
/* 72 msg_c_report_unknown_timer_node */ "offload error: unknown timer node",
|
||||
/* 73 msg_c_report_unknown_trace_node */ "offload error: unknown trace node",
|
||||
/* 74 msg_c_incorrect_affinity */ "offload error: unknow affinity type %s, specify compact, scatter or balanced",
|
||||
/* 75 msg_c_cannot_set_affinity */ "offload_error: unable to set affinity",
|
||||
/* 76 msg_c_mixed_versions */ "offload_error: all application executables that contain offload must be built with the same compiler version",
|
||||
/* 77 msg_c_report_host */ "HOST",
|
||||
/* 78 msg_c_report_mic */ "MIC",
|
||||
/* 79 msg_c_report_title */ "timer data (sec)",
|
||||
/* 80 msg_c_report_seconds */ "(seconds)",
|
||||
/* 81 msg_c_report_bytes */ "(bytes)",
|
||||
/* 82 msg_c_report_cpu_time */ "CPU Time",
|
||||
/* 83 msg_c_report_mic_time */ "MIC Time",
|
||||
/* 84 msg_c_report_tag */ "Tag",
|
||||
/* 85 msg_c_report_from_file */ "Offload from file",
|
||||
/* 86 msg_c_report_file */ "File",
|
||||
/* 87 msg_c_report_line */ "Line",
|
||||
/* 88 msg_c_report_cpu_to_mic_data */ "CPU->MIC Data",
|
||||
/* 89 msg_c_report_mic_to_cpu_data */ "MIC->CPU Data",
|
||||
/* 90 msg_c_report_offload */ "Offload",
|
||||
/* 91 msg_c_report_w_tag */ "Tag %d",
|
||||
/* 92 msg_c_report_state */ "State",
|
||||
/* 93 msg_c_report_start */ "Start target",
|
||||
/* 94 msg_c_report_init */ "Initialize",
|
||||
/* 95 msg_c_report_logical_card */ "logical card",
|
||||
/* 96 msg_c_report_physical_card */ "physical card",
|
||||
/* 97 msg_c_report_register */ "Register static data tables",
|
||||
/* 98 msg_c_report_init_func */ "Setup target entry",
|
||||
/* 99 msg_c_report_create_buf_host */ "Create host buffer",
|
||||
/* 100 msg_c_report_create_buf_mic */ "Create target buffer",
|
||||
/* 101 msg_c_report_send_pointer_data */ "Send pointer data",
|
||||
/* 102 msg_c_report_sent_pointer_data */ "Host->target pointer data",
|
||||
/* 103 msg_c_report_gather_copyin_data */ "Gather copyin data",
|
||||
/* 104 msg_c_report_copyin_data */ "Host->target copyin data",
|
||||
/* 105 msg_c_report_state_signal */ "Signal",
|
||||
/* 106 msg_c_report_signal */ "signal :",
|
||||
/* 107 msg_c_report_wait */ "waits :",
|
||||
/* 108 msg_c_report_compute */ "Execute task on target",
|
||||
/* 109 msg_c_report_receive_pointer_data */ "Receive pointer data",
|
||||
/* 110 msg_c_report_received_pointer_data */ "Target->host pointer data",
|
||||
/* 111 msg_c_report_start_target_func */ "Start target entry",
|
||||
/* 112 msg_c_report_var */ "Var",
|
||||
/* 113 msg_c_report_scatter_copyin_data */ "Scatter copyin data",
|
||||
/* 114 msg_c_report_gather_copyout_data */ "Gather copyout data",
|
||||
/* 115 msg_c_report_scatter_copyout_data */ "Scatter copyout data",
|
||||
/* 116 msg_c_report_copyout_data */ "Target->host copyout data",
|
||||
/* 117 msg_c_report_unregister */ "Unregister data tables",
|
||||
/* 118 msg_c_report_destroy */ "Destroy",
|
||||
/* 119 msg_c_report_myoinit */ "Initialize MYO",
|
||||
/* 120 msg_c_report_myoregister */ "Register MYO tables",
|
||||
/* 121 msg_c_report_myofini */ "Finalize MYO",
|
||||
/* 122 msg_c_report_mic_myo_shared */ "MIC MYO shared table register",
|
||||
/* 123 msg_c_report_mic_myo_fptr */ "MIC MYO fptr table register",
|
||||
/* 124 msg_c_report_myosharedmalloc */ "MYO shared malloc",
|
||||
/* 125 msg_c_report_myosharedfree */ "MYO shared free",
|
||||
/* 126 msg_c_report_myosharedalignedmalloc */ "MYO shared aligned malloc",
|
||||
/* 127 msg_c_report_myosharedalignedfree */ "MYO shared aligned free",
|
||||
/* 128 msg_c_report_myoacquire */ "MYO acquire",
|
||||
/* 129 msg_c_report_myorelease */ "MYO release",
|
||||
/* 130 msg_c_report_myosupportsfeature */ "MYO supports feature",
|
||||
/* 131 msg_c_report_myosharedarenacreate */ "MYO shared arena create",
|
||||
/* 132 msg_c_report_myosharedalignedarenamalloc */ "MYO shared aligned arena malloc",
|
||||
/* 133 msg_c_report_myosharedalignedarenafree */ "MYO shared aligned arena free",
|
||||
/* 134 msg_c_report_myoarenaacquire */ "MYO arena acquire",
|
||||
/* 135 msg_c_report_myoarenarelease */ "MYO arena release",
|
||||
/* 136 msg_c_report_host_total_offload_time */ "host: total offload time",
|
||||
/* 137 msg_c_report_host_initialize */ "host: initialize target",
|
||||
/* 138 msg_c_report_host_target_acquire */ "host: acquire target",
|
||||
/* 139 msg_c_report_host_wait_deps */ "host: wait dependencies",
|
||||
/* 140 msg_c_report_host_setup_buffers */ "host: setup buffers",
|
||||
/* 141 msg_c_report_host_alloc_buffers */ "host: allocate buffers",
|
||||
/* 142 msg_c_report_host_setup_misc_data */ "host: setup misc_data",
|
||||
/* 143 msg_c_report_host_alloc_data_buffer */ "host: allocate buffer",
|
||||
/* 144 msg_c_report_host_send_pointers */ "host: send pointers",
|
||||
/* 145 msg_c_report_host_gather_inputs */ "host: gather inputs",
|
||||
/* 146 msg_c_report_host_map_in_data_buffer */ "host: map IN data buffer",
|
||||
/* 147 msg_c_report_host_unmap_in_data_buffer */ "host: unmap IN data buffer",
|
||||
/* 148 msg_c_report_host_start_compute */ "host: initiate compute",
|
||||
/* 149 msg_c_report_host_wait_compute */ "host: wait compute",
|
||||
/* 150 msg_c_report_host_start_buffers_reads */ "host: initiate pointer reads",
|
||||
/* 151 msg_c_report_host_scatter_outputs */ "host: scatter outputs",
|
||||
/* 152 msg_c_report_host_map_out_data_buffer */ "host: map OUT data buffer",
|
||||
/* 153 msg_c_report_host_unmap_out_data_buffer */ "host: unmap OUT data buffer",
|
||||
/* 154 msg_c_report_host_wait_buffers_reads */ "host: wait pointer reads",
|
||||
/* 155 msg_c_report_host_destroy_buffers */ "host: destroy buffers",
|
||||
/* 156 msg_c_report_target_total_time */ "target: total time",
|
||||
/* 157 msg_c_report_target_descriptor_setup */ "target: setup offload descriptor",
|
||||
/* 158 msg_c_report_target_func_lookup */ "target: entry lookup",
|
||||
/* 159 msg_c_report_target_func_time */ "target: entry time",
|
||||
/* 160 msg_c_report_target_scatter_inputs */ "target: scatter inputs",
|
||||
/* 161 msg_c_report_target_add_buffer_refs */ "target: add buffer reference",
|
||||
/* 162 msg_c_report_target_compute */ "target: compute",
|
||||
/* 163 msg_c_report_target_gather_outputs */ "target: gather outputs",
|
||||
/* 164 msg_c_report_target_release_buffer_refs */ "target: remove buffer reference",
|
||||
/* 165 msg_c_coi_pipeline_max_number */ "number of host threads doing offload exceeds maximum of %d",
|
||||
/* 166 msg_c_ranges_dont_match */ "ranges of source and destination don't match together",
|
||||
/* 167 msg_c_destination_is_over */ "insufficient destination memory to transfer source",
|
||||
/* 168 msg_c_slice_of_noncont_array */ "a non-contiguous slice may be taken of contiguous arrays only",
|
||||
/* 169 msg_c_pointer_array_mismatch */ "number of %s elements is less than described by the source",
|
||||
/* 170 msg_c_in_with_preallocated */ "offload error: preallocated targetptr alloc_if(1) may not be used with an in clause",
|
||||
/* 171 msg_c_report_no_host_exe */ "offload error: Cannot find host executable",
|
||||
/* 172 msg_c_report_no_target_exe */ "offload error: Cannot find target executable (%s)",
|
||||
/* 173 msg_c_report_path_buff_overflow */ "offload error: Size of host executable path exceeded 4KB",
|
||||
/* 174 msg_c_create_pipeline_for_stream */ "offload error: number of cpus exceeds maximum of %d",
|
||||
/* 175 msg_c_offload_no_stream */ "offload error: the stream isn't found on device %d",
|
||||
/* 176 msg_c_offload_device_doesnt_match_to_stream */ "offload_error: the stream was created for device %d",
|
||||
/* 177 msg_c_offload_streams_are_absent */ "offload error: there was created no streams",
|
||||
/* 178 msg_c_get_engine_info */ "offload error: cannot get device %d info (error code %d)",
|
||||
/* 179 msg_c_clear_cpu_mask */ "offload error: cannot clear cpu mask (error code %d)",
|
||||
/* 180 msg_c_set_cpu_mask */ "offload error: cannot set cpu mask (error code %d)",
|
||||
/* 181 msg_c_report_state_stream */ "Stream",
|
||||
/* 182 msg_c_report_stream */ "stream :",
|
||||
/* 183 msg_c_unload_library */ "offload error: cannot unload library from the device %d (error code %d)",
|
||||
/* 184 msg_c_target_myo_library */ "offload error: cannot find MYO library on device %s",
|
||||
/* 185 msg_c_myo_dl_sym */ "offload error: cannot find MYO func on device %s",
|
||||
/* 186 msg_c_bad_myo_free */ "offload error: cannot free MYO shared memory %p",
|
||||
};
|
|
@ -1,282 +0,0 @@
|
|||
!
|
||||
! Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
!
|
||||
! Redistribution and use in source and binary forms, with or without
|
||||
! modification, are permitted provided that the following conditions
|
||||
! are met:
|
||||
!
|
||||
! * Redistributions of source code must retain the above copyright
|
||||
! notice, this list of conditions and the following disclaimer.
|
||||
! * Redistributions in binary form must reproduce the above copyright
|
||||
! notice, this list of conditions and the following disclaimer in the
|
||||
! documentation and/or other materials provided with the distribution.
|
||||
! * Neither the name of Intel Corporation nor the names of its
|
||||
! contributors may be used to endorse or promote products derived
|
||||
! from this software without specific prior written permission.
|
||||
!
|
||||
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
!
|
||||
|
||||
|
||||
! **********************************************************************************
|
||||
! * This file is intended to support the Intel(r) Many Integrated Core Architecture.
|
||||
! **********************************************************************************
|
||||
! free form Fortran source - should be named .f90
|
||||
! lines are longer than 72 characters
|
||||
|
||||
module mic_lib
|
||||
use, intrinsic :: iso_c_binding
|
||||
|
||||
integer, parameter:: target_mic=2
|
||||
integer, parameter:: default_target_type=target_mic
|
||||
integer, parameter:: default_target_number=0
|
||||
|
||||
enum, bind(C)
|
||||
enumerator :: OFFLOAD_SUCCESS = 0
|
||||
enumerator :: OFFLOAD_DISABLED ! offload is disabled
|
||||
enumerator :: OFFLOAD_UNAVAILABLE ! card is not available
|
||||
enumerator :: OFFLOAD_OUT_OF_MEMORY ! not enough memory on device
|
||||
enumerator :: OFFLOAD_PROCESS_DIED ! target process has died
|
||||
enumerator :: OFFLOAD_ERROR ! unspecified error
|
||||
end enum
|
||||
|
||||
type, bind (C) :: offload_status
|
||||
integer(kind=c_int) :: result = OFFLOAD_DISABLED
|
||||
integer(kind=c_int) :: device_number = -1
|
||||
integer(kind=c_size_t) :: data_sent = 0
|
||||
integer(kind=c_size_t) :: data_received = 0
|
||||
end type offload_status
|
||||
|
||||
interface
|
||||
function offload_number_of_devices () &
|
||||
bind (C, name = "_Offload_number_of_devices")
|
||||
!dec$ attributes default :: offload_number_of_devices
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: offload_number_of_devices
|
||||
!dec$ attributes offload:mic :: offload_number_of_devices
|
||||
!dir$ attributes known_intrinsic :: offload_number_of_devices
|
||||
end function offload_number_of_devices
|
||||
|
||||
function offload_signaled(target_number, signal) &
|
||||
bind (C, name = "_Offload_signaled")
|
||||
!dec$ attributes default :: offload_signaled
|
||||
import :: c_int, c_int64_t
|
||||
integer (kind=c_int) :: offload_signaled
|
||||
integer (kind=c_int), value :: target_number
|
||||
integer (kind=c_int64_t), value :: signal
|
||||
!dec$ attributes offload:mic :: offload_signaled
|
||||
end function offload_signaled
|
||||
|
||||
subroutine offload_report(val) &
|
||||
bind (C, name = "_Offload_report")
|
||||
!dec$ attributes default :: offload_report
|
||||
import :: c_int
|
||||
integer (kind=c_int), value :: val
|
||||
!dec$ attributes offload:mic :: offload_report
|
||||
end subroutine offload_report
|
||||
|
||||
function offload_get_device_number() &
|
||||
bind (C, name = "_Offload_get_device_number")
|
||||
!dec$ attributes default :: offload_get_device_number
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: offload_get_device_number
|
||||
!dec$ attributes offload:mic :: offload_get_device_number
|
||||
end function offload_get_device_number
|
||||
|
||||
function offload_get_physical_device_number() &
|
||||
bind (C, name = "_Offload_get_physical_device_number")
|
||||
!dec$ attributes default :: offload_get_physical_device_number
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: offload_get_physical_device_number
|
||||
!dec$ attributes offload:mic :: offload_get_physical_device_number
|
||||
end function offload_get_physical_device_number
|
||||
|
||||
! OpenMP API wrappers
|
||||
|
||||
subroutine omp_set_num_threads_target (target_type, &
|
||||
target_number, &
|
||||
num_threads) &
|
||||
bind (C, name = "omp_set_num_threads_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int), value :: target_type, target_number, num_threads
|
||||
end subroutine omp_set_num_threads_target
|
||||
|
||||
function omp_get_max_threads_target (target_type, &
|
||||
target_number) &
|
||||
bind (C, name = "omp_get_max_threads_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: omp_get_max_threads_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
end function omp_get_max_threads_target
|
||||
|
||||
function omp_get_num_procs_target (target_type, &
|
||||
target_number) &
|
||||
bind (C, name = "omp_get_num_procs_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: omp_get_num_procs_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
end function omp_get_num_procs_target
|
||||
|
||||
subroutine omp_set_dynamic_target (target_type, &
|
||||
target_number, &
|
||||
num_threads) &
|
||||
bind (C, name = "omp_set_dynamic_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int), value :: target_type, target_number, num_threads
|
||||
end subroutine omp_set_dynamic_target
|
||||
|
||||
function omp_get_dynamic_target (target_type, &
|
||||
target_number) &
|
||||
bind (C, name = "omp_get_dynamic_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: omp_get_dynamic_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
end function omp_get_dynamic_target
|
||||
|
||||
subroutine omp_set_nested_target (target_type, &
|
||||
target_number, &
|
||||
nested) &
|
||||
bind (C, name = "omp_set_nested_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int), value :: target_type, target_number, nested
|
||||
end subroutine omp_set_nested_target
|
||||
|
||||
function omp_get_nested_target (target_type, &
|
||||
target_number) &
|
||||
bind (C, name = "omp_get_nested_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int) :: omp_get_nested_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
end function omp_get_nested_target
|
||||
|
||||
subroutine omp_set_schedule_target (target_type, &
|
||||
target_number, &
|
||||
kind, &
|
||||
modifier) &
|
||||
bind (C, name = "omp_set_schedule_target")
|
||||
import :: c_int
|
||||
integer (kind=c_int), value :: target_type, target_number, kind, modifier
|
||||
end subroutine omp_set_schedule_target
|
||||
|
||||
subroutine omp_get_schedule_target (target_type, &
|
||||
target_number, &
|
||||
kind, &
|
||||
modifier) &
|
||||
bind (C, name = "omp_get_schedule_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: kind, modifier
|
||||
end subroutine omp_get_schedule_target
|
||||
|
||||
! lock API functions
|
||||
|
||||
subroutine omp_init_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_init_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
!dir$ attributes known_intrinsic :: omp_init_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_init_lock_target
|
||||
|
||||
subroutine omp_destroy_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_destroy_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
!dir$ attributes known_intrinsic :: omp_destroy_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_destroy_lock_target
|
||||
|
||||
subroutine omp_set_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_set_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
!dir$ attributes known_intrinsic :: omp_set_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_set_lock_target
|
||||
|
||||
subroutine omp_unset_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_unset_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
!dir$ attributes known_intrinsic :: omp_unset_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_unset_lock_target
|
||||
|
||||
function omp_test_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_test_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int) :: omp_test_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end function omp_test_lock_target
|
||||
|
||||
! nested lock API functions
|
||||
|
||||
subroutine omp_init_nest_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_init_nest_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_init_nest_lock_target
|
||||
|
||||
subroutine omp_destroy_nest_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_destroy_nest_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_destroy_nest_lock_target
|
||||
|
||||
subroutine omp_set_nest_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_set_nest_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_set_nest_lock_target
|
||||
|
||||
subroutine omp_unset_nest_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_unset_nest_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end subroutine omp_unset_nest_lock_target
|
||||
|
||||
function omp_test_nest_lock_target (target_type, &
|
||||
target_number, &
|
||||
lock) &
|
||||
bind (C, name = "omp_test_nest_lock_target")
|
||||
import :: c_int, c_intptr_t
|
||||
integer (kind=c_int) :: omp_test_nest_lock_target
|
||||
integer (kind=c_int), value :: target_type, target_number
|
||||
integer (kind=c_intptr_t), value :: lock
|
||||
end function omp_test_nest_lock_target
|
||||
|
||||
end interface
|
||||
end module mic_lib
|
|
@ -1,565 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Include file for Offload API.
|
||||
*/
|
||||
|
||||
#ifndef OFFLOAD_H_INCLUDED
|
||||
#define OFFLOAD_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(LINUX) || defined(FREEBSD)
|
||||
#include <bits/functexcept.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <omp.h>
|
||||
|
||||
#ifdef TARGET_WINNT
|
||||
// <stdint.h> is incompatible on Windows.
|
||||
typedef unsigned long long int uint64_t;
|
||||
typedef signed long long int int64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TARGET_ATTRIBUTE __declspec(target(mic))
|
||||
|
||||
/*
|
||||
* The target architecture.
|
||||
*/
|
||||
typedef enum TARGET_TYPE {
|
||||
TARGET_NONE, /* Undefine target */
|
||||
TARGET_HOST, /* Host used as target */
|
||||
TARGET_MIC /* MIC target */
|
||||
} TARGET_TYPE;
|
||||
|
||||
/*
|
||||
* The default target type.
|
||||
*/
|
||||
#define DEFAULT_TARGET_TYPE TARGET_MIC
|
||||
|
||||
/*
|
||||
* The default target number.
|
||||
*/
|
||||
#define DEFAULT_TARGET_NUMBER 0
|
||||
|
||||
/*
|
||||
* Offload status.
|
||||
*/
|
||||
typedef enum {
|
||||
OFFLOAD_SUCCESS = 0,
|
||||
OFFLOAD_DISABLED, /* offload is disabled */
|
||||
OFFLOAD_UNAVAILABLE, /* card is not available */
|
||||
OFFLOAD_OUT_OF_MEMORY, /* not enough memory on device */
|
||||
OFFLOAD_PROCESS_DIED, /* target process has died */
|
||||
OFFLOAD_ERROR /* unspecified error */
|
||||
} _Offload_result;
|
||||
|
||||
typedef struct {
|
||||
_Offload_result result; /* result, see above */
|
||||
int device_number; /* device number */
|
||||
size_t data_sent; /* number of bytes sent to the target */
|
||||
size_t data_received; /* number of bytes received by host */
|
||||
} _Offload_status;
|
||||
|
||||
typedef int64_t _Offload_stream;
|
||||
|
||||
#define OFFLOAD_STATUS_INIT(x) \
|
||||
((x).result = OFFLOAD_DISABLED)
|
||||
|
||||
#define OFFLOAD_STATUS_INITIALIZER \
|
||||
{ OFFLOAD_DISABLED, -1, 0, 0 }
|
||||
|
||||
/* Offload runtime interfaces */
|
||||
|
||||
extern int _Offload_number_of_devices(void);
|
||||
extern int _Offload_get_device_number(void);
|
||||
extern int _Offload_get_physical_device_number(void);
|
||||
|
||||
/* Offload stream runtime interfaces */
|
||||
|
||||
extern _Offload_stream _Offload_stream_create(
|
||||
int device, // MIC device number
|
||||
int number_of_cpus // Cores allocated to the stream
|
||||
);
|
||||
|
||||
extern int _Offload_stream_destroy(
|
||||
int device, // MIC device number
|
||||
_Offload_stream stream // stream handle
|
||||
);
|
||||
|
||||
extern int _Offload_stream_delete(
|
||||
_Offload_stream handle // stream handle
|
||||
);
|
||||
|
||||
extern int _Offload_stream_completed(
|
||||
int device, // MIC device number
|
||||
_Offload_stream handle // stream handle
|
||||
);
|
||||
|
||||
extern int _Offload_device_streams_completed(
|
||||
int device // MIC device number
|
||||
);
|
||||
|
||||
extern int _Offload_stream_is_empty(
|
||||
_Offload_stream handle // stream handle
|
||||
);
|
||||
|
||||
/*
|
||||
* _Offload_shared_malloc/free are only supported when offload is enabled
|
||||
* else they are defined to malloc and free
|
||||
*/
|
||||
#ifdef __INTEL_OFFLOAD
|
||||
extern void* _Offload_shared_malloc(size_t size);
|
||||
extern void _Offload_shared_free(void *ptr);
|
||||
extern void* _Offload_shared_aligned_malloc(size_t size, size_t align);
|
||||
extern void _Offload_shared_aligned_free(void *ptr);
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#define _Offload_shared_malloc(size) malloc(size)
|
||||
#define _Offload_shared_free(ptr) free(ptr);
|
||||
#if defined(_WIN32)
|
||||
#define _Offload_shared_aligned_malloc(size, align) _aligned_malloc(size, align)
|
||||
#define _Offload_shared_aligned_free(ptr) _aligned_free(ptr);
|
||||
#else
|
||||
#define _Offload_shared_aligned_malloc(size, align) memalign(align, size)
|
||||
#define _Offload_shared_aligned_free(ptr) free(ptr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
extern int _Offload_signaled(int index, void *signal);
|
||||
extern void _Offload_report(int val);
|
||||
extern int _Offload_find_associated_mic_memory(
|
||||
int target,
|
||||
const void* cpu_addr,
|
||||
void** cpu_base_addr,
|
||||
uint64_t* buf_length,
|
||||
void** mic_addr,
|
||||
uint64_t* mic_buf_start_offset,
|
||||
int* is_static
|
||||
);
|
||||
|
||||
/* OpenMP API */
|
||||
|
||||
extern void omp_set_default_device(int num) __GOMP_NOTHROW;
|
||||
extern int omp_get_default_device(void) __GOMP_NOTHROW;
|
||||
extern int omp_get_num_devices(void) __GOMP_NOTHROW;
|
||||
|
||||
// OpenMP 4.5 APIs
|
||||
|
||||
/*! \fn omp_get_initial_device
|
||||
\brief Return the device id of the initial device.
|
||||
\return Returns the device id of the initial device.
|
||||
*/
|
||||
extern int omp_get_initial_device(
|
||||
void
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_alloc
|
||||
\brief Allocate memory in the device data environment.
|
||||
\param size Number of bytes to allocate.
|
||||
\param device_num The device number on which to allocate.
|
||||
\return Returns a pointer to the allocated memory.
|
||||
*/
|
||||
extern void* omp_target_alloc(
|
||||
size_t size,
|
||||
int device_num
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_free
|
||||
\brief Free memory in the device data environment.
|
||||
\param device_ptr Address of allocated device memory.
|
||||
\param device_num The device number on which to free.
|
||||
*/
|
||||
extern void omp_target_free(
|
||||
void *device_ptr,
|
||||
int device_num
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_is_present
|
||||
\brief Test whether a host pointer has corresponding storage on a device.
|
||||
\param device_ptr Address of allocated device memory.
|
||||
\param device_num The device number on which to test..
|
||||
\return true if storage is found, false otherwise.
|
||||
*/
|
||||
extern int omp_target_is_present(
|
||||
const void *ptr,
|
||||
int device_num
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_memcpy
|
||||
\brief Copy memory between host/device pointers.
|
||||
\param dst Address of destination memory.
|
||||
\param src Address of source memory.
|
||||
\param length Number of bytes to copy.
|
||||
\param dst_offset Destination offset in bytes.
|
||||
\param src_offset Source offset in bytes.
|
||||
\param dst_device Destination device number.
|
||||
\param src_device Source device number.
|
||||
\return 0 on success, 1 otherwise.
|
||||
*/
|
||||
extern int omp_target_memcpy(
|
||||
void *dst,
|
||||
const void *src,
|
||||
size_t length,
|
||||
size_t dst_offset,
|
||||
size_t src_offset,
|
||||
int dst_device,
|
||||
int src_device
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_memcpy_rect
|
||||
\brief Copy a rectangular subsection from
|
||||
\brief one multi-dimensional array to another.
|
||||
\param dst Address of destination array.
|
||||
\param src Address of source array.
|
||||
\param element_size Number of bytes in each array element.
|
||||
\param num_dims Number of dimensions.
|
||||
\param volume Array of element counts to copy in each dimension.
|
||||
\param dst_offsets Destination offsets array.
|
||||
\param src_offsets Source offsets array.
|
||||
\param dst_dims Destination array dimensions array.
|
||||
\param src_dims Source array dimensions array.
|
||||
\param dst_device Destination device number.
|
||||
\param src_device Source device number.
|
||||
\return 0 on success, 1 otherwise.
|
||||
*/
|
||||
extern int omp_target_memcpy_rect(
|
||||
void *dst,
|
||||
const void *src,
|
||||
size_t element_size,
|
||||
int num_dims,
|
||||
const size_t *volume,
|
||||
const size_t *dst_offsets,
|
||||
const size_t *src_offsets,
|
||||
const size_t *dst_dimensions,
|
||||
const size_t *src_dimensions,
|
||||
int dst_device,
|
||||
int src_device
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_associate_ptr
|
||||
\brief Map a device pointer to a host pointer.
|
||||
\param host_ptr The host pointer.
|
||||
\param device_ptr The device pointer.
|
||||
\param size Number of bytes to map.
|
||||
\param device_offset Offset on device of mapped memory.
|
||||
\param device_num Device number.
|
||||
\return 0 on success, 1 otherwise.
|
||||
*/
|
||||
extern int omp_target_associate_ptr(
|
||||
const void *host_ptr,
|
||||
const void *device_ptr,
|
||||
size_t size,
|
||||
size_t device_offset,
|
||||
int device_num
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
/*! \fn omp_target_disassociate_ptr
|
||||
\brief Remove a host pointer to device pointer association.
|
||||
\param ptr The host pointer to disassociate.
|
||||
\param device_num Device number.
|
||||
\return 0 on success, 1 otherwise.
|
||||
*/
|
||||
extern int omp_target_disassociate_ptr(
|
||||
const void *host_ptr,
|
||||
int device_num
|
||||
) __GOMP_NOTHROW;
|
||||
|
||||
// End of OpenMP 4.5 APIs
|
||||
|
||||
/* OpenMP API wrappers */
|
||||
|
||||
/* Set num_threads on target */
|
||||
extern void omp_set_num_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
);
|
||||
|
||||
/* Get max_threads from target */
|
||||
extern int omp_get_max_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
/* Get num_procs from target */
|
||||
extern int omp_get_num_procs_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
/* Set dynamic on target */
|
||||
extern void omp_set_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
);
|
||||
|
||||
/* Get dynamic from target */
|
||||
extern int omp_get_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
/* Set nested on target */
|
||||
extern void omp_set_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int nested
|
||||
);
|
||||
|
||||
/* Get nested from target */
|
||||
extern int omp_get_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
extern void omp_set_num_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
);
|
||||
|
||||
extern int omp_get_max_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
extern int omp_get_num_procs_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
extern void omp_set_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
);
|
||||
|
||||
extern int omp_get_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
extern void omp_set_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
);
|
||||
|
||||
extern int omp_get_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
);
|
||||
|
||||
extern void omp_set_schedule_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_sched_t kind,
|
||||
int modifier
|
||||
);
|
||||
|
||||
extern void omp_get_schedule_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_sched_t *kind,
|
||||
int *modifier
|
||||
);
|
||||
|
||||
/* lock API functions */
|
||||
|
||||
typedef struct {
|
||||
omp_lock_t lock;
|
||||
} omp_lock_target_t;
|
||||
|
||||
extern void omp_init_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_destroy_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_set_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_unset_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern int omp_test_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
);
|
||||
|
||||
/* nested lock API functions */
|
||||
|
||||
typedef struct {
|
||||
omp_nest_lock_t lock;
|
||||
} omp_nest_lock_target_t;
|
||||
|
||||
extern void omp_init_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_destroy_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_set_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern void omp_unset_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
);
|
||||
|
||||
extern int omp_test_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
/* Namespace for the shared_allocator. */
|
||||
namespace __offload {
|
||||
/* This follows the specification for std::allocator. */
|
||||
/* Forward declaration of the class template. */
|
||||
template <typename T>
|
||||
class shared_allocator;
|
||||
|
||||
/* Specialization for shared_allocator<void>. */
|
||||
template <>
|
||||
class shared_allocator<void> {
|
||||
public:
|
||||
typedef void *pointer;
|
||||
typedef const void *const_pointer;
|
||||
typedef void value_type;
|
||||
template <class U> struct rebind { typedef shared_allocator<U> other; };
|
||||
};
|
||||
|
||||
/* Definition of shared_allocator<T>. */
|
||||
template <class T>
|
||||
class shared_allocator {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef T &reference;
|
||||
typedef const T &const_reference;
|
||||
typedef T value_type;
|
||||
template <class U> struct rebind { typedef shared_allocator<U> other; };
|
||||
shared_allocator() throw() { }
|
||||
shared_allocator(const shared_allocator&) throw() { }
|
||||
template <class U> shared_allocator(const shared_allocator<U>&) throw() { }
|
||||
~shared_allocator() throw() { }
|
||||
pointer address(reference x) const { return &x; }
|
||||
const_pointer address(const_reference x) const { return &x; }
|
||||
pointer allocate(
|
||||
size_type, shared_allocator<void>::const_pointer hint = 0);
|
||||
void deallocate(pointer p, size_type n);
|
||||
size_type max_size() const throw() {
|
||||
return size_type(-1)/sizeof(T);
|
||||
} /* max_size */
|
||||
void construct(pointer p, const T& arg) {
|
||||
::new (p) T(arg);
|
||||
} /* construct */
|
||||
void destroy(pointer p) {
|
||||
p->~T();
|
||||
} /* destroy */
|
||||
};
|
||||
|
||||
/* Definition for allocate. */
|
||||
template <class T>
|
||||
typename shared_allocator<T>::pointer
|
||||
shared_allocator<T>::allocate(shared_allocator<T>::size_type s,
|
||||
shared_allocator<void>::const_pointer) {
|
||||
/* Allocate from shared memory. */
|
||||
void *ptr = _Offload_shared_malloc(s*sizeof(T));
|
||||
#if (defined(_WIN32) || defined(_WIN64)) /* Windows */
|
||||
if (ptr == 0) throw std::bad_alloc();
|
||||
#else
|
||||
if (ptr == 0) std::__throw_bad_alloc();
|
||||
#endif
|
||||
return static_cast<pointer>(ptr);
|
||||
} /* allocate */
|
||||
|
||||
template <class T>
|
||||
void shared_allocator<T>::deallocate(pointer p,
|
||||
shared_allocator<T>::size_type) {
|
||||
/* Free the shared memory. */
|
||||
_Offload_shared_free(p);
|
||||
} /* deallocate */
|
||||
|
||||
template <typename _T1, typename _T2>
|
||||
inline bool operator==(const shared_allocator<_T1> &,
|
||||
const shared_allocator<_T2> &) throw() {
|
||||
return true;
|
||||
} /* operator== */
|
||||
|
||||
template <typename _T1, typename _T2>
|
||||
inline bool operator!=(const shared_allocator<_T1> &,
|
||||
const shared_allocator<_T2> &) throw() {
|
||||
return false;
|
||||
} /* operator!= */
|
||||
} /* __offload */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* OFFLOAD_H_INCLUDED */
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#if defined(LINUX) || defined(FREEBSD)
|
||||
#include <mm_malloc.h>
|
||||
#endif
|
||||
|
||||
#include "offload_common.h"
|
||||
|
||||
// The debug routines
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
|
||||
void __dump_bytes(
|
||||
int trace_level,
|
||||
const void *data,
|
||||
int len
|
||||
)
|
||||
{
|
||||
if (console_enabled > trace_level) {
|
||||
const uint8_t *arr = (const uint8_t*) data;
|
||||
char buffer[4096];
|
||||
char *bufferp;
|
||||
int count = 0;
|
||||
|
||||
bufferp = buffer;
|
||||
while (len--) {
|
||||
sprintf(bufferp, "%02x", *arr++);
|
||||
bufferp += 2;
|
||||
count++;
|
||||
if ((count&3) == 0) {
|
||||
sprintf(bufferp, " ");
|
||||
bufferp++;
|
||||
}
|
||||
if ((count&63) == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(trace_level, "%s\n", buffer);
|
||||
bufferp = buffer;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (count) {
|
||||
OFFLOAD_DEBUG_TRACE(trace_level, "%s\n", buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // OFFLOAD_DEBUG
|
||||
|
||||
// The Marshaller and associated routines
|
||||
|
||||
void Marshaller::send_data(
|
||||
const void *data,
|
||||
int64_t length
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "send_data(%p, %lld)\n",
|
||||
data, length);
|
||||
memcpy(buffer_ptr, data, (size_t)length);
|
||||
buffer_ptr += length;
|
||||
tfr_size += length;
|
||||
}
|
||||
|
||||
void Marshaller::receive_data(
|
||||
void *data,
|
||||
int64_t length
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "receive_data(%p, %lld)\n",
|
||||
data, length);
|
||||
memcpy(data, buffer_ptr, (size_t)length);
|
||||
buffer_ptr += length;
|
||||
tfr_size += length;
|
||||
}
|
||||
|
||||
// Send function pointer
|
||||
void Marshaller::send_func_ptr(
|
||||
const void* data
|
||||
)
|
||||
{
|
||||
const char* name;
|
||||
size_t length;
|
||||
|
||||
if (data != 0) {
|
||||
name = __offload_funcs.find_name(data);
|
||||
if (name == 0) {
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
if (console_enabled > 2) {
|
||||
__offload_funcs.dump();
|
||||
}
|
||||
#endif // OFFLOAD_DEBUG > 0
|
||||
|
||||
LIBOFFLOAD_ERROR(c_send_func_ptr, data);
|
||||
exit(1);
|
||||
}
|
||||
length = strlen(name) + 1;
|
||||
}
|
||||
else {
|
||||
name = "";
|
||||
length = 1;
|
||||
}
|
||||
|
||||
memcpy(buffer_ptr, name, length);
|
||||
buffer_ptr += length;
|
||||
tfr_size += length;
|
||||
}
|
||||
|
||||
// Receive function pointer
|
||||
void Marshaller::receive_func_ptr(
|
||||
const void** data
|
||||
)
|
||||
{
|
||||
const char* name;
|
||||
size_t length;
|
||||
|
||||
name = (const char*) buffer_ptr;
|
||||
if (name[0] != '\0') {
|
||||
*data = __offload_funcs.find_addr(name);
|
||||
if (*data == 0) {
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
if (console_enabled > 2) {
|
||||
__offload_funcs.dump();
|
||||
}
|
||||
#endif // OFFLOAD_DEBUG > 0
|
||||
|
||||
LIBOFFLOAD_ERROR(c_receive_func_ptr, name);
|
||||
exit(1);
|
||||
}
|
||||
length = strlen(name) + 1;
|
||||
}
|
||||
else {
|
||||
*data = 0;
|
||||
length = 1;
|
||||
}
|
||||
|
||||
buffer_ptr += length;
|
||||
tfr_size += length;
|
||||
}
|
||||
|
||||
// End of the Marshaller and associated routines
|
||||
|
||||
extern void *OFFLOAD_MALLOC(
|
||||
size_t size,
|
||||
size_t align
|
||||
)
|
||||
{
|
||||
void *ptr;
|
||||
int err;
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "%s(%lld, %lld)\n", __func__, size, align);
|
||||
|
||||
if (align < sizeof(void*)) {
|
||||
align = sizeof(void*);
|
||||
}
|
||||
|
||||
ptr = _mm_malloc(size, align);
|
||||
if (ptr == NULL) {
|
||||
LIBOFFLOAD_ERROR(c_offload_malloc, size, align);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "%s returned %p\n", __func__, ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
|
@ -1,553 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief The parts of the runtime library common to host and target
|
||||
*/
|
||||
|
||||
#ifndef OFFLOAD_COMMON_H_INCLUDED
|
||||
#define OFFLOAD_COMMON_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "offload.h"
|
||||
#include "offload_table.h"
|
||||
#include "offload_trace.h"
|
||||
#include "offload_timer.h"
|
||||
#include "offload_util.h"
|
||||
#include "cean_util.h"
|
||||
#include "dv_util.h"
|
||||
#include "liboffload_error_codes.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// Use secure getenv if it's supported
|
||||
#ifdef HAVE_SECURE_GETENV
|
||||
#define getenv(x) secure_getenv(x)
|
||||
#elif HAVE___SECURE_GETENV
|
||||
#define getenv(x) __secure_getenv(x)
|
||||
#endif
|
||||
|
||||
// Offload Library versioning
|
||||
DLL_LOCAL extern int offload_version;
|
||||
DLL_LOCAL extern int offload_version_count;
|
||||
|
||||
// The debug routines
|
||||
|
||||
// Host console and file logging
|
||||
DLL_LOCAL extern int console_enabled;
|
||||
DLL_LOCAL extern int offload_report_level;
|
||||
|
||||
|
||||
DLL_LOCAL extern const char *prefix;
|
||||
DLL_LOCAL extern int offload_number;
|
||||
#if !HOST_LIBRARY
|
||||
DLL_LOCAL extern int mic_index;
|
||||
#define OFFLOAD_DO_TRACE (offload_report_level == 3)
|
||||
#else
|
||||
#define OFFLOAD_DO_TRACE (offload_report_enabled && (offload_report_level == 3))
|
||||
#endif
|
||||
|
||||
#if HOST_LIBRARY
|
||||
DLL_LOCAL void Offload_Report_Prolog(OffloadHostTimerData* timer_data);
|
||||
DLL_LOCAL void Offload_Report_Epilog(OffloadHostTimerData* timer_data);
|
||||
DLL_LOCAL void offload_report_free_data(OffloadHostTimerData * timer_data);
|
||||
DLL_LOCAL void Offload_Timer_Print(void);
|
||||
|
||||
#ifndef TARGET_WINNT
|
||||
#define OFFLOAD_DEBUG_INCR_OFLD_NUM() \
|
||||
__sync_add_and_fetch(&offload_number, 1)
|
||||
#else
|
||||
#define OFFLOAD_DEBUG_INCR_OFLD_NUM() \
|
||||
_InterlockedIncrement(reinterpret_cast<long*>(&offload_number))
|
||||
#endif
|
||||
|
||||
#define OFFLOAD_DEBUG_PRINT_TAG_PREFIX() \
|
||||
printf("%s: ", prefix);
|
||||
|
||||
#define OFFLOAD_DEBUG_PRINT_PREFIX() \
|
||||
printf("%s: ", prefix);
|
||||
#else
|
||||
#define OFFLOAD_DEBUG_PRINT_PREFIX() \
|
||||
printf("%s%d: ", prefix, mic_index);
|
||||
#endif // HOST_LIBRARY
|
||||
|
||||
#define OFFLOAD_TRACE(trace_level, ...) \
|
||||
if (console_enabled >= trace_level) { \
|
||||
OFFLOAD_DEBUG_PRINT_PREFIX(); \
|
||||
printf(__VA_ARGS__); \
|
||||
fflush(NULL); \
|
||||
}
|
||||
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
|
||||
#define OFFLOAD_DEBUG_TRACE(level, ...) \
|
||||
OFFLOAD_TRACE(level, __VA_ARGS__)
|
||||
|
||||
#define OFFLOAD_REPORT(level, offload_number, stage, ...) \
|
||||
if (OFFLOAD_DO_TRACE) { \
|
||||
offload_stage_print(stage, offload_number, __VA_ARGS__); \
|
||||
fflush(NULL); \
|
||||
}
|
||||
|
||||
#define OFFLOAD_DEBUG_TRACE_1(level, offload_number, stage, ...) \
|
||||
if (OFFLOAD_DO_TRACE) { \
|
||||
offload_stage_print(stage, offload_number, __VA_ARGS__); \
|
||||
fflush(NULL); \
|
||||
} \
|
||||
if (!OFFLOAD_DO_TRACE) { \
|
||||
OFFLOAD_TRACE(level, __VA_ARGS__) \
|
||||
}
|
||||
|
||||
#define OFFLOAD_DEBUG_DUMP_BYTES(level, a, b) \
|
||||
__dump_bytes(level, a, b)
|
||||
|
||||
DLL_LOCAL extern void __dump_bytes(
|
||||
int level,
|
||||
const void *data,
|
||||
int len
|
||||
);
|
||||
|
||||
#else
|
||||
|
||||
#define OFFLOAD_DEBUG_LOG(level, ...)
|
||||
#define OFFLOAD_DEBUG_DUMP_BYTES(level, a, b)
|
||||
|
||||
#endif
|
||||
|
||||
// Runtime interface
|
||||
|
||||
#define OFFLOAD_PREFIX(a) __offload_##a
|
||||
|
||||
#define OFFLOAD_MALLOC OFFLOAD_PREFIX(malloc)
|
||||
#define OFFLOAD_FREE(a) _mm_free(a)
|
||||
|
||||
// Forward functions
|
||||
|
||||
extern void *OFFLOAD_MALLOC(size_t size, size_t align);
|
||||
|
||||
// The Marshaller
|
||||
|
||||
// Flags describing an offload
|
||||
|
||||
//! Flags describing an offload
|
||||
union OffloadFlags{
|
||||
uint32_t flags;
|
||||
struct {
|
||||
uint32_t fortran_traceback : 1; //!< Fortran traceback requested
|
||||
uint32_t omp_async : 1; //!< OpenMP asynchronous offload
|
||||
} bits;
|
||||
};
|
||||
|
||||
//! \enum Indicator for the type of entry on an offload item list.
|
||||
enum OffloadItemType {
|
||||
c_data = 1, //!< Plain data
|
||||
c_data_ptr, //!< Pointer data
|
||||
c_func_ptr, //!< Function pointer
|
||||
c_void_ptr, //!< void*
|
||||
c_string_ptr, //!< C string
|
||||
c_dv, //!< Dope vector variable
|
||||
c_dv_data, //!< Dope-vector data
|
||||
c_dv_data_slice, //!< Dope-vector data's slice
|
||||
c_dv_ptr, //!< Dope-vector variable pointer
|
||||
c_dv_ptr_data, //!< Dope-vector pointer data
|
||||
c_dv_ptr_data_slice,//!< Dope-vector pointer data's slice
|
||||
c_cean_var, //!< CEAN variable
|
||||
c_cean_var_ptr, //!< Pointer to CEAN variable
|
||||
c_data_ptr_array, //!< Pointer to data pointer array
|
||||
c_extended_type, //!< Is used to extend OffloadItemType
|
||||
//!< Actual OffloadItemType is in the
|
||||
//!< structure VarDescExtendedType
|
||||
c_func_ptr_array, //!< Pointer to function pointer array
|
||||
c_void_ptr_array, //!< Pointer to void* pointer array
|
||||
c_string_ptr_array, //!< Pointer to char* pointer array
|
||||
c_data_ptr_ptr, //!< Pointer to pointer to data (struct member)
|
||||
c_func_ptr_ptr, //!< Pointer to pointer to function (struct member)
|
||||
c_void_ptr_ptr, //!< Pointer to pointer to void* (struct member)
|
||||
c_string_ptr_ptr, //!< Pointer to pointer to string (struct member)
|
||||
c_cean_var_ptr_ptr //!< Pointer to pointer to cean var (struct member)
|
||||
};
|
||||
|
||||
#define TYPE_IS_PTR_TO_PTR(t) ((t) == c_string_ptr_ptr || \
|
||||
(t) == c_data_ptr_ptr || \
|
||||
(t) == c_func_ptr_ptr || \
|
||||
(t) == c_void_ptr_ptr || \
|
||||
(t) == c_cean_var_ptr_ptr)
|
||||
|
||||
#define VAR_TYPE_IS_PTR(t) ((t) == c_string_ptr || \
|
||||
(t) == c_data_ptr || \
|
||||
(t) == c_cean_var_ptr || \
|
||||
(t) == c_dv_ptr || \
|
||||
TYPE_IS_PTR_TO_PTR(t))
|
||||
|
||||
#define VAR_TYPE_IS_SCALAR(t) ((t) == c_data || \
|
||||
(t) == c_void_ptr || \
|
||||
(t) == c_cean_var || \
|
||||
(t) == c_dv)
|
||||
|
||||
#define VAR_TYPE_IS_DV_DATA(t) ((t) == c_dv_data || \
|
||||
(t) == c_dv_ptr_data)
|
||||
|
||||
#define VAR_TYPE_IS_DV_DATA_SLICE(t) ((t) == c_dv_data_slice || \
|
||||
(t) == c_dv_ptr_data_slice)
|
||||
|
||||
//! \enum Specify direction to copy offloaded variable.
|
||||
enum OffloadParameterType {
|
||||
c_parameter_unknown = -1, //!< Unknown clause
|
||||
c_parameter_nocopy, //!< Variable listed in "nocopy" clause
|
||||
c_parameter_in, //!< Variable listed in "in" clause
|
||||
c_parameter_out, //!< Variable listed in "out" clause
|
||||
c_parameter_inout //!< Variable listed in "inout" clause
|
||||
};
|
||||
|
||||
|
||||
//! Flags describing an offloaded variable
|
||||
union varDescFlags {
|
||||
struct {
|
||||
//! source variable has persistent storage
|
||||
uint32_t is_static : 1;
|
||||
//! destination variable has persistent storage
|
||||
uint32_t is_static_dstn : 1;
|
||||
//! has length for c_dv && c_dv_ptr
|
||||
uint32_t has_length : 1;
|
||||
//! persisted local scalar is in stack buffer
|
||||
uint32_t is_stack_buf : 1;
|
||||
//! "targetptr" modifier used
|
||||
uint32_t targetptr : 1;
|
||||
//! "preallocated" modifier used
|
||||
uint32_t preallocated : 1;
|
||||
//! pointer to a pointer array
|
||||
uint32_t is_pointer : 1;
|
||||
|
||||
//! buffer address is sent in data
|
||||
uint32_t sink_addr : 1;
|
||||
//! alloc displacement is sent in data
|
||||
uint32_t alloc_disp : 1;
|
||||
//! source data is noncontiguous
|
||||
uint32_t is_noncont_src : 1;
|
||||
//! destination data is noncontiguous
|
||||
uint32_t is_noncont_dst : 1;
|
||||
|
||||
//! "OpenMP always" modifier used
|
||||
uint32_t always_copy : 1;
|
||||
//! "OpenMP delete" modifier used
|
||||
uint32_t always_delete : 1;
|
||||
//! structured data is noncontiguous
|
||||
uint32_t is_non_cont_struct : 1;
|
||||
//! CPU memory pinning/unpinning operation
|
||||
uint32_t pin : 1;
|
||||
//! Pointer to device memory
|
||||
uint32_t is_device_ptr : 1;
|
||||
//! Hostpointer with associated device pointer
|
||||
uint32_t use_device_ptr : 1;
|
||||
};
|
||||
uint32_t bits;
|
||||
};
|
||||
|
||||
//! An Offload Variable descriptor
|
||||
struct VarDesc {
|
||||
//! OffloadItemTypes of source and destination
|
||||
union {
|
||||
struct {
|
||||
uint8_t dst : 4; //!< OffloadItemType of destination
|
||||
uint8_t src : 4; //!< OffloadItemType of source
|
||||
};
|
||||
uint8_t bits;
|
||||
} type;
|
||||
|
||||
//! OffloadParameterType that describes direction of data transfer
|
||||
union {
|
||||
struct {
|
||||
uint8_t in : 1; //!< Set if IN or INOUT
|
||||
uint8_t out : 1; //!< Set if OUT or INOUT
|
||||
};
|
||||
uint8_t bits;
|
||||
} direction;
|
||||
|
||||
uint8_t alloc_if; //!< alloc_if modifier value
|
||||
uint8_t free_if; //!< free_if modifier value
|
||||
uint32_t align; //!< MIC alignment requested for pointer data
|
||||
//! Not used by compiler; set to 0
|
||||
/*! Used by runtime as offset to data from start of MIC buffer */
|
||||
uint32_t mic_offset;
|
||||
//! Flags describing this variable
|
||||
varDescFlags flags;
|
||||
//! Not used by compiler; set to 0
|
||||
/*! Used by runtime as offset to base from data stored in a buffer */
|
||||
int64_t offset;
|
||||
//! Element byte-size of data to be transferred
|
||||
/*! For dope-vector, the size of the dope-vector */
|
||||
int64_t size;
|
||||
union {
|
||||
//! Set to 0 for array expressions and dope-vectors
|
||||
/*! Set to 1 for scalars */
|
||||
/*! Set to value of length modifier for pointers */
|
||||
int64_t count;
|
||||
//! Displacement not used by compiler
|
||||
int64_t disp;
|
||||
};
|
||||
|
||||
//! This field not used by OpenMP 4.0
|
||||
/*! The alloc section expression in #pragma offload */
|
||||
union {
|
||||
void *alloc;
|
||||
int64_t ptr_arr_offset;
|
||||
};
|
||||
|
||||
//! This field not used by OpenMP 4.0
|
||||
/*! The into section expression in #pragma offload */
|
||||
/*! For c_data_ptr_array this is the into ptr array */
|
||||
void *into;
|
||||
|
||||
//! For an ordinary variable, address of the variable
|
||||
/*! For c_cean_var (C/C++ array expression),
|
||||
pointer to arr_desc, which is an array descriptor. */
|
||||
/*! For c_data_ptr_array (array of data pointers),
|
||||
pointer to ptr_array_descriptor,
|
||||
which is a descriptor for pointer array transfers. */
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
//! Auxiliary struct used when -g is enabled that holds variable names
|
||||
struct VarDesc2 {
|
||||
const char *sname; //!< Source name
|
||||
const char *dname; //!< Destination name (when "into" is used)
|
||||
};
|
||||
|
||||
/*! When the OffloadItemType is c_data_ptr_array
|
||||
the ptr field of the main descriptor points to this struct. */
|
||||
/*! The type in VarDesc1 merely says c_cean_data_ptr, but the pointer
|
||||
type can be c_data_ptr, c_func_ptr, c_void_ptr, or c_string_ptr.
|
||||
Therefore the actual pointer type is in the flags field of VarDesc3. */
|
||||
/*! If flag_align_is_array/flag_alloc_if_is_array/flag_free_if_is_array
|
||||
is 0 then alignment/alloc_if/free_if are specified in VarDesc1. */
|
||||
/*! If flag_align_is_array/flag_alloc_if_is_array/flag_free_if_is_array
|
||||
is 1 then align_array/alloc_if_array/free_if_array specify
|
||||
the set of alignment/alloc_if/free_if values. */
|
||||
/*! For the other fields, if neither the scalar nor the array flag
|
||||
is set, then that modifier was not specified. If the bits are set
|
||||
they specify which modifier was set and whether it was a
|
||||
scalar or an array expression. */
|
||||
struct VarDesc3
|
||||
{
|
||||
void *ptr_array; //!< Pointer to arr_desc of array of pointers
|
||||
void *align_array; //!< Scalar value or pointer to arr_desc
|
||||
void *alloc_if_array; //!< Scalar value or pointer to arr_desc
|
||||
void *free_if_array; //!< Scalar value or pointer to arr_desc
|
||||
void *extent_start; //!< Scalar value or pointer to arr_desc
|
||||
void *extent_elements; //!< Scalar value or pointer to arr_desc
|
||||
void *into_start; //!< Scalar value or pointer to arr_desc
|
||||
void *into_elements; //!< Scalar value or pointer to arr_desc
|
||||
void *alloc_start; //!< Scalar value or pointer to arr_desc
|
||||
void *alloc_elements; //!< Scalar value or pointer to arr_desc
|
||||
/*! Flags that describe the pointer type and whether each field
|
||||
is a scalar value or an array expression. */
|
||||
/*! First 6 bits are pointer array element type:
|
||||
c_data_ptr, c_func_ptr, c_void_ptr, c_string_ptr */
|
||||
/*! Then single bits specify: */
|
||||
/*! align_array is an array */
|
||||
/*! alloc_if_array is an array */
|
||||
/*! free_if_array is an array */
|
||||
/*! extent_start is a scalar expression */
|
||||
/*! extent_start is an array expression */
|
||||
/*! extent_elements is a scalar expression */
|
||||
/*! extent_elements is an array expression */
|
||||
/*! into_start is a scalar expression */
|
||||
/*! into_start is an array expression */
|
||||
/*! into_elements is a scalar expression */
|
||||
/*! into_elements is an array expression */
|
||||
/*! alloc_start is a scalar expression */
|
||||
/*! alloc_start is an array expression */
|
||||
/*! alloc_elements is a scalar expression */
|
||||
/*! alloc_elements is an array expression */
|
||||
uint32_t array_fields;
|
||||
};
|
||||
const int flag_align_is_array = 6;
|
||||
const int flag_alloc_if_is_array = 7;
|
||||
const int flag_free_if_is_array = 8;
|
||||
const int flag_extent_start_is_scalar = 9;
|
||||
const int flag_extent_start_is_array = 10;
|
||||
const int flag_extent_elements_is_scalar = 11;
|
||||
const int flag_extent_elements_is_array = 12;
|
||||
const int flag_into_start_is_scalar = 13;
|
||||
const int flag_into_start_is_array = 14;
|
||||
const int flag_into_elements_is_scalar = 15;
|
||||
const int flag_into_elements_is_array = 16;
|
||||
const int flag_alloc_start_is_scalar = 17;
|
||||
const int flag_alloc_start_is_array = 18;
|
||||
const int flag_alloc_elements_is_scalar = 19;
|
||||
const int flag_alloc_elements_is_array = 20;
|
||||
|
||||
//! Extended Variable Descriptor. Since VarDesc uses 16 bits for
|
||||
//! OffloadItemType, we have exceeded that limit, So any Type
|
||||
//! greater than 15 will have Type set in VarDesc as c_extended_type
|
||||
//! and this structure will be used to represent those Types.
|
||||
typedef struct VarDescExtendedType {
|
||||
|
||||
// Represents overflow of OffloadItemType
|
||||
uint32_t extended_type;
|
||||
|
||||
//! For extended_type
|
||||
//! address of the variable
|
||||
//! Future Types can point to other descriptors
|
||||
void *ptr;
|
||||
} VarDescExtendedType;
|
||||
|
||||
// The Marshaller
|
||||
class Marshaller
|
||||
{
|
||||
private:
|
||||
// Start address of buffer
|
||||
char *buffer_start;
|
||||
|
||||
// Current pointer within buffer
|
||||
char *buffer_ptr;
|
||||
|
||||
// Physical size of data sent (including flags)
|
||||
long long buffer_size;
|
||||
|
||||
// User data sent/received
|
||||
long long tfr_size;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Marshaller() :
|
||||
buffer_start(0), buffer_ptr(0),
|
||||
buffer_size(0), tfr_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Return count of user data sent/received
|
||||
long long get_tfr_size() const
|
||||
{
|
||||
return tfr_size;
|
||||
}
|
||||
|
||||
// Return pointer to buffer
|
||||
char *get_buffer_start() const
|
||||
{
|
||||
return buffer_start;
|
||||
}
|
||||
|
||||
// Return current size of data in buffer
|
||||
long long get_buffer_size() const
|
||||
{
|
||||
return buffer_size;
|
||||
}
|
||||
|
||||
// Set buffer pointer
|
||||
void init_buffer(
|
||||
char *d,
|
||||
long long s
|
||||
)
|
||||
{
|
||||
buffer_start = buffer_ptr = d;
|
||||
buffer_size = s;
|
||||
}
|
||||
|
||||
// Send data
|
||||
void send_data(
|
||||
const void *data,
|
||||
int64_t length
|
||||
);
|
||||
|
||||
// Receive data
|
||||
void receive_data(
|
||||
void *data,
|
||||
int64_t length
|
||||
);
|
||||
|
||||
// Send function pointer
|
||||
void send_func_ptr(
|
||||
const void* data
|
||||
);
|
||||
|
||||
// Receive function pointer
|
||||
void receive_func_ptr(
|
||||
const void** data
|
||||
);
|
||||
};
|
||||
|
||||
// End of the Marshaller
|
||||
|
||||
// The offloaded function descriptor.
|
||||
// Sent from host to target to specify which function to run.
|
||||
// Also, sets console and file tracing levels.
|
||||
struct FunctionDescriptor
|
||||
{
|
||||
// Input data size.
|
||||
long long in_datalen;
|
||||
|
||||
// Output data size.
|
||||
long long out_datalen;
|
||||
|
||||
// Whether trace is requested on console.
|
||||
// A value of 1 produces only function name and data sent/received.
|
||||
// Values > 1 produce copious trace information.
|
||||
uint8_t console_enabled;
|
||||
|
||||
// Flag controlling timing on the target side.
|
||||
// Values > 0 enable timing on sink.
|
||||
uint8_t timer_enabled;
|
||||
|
||||
int offload_report_level;
|
||||
int offload_number;
|
||||
|
||||
// number of variable descriptors
|
||||
int vars_num;
|
||||
|
||||
// inout data offset if data is passed as misc/return data
|
||||
// otherwise it should be zero.
|
||||
int data_offset;
|
||||
|
||||
// The name of the offloaded function
|
||||
char data[];
|
||||
};
|
||||
|
||||
// typedef OFFLOAD.
|
||||
// Pointer to OffloadDescriptor.
|
||||
typedef struct OffloadDescriptor *OFFLOAD;
|
||||
|
||||
// Use for setting affinity of a stream
|
||||
enum affinity_type {
|
||||
affinity_compact,
|
||||
affinity_scatter
|
||||
};
|
||||
struct affinity_spec {
|
||||
uint64_t sink_mask[16];
|
||||
int affinity_type;
|
||||
int num_cores;
|
||||
int num_threads;
|
||||
};
|
||||
|
||||
#endif // OFFLOAD_COMMON_H_INCLUDED
|
File diff suppressed because it is too large
Load diff
|
@ -1,724 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OFFLOAD_ENGINE_H_INCLUDED
|
||||
#define OFFLOAD_ENGINE_H_INCLUDED
|
||||
|
||||
#include <limits.h>
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "offload_common.h"
|
||||
#include "coi/coi_client.h"
|
||||
|
||||
#define SIGNAL_HAS_COMPLETED ((OffloadDescriptor *)-1)
|
||||
const int64_t no_stream = -1;
|
||||
|
||||
// Address range
|
||||
class MemRange {
|
||||
public:
|
||||
MemRange() : m_start(0), m_length(0) {}
|
||||
MemRange(const void *addr, uint64_t len) : m_start(addr), m_length(len) {}
|
||||
|
||||
const void* start() const {
|
||||
return m_start;
|
||||
}
|
||||
|
||||
const void* end() const {
|
||||
return static_cast<const char*>(m_start) + m_length;
|
||||
}
|
||||
|
||||
uint64_t length() const {
|
||||
return m_length;
|
||||
}
|
||||
|
||||
// returns true if given range overlaps with another one
|
||||
bool overlaps(const MemRange &o) const {
|
||||
// Two address ranges A[start, end) and B[start,end) overlap
|
||||
// if A.start < B.end and A.end > B.start.
|
||||
return start() < o.end() && end() > o.start();
|
||||
}
|
||||
|
||||
// returns true if given range contains the other range
|
||||
bool contains(const MemRange &o) const {
|
||||
return start() <= o.start() && o.end() <= end();
|
||||
}
|
||||
|
||||
private:
|
||||
const void* m_start;
|
||||
uint64_t m_length;
|
||||
};
|
||||
|
||||
// Data associated with a pointer variable
|
||||
class PtrData {
|
||||
public:
|
||||
PtrData(const void *addr, uint64_t len) :
|
||||
cpu_addr(addr, len), cpu_buf(0),
|
||||
mic_addr(0), alloc_disp(0), mic_buf(0), mic_offset(0),
|
||||
ref_count(0), is_static(false), is_omp_associate(false)
|
||||
{}
|
||||
|
||||
//
|
||||
// Copy constructor
|
||||
//
|
||||
PtrData(const PtrData& ptr):
|
||||
cpu_addr(ptr.cpu_addr), cpu_buf(ptr.cpu_buf),
|
||||
mic_addr(ptr.mic_addr), alloc_disp(ptr.alloc_disp),
|
||||
mic_buf(ptr.mic_buf), mic_offset(ptr.mic_offset),
|
||||
ref_count(ptr.ref_count), is_static(ptr.is_static),
|
||||
is_omp_associate(ptr.is_omp_associate),
|
||||
var_alloc_type(0)
|
||||
{}
|
||||
|
||||
bool operator<(const PtrData &o) const {
|
||||
// Variables are sorted by the CPU start address.
|
||||
// Overlapping memory ranges are considered equal.
|
||||
return (cpu_addr.start() < o.cpu_addr.start()) &&
|
||||
!cpu_addr.overlaps(o.cpu_addr);
|
||||
}
|
||||
|
||||
long add_reference() {
|
||||
if (is_omp_associate || (is_static && !var_alloc_type)) {
|
||||
return LONG_MAX;
|
||||
}
|
||||
#ifndef TARGET_WINNT
|
||||
return __sync_fetch_and_add(&ref_count, 1);
|
||||
#else // TARGET_WINNT
|
||||
return _InterlockedIncrement(&ref_count) - 1;
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
|
||||
long remove_reference() {
|
||||
if (is_omp_associate || (is_static && !var_alloc_type)) {
|
||||
return LONG_MAX;
|
||||
}
|
||||
#ifndef TARGET_WINNT
|
||||
return __sync_sub_and_fetch(&ref_count, 1);
|
||||
#else // TARGET_WINNT
|
||||
return _InterlockedDecrement(&ref_count);
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
|
||||
long get_reference() const {
|
||||
if (is_omp_associate || (is_static && !var_alloc_type)) {
|
||||
return LONG_MAX;
|
||||
}
|
||||
return ref_count;
|
||||
}
|
||||
|
||||
public:
|
||||
// CPU address range
|
||||
const MemRange cpu_addr;
|
||||
|
||||
// CPU and MIC buffers
|
||||
COIBUFFER cpu_buf;
|
||||
COIBUFFER mic_buf;
|
||||
|
||||
// placeholder for buffer address on mic
|
||||
uint64_t mic_addr;
|
||||
|
||||
uint64_t alloc_disp;
|
||||
|
||||
// additional offset to pointer data on MIC for improving bandwidth for
|
||||
// data which is not 4K aligned
|
||||
uint32_t mic_offset;
|
||||
|
||||
// if true buffers are created from static memory
|
||||
bool is_static;
|
||||
|
||||
// true if MIC buffer created by omp_target_associate
|
||||
bool is_omp_associate;
|
||||
|
||||
bool var_alloc_type;
|
||||
mutex_t alloc_ptr_data_lock;
|
||||
|
||||
private:
|
||||
// reference count for the entry
|
||||
long ref_count;
|
||||
};
|
||||
|
||||
typedef std::list<PtrData*> PtrDataList;
|
||||
|
||||
class PtrDataTable {
|
||||
public:
|
||||
typedef std::set<PtrData> PtrSet;
|
||||
|
||||
PtrData* find_ptr_data(const void *ptr) {
|
||||
m_ptr_lock.lock();
|
||||
PtrSet::iterator res = list.find(PtrData(ptr, 0));
|
||||
|
||||
m_ptr_lock.unlock();
|
||||
if (res == list.end()) {
|
||||
return 0;
|
||||
}
|
||||
return const_cast<PtrData*>(res.operator->());
|
||||
}
|
||||
|
||||
PtrData* insert_ptr_data(const void *ptr, uint64_t len, bool &is_new) {
|
||||
m_ptr_lock.lock();
|
||||
std::pair<PtrSet::iterator, bool> res =
|
||||
list.insert(PtrData(ptr, len));
|
||||
|
||||
PtrData* ptr_data = const_cast<PtrData*>(res.first.operator->());
|
||||
m_ptr_lock.unlock();
|
||||
|
||||
is_new = res.second;
|
||||
if (is_new) {
|
||||
// It's necessary to lock as soon as possible.
|
||||
// unlock must be done at call site of insert_ptr_data at
|
||||
// branch for is_new
|
||||
ptr_data->alloc_ptr_data_lock.lock();
|
||||
}
|
||||
return ptr_data;
|
||||
}
|
||||
|
||||
void remove_ptr_data(const void *ptr) {
|
||||
m_ptr_lock.lock();
|
||||
list.erase(PtrData(ptr, 0));
|
||||
m_ptr_lock.unlock();
|
||||
}
|
||||
private:
|
||||
|
||||
PtrSet list;
|
||||
mutex_t m_ptr_lock;
|
||||
};
|
||||
|
||||
// Data associated with automatic variable
|
||||
class AutoData {
|
||||
public:
|
||||
AutoData(const void *addr, uint64_t len) :
|
||||
cpu_addr(addr, len), ref_count(0)
|
||||
{}
|
||||
|
||||
bool operator<(const AutoData &o) const {
|
||||
// Variables are sorted by the CPU start address.
|
||||
// Overlapping memory ranges are considered equal.
|
||||
return (cpu_addr.start() < o.cpu_addr.start()) &&
|
||||
!cpu_addr.overlaps(o.cpu_addr);
|
||||
}
|
||||
|
||||
long add_reference() {
|
||||
#ifndef TARGET_WINNT
|
||||
return __sync_fetch_and_add(&ref_count, 1);
|
||||
#else // TARGET_WINNT
|
||||
return _InterlockedIncrement(&ref_count) - 1;
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
|
||||
long remove_reference() {
|
||||
#ifndef TARGET_WINNT
|
||||
return __sync_sub_and_fetch(&ref_count, 1);
|
||||
#else // TARGET_WINNT
|
||||
return _InterlockedDecrement(&ref_count);
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
|
||||
long nullify_reference() {
|
||||
#ifndef TARGET_WINNT
|
||||
return __sync_lock_test_and_set(&ref_count, 0);
|
||||
#else // TARGET_WINNT
|
||||
return _InterlockedExchange(&ref_count,0);
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
|
||||
long get_reference() const {
|
||||
return ref_count;
|
||||
}
|
||||
|
||||
public:
|
||||
// CPU address range
|
||||
const MemRange cpu_addr;
|
||||
|
||||
private:
|
||||
// reference count for the entry
|
||||
long ref_count;
|
||||
};
|
||||
|
||||
// Set of autimatic variables
|
||||
typedef std::set<AutoData> AutoSet;
|
||||
|
||||
// Target image data
|
||||
struct TargetImage
|
||||
{
|
||||
TargetImage(const char *_name, const void *_data, uint64_t _size,
|
||||
const char *_origin, uint64_t _offset) :
|
||||
name(_name), data(_data), size(_size),
|
||||
origin(_origin), offset(_offset)
|
||||
{}
|
||||
|
||||
// library name
|
||||
const char* name;
|
||||
|
||||
// contents and size
|
||||
const void* data;
|
||||
uint64_t size;
|
||||
|
||||
// file of origin and offset within that file
|
||||
const char* origin;
|
||||
uint64_t offset;
|
||||
};
|
||||
|
||||
typedef std::list<TargetImage> TargetImageList;
|
||||
|
||||
// dynamic library and Image associated with lib
|
||||
struct DynLib
|
||||
{
|
||||
DynLib(const char *_name, const void *_data,
|
||||
COILIBRARY _lib) :
|
||||
name(_name), data(_data), lib(_lib)
|
||||
{}
|
||||
// library name
|
||||
const char* name;
|
||||
|
||||
// contents
|
||||
const void* data;
|
||||
|
||||
COILIBRARY lib;
|
||||
};
|
||||
typedef std::list<DynLib> DynLibList;
|
||||
|
||||
// Data associated with persistent auto objects
|
||||
struct PersistData
|
||||
{
|
||||
PersistData(const void *addr, uint64_t routine_num,
|
||||
uint64_t size, uint64_t thread) :
|
||||
stack_cpu_addr(addr), routine_id(routine_num), thread_id(thread)
|
||||
{
|
||||
stack_ptr_data = new PtrData(0, size);
|
||||
}
|
||||
// 1-st key value - beginning of the stack at CPU
|
||||
const void * stack_cpu_addr;
|
||||
// 2-nd key value - identifier of routine invocation at CPU
|
||||
uint64_t routine_id;
|
||||
// 3-rd key value - thread identifier
|
||||
uint64_t thread_id;
|
||||
|
||||
// corresponded PtrData; only stack_ptr_data->mic_buf is used
|
||||
PtrData * stack_ptr_data;
|
||||
// used to get offset of the variable in stack buffer
|
||||
char * cpu_stack_addr;
|
||||
};
|
||||
|
||||
typedef std::list<PersistData> PersistDataList;
|
||||
|
||||
// Data associated with stream
|
||||
struct Stream
|
||||
{
|
||||
Stream(int device, int num_of_cpus) :
|
||||
m_number_of_cpus(num_of_cpus), m_pipeline(0), m_last_offload(0),
|
||||
m_device(device)
|
||||
{}
|
||||
~Stream() {
|
||||
if (m_pipeline) {
|
||||
COI::PipelineDestroy(m_pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
COIPIPELINE get_pipeline(void) {
|
||||
return(m_pipeline);
|
||||
}
|
||||
|
||||
int get_device(void) {
|
||||
return(m_device);
|
||||
}
|
||||
|
||||
int get_cpu_number(void) {
|
||||
return(m_number_of_cpus);
|
||||
}
|
||||
|
||||
void set_pipeline(COIPIPELINE pipeline) {
|
||||
m_pipeline = pipeline;
|
||||
}
|
||||
|
||||
OffloadDescriptor* get_last_offload(void) {
|
||||
return(m_last_offload);
|
||||
}
|
||||
|
||||
void set_last_offload(OffloadDescriptor* last_offload) {
|
||||
m_last_offload = last_offload;
|
||||
}
|
||||
|
||||
static Stream* find_stream(uint64_t handle, bool remove);
|
||||
|
||||
static _Offload_stream add_stream(int device, int number_of_cpus) {
|
||||
_Offload_stream result;
|
||||
m_stream_lock.lock();
|
||||
result = ++m_streams_count;
|
||||
all_streams[m_streams_count] = new Stream(device, number_of_cpus);
|
||||
m_stream_lock.unlock();
|
||||
return(result);
|
||||
}
|
||||
|
||||
static uint64_t get_streams_count() {
|
||||
return m_streams_count;
|
||||
}
|
||||
|
||||
typedef std::map<uint64_t, Stream*> StreamMap;
|
||||
|
||||
static uint64_t m_streams_count;
|
||||
static StreamMap all_streams;
|
||||
static mutex_t m_stream_lock;
|
||||
|
||||
int m_device;
|
||||
|
||||
// number of cpus
|
||||
int m_number_of_cpus;
|
||||
|
||||
// The pipeline associated with the stream
|
||||
COIPIPELINE m_pipeline;
|
||||
|
||||
// The last offload occured via the stream
|
||||
OffloadDescriptor* m_last_offload;
|
||||
|
||||
// Cpus used by the stream
|
||||
std::bitset<COI_MAX_HW_THREADS> m_stream_cpus;
|
||||
};
|
||||
|
||||
typedef std::map<uint64_t, Stream*> StreamMap;
|
||||
typedef std::bitset<COI_MAX_HW_THREADS> micLcpuMask;
|
||||
|
||||
// ordered by count double linked list of cpus used by streams
|
||||
typedef struct CpuEl{
|
||||
uint64_t count; // number of streams using the cpu
|
||||
struct CpuEl* prev; // cpu with the same or lesser count
|
||||
struct CpuEl* next; // cpu with the same or greater count
|
||||
} CpuEl;
|
||||
|
||||
// class representing a single engine
|
||||
struct Engine {
|
||||
friend void __offload_init_library_once(void);
|
||||
friend void __offload_fini_library(void);
|
||||
|
||||
#define CPU_INDEX(x) (x - m_cpus)
|
||||
#define check_result(res, tag, ...) \
|
||||
{ \
|
||||
if (res == COI_PROCESS_DIED) { \
|
||||
fini_process(true); \
|
||||
exit(1); \
|
||||
} \
|
||||
if (res != COI_SUCCESS) { \
|
||||
__liboffload_error_support(tag, __VA_ARGS__); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
int get_logical_index() const {
|
||||
return m_index;
|
||||
}
|
||||
|
||||
int get_physical_index() const {
|
||||
return m_physical_index;
|
||||
}
|
||||
|
||||
const COIPROCESS& get_process() const {
|
||||
return m_process;
|
||||
}
|
||||
|
||||
bool get_ready() {
|
||||
return m_ready;
|
||||
}
|
||||
|
||||
uint64_t get_thread_id(void);
|
||||
|
||||
// initialize device
|
||||
void init(void);
|
||||
|
||||
// unload library
|
||||
void unload_library(const void *data, const char *name);
|
||||
|
||||
// add new library
|
||||
void add_lib(const TargetImage &lib)
|
||||
{
|
||||
m_lock.lock();
|
||||
m_ready = false;
|
||||
m_images.push_back(lib);
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
COIRESULT compute(
|
||||
_Offload_stream stream,
|
||||
const std::list<COIBUFFER> &buffers,
|
||||
const void* data,
|
||||
uint16_t data_size,
|
||||
void* ret,
|
||||
uint16_t ret_size,
|
||||
uint32_t num_deps,
|
||||
const COIEVENT* deps,
|
||||
COIEVENT* event
|
||||
);
|
||||
|
||||
#ifdef MYO_SUPPORT
|
||||
// temporary workaround for blocking behavior for myoiLibInit/Fini calls
|
||||
void init_myo(COIEVENT *event) {
|
||||
COIRESULT res;
|
||||
res = COI::PipelineRunFunction(get_pipeline(),
|
||||
m_funcs[c_func_myo_init],
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
event);
|
||||
check_result(res, c_pipeline_run_func, m_index, res);
|
||||
}
|
||||
|
||||
void fini_myo(COIEVENT *event) {
|
||||
COIRESULT res;
|
||||
res = COI::PipelineRunFunction(get_pipeline(),
|
||||
m_funcs[c_func_myo_fini],
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
event);
|
||||
check_result(res, c_pipeline_run_func, m_index, res);
|
||||
}
|
||||
#endif // MYO_SUPPORT
|
||||
|
||||
//
|
||||
// Memory association table
|
||||
//
|
||||
PtrData* find_ptr_data(const void *ptr) {
|
||||
return m_ptr_set.find_ptr_data(ptr);
|
||||
}
|
||||
|
||||
PtrData* find_targetptr_data(const void *ptr) {
|
||||
return m_targetptr_set.find_ptr_data(ptr);
|
||||
}
|
||||
|
||||
PtrData* insert_ptr_data(const void *ptr, uint64_t len, bool &is_new) {
|
||||
return m_ptr_set.insert_ptr_data(ptr, len, is_new);
|
||||
}
|
||||
|
||||
PtrData* insert_targetptr_data(const void *ptr, uint64_t len,
|
||||
bool &is_new) {
|
||||
return m_targetptr_set.insert_ptr_data(ptr, len, is_new);
|
||||
}
|
||||
|
||||
void remove_ptr_data(const void *ptr) {
|
||||
m_ptr_set.remove_ptr_data(ptr);
|
||||
}
|
||||
|
||||
void remove_targetptr_data(const void *ptr) {
|
||||
m_targetptr_set.remove_ptr_data(ptr);
|
||||
}
|
||||
|
||||
//
|
||||
// Automatic variables
|
||||
//
|
||||
AutoData* find_auto_data(const void *ptr) {
|
||||
AutoSet &auto_vars = get_auto_vars();
|
||||
AutoSet::iterator res = auto_vars.find(AutoData(ptr, 0));
|
||||
if (res == auto_vars.end()) {
|
||||
return 0;
|
||||
}
|
||||
return const_cast<AutoData*>(res.operator->());
|
||||
}
|
||||
|
||||
AutoData* insert_auto_data(const void *ptr, uint64_t len) {
|
||||
AutoSet &auto_vars = get_auto_vars();
|
||||
std::pair<AutoSet::iterator, bool> res =
|
||||
auto_vars.insert(AutoData(ptr, len));
|
||||
return const_cast<AutoData*>(res.first.operator->());
|
||||
}
|
||||
|
||||
void remove_auto_data(const void *ptr) {
|
||||
get_auto_vars().erase(AutoData(ptr, 0));
|
||||
}
|
||||
|
||||
//
|
||||
// Signals
|
||||
//
|
||||
void add_signal(const void *signal, OffloadDescriptor *desc) {
|
||||
m_signal_lock.lock();
|
||||
m_signal_map[signal] = desc;
|
||||
m_signal_lock.unlock();
|
||||
}
|
||||
|
||||
OffloadDescriptor* find_signal(const void *signal, bool remove) {
|
||||
OffloadDescriptor *desc = 0;
|
||||
|
||||
m_signal_lock.lock();
|
||||
{
|
||||
SignalMap::iterator it = m_signal_map.find(signal);
|
||||
if (it != m_signal_map.end()) {
|
||||
desc = it->second;
|
||||
if (remove) {
|
||||
it->second = SIGNAL_HAS_COMPLETED;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_signal_lock.unlock();
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
void complete_signaled_ofld(const void *signal) {
|
||||
|
||||
m_signal_lock.lock();
|
||||
{
|
||||
SignalMap::iterator it = m_signal_map.find(signal);
|
||||
if (it != m_signal_map.end()) {
|
||||
it->second = SIGNAL_HAS_COMPLETED;
|
||||
}
|
||||
}
|
||||
m_signal_lock.unlock();
|
||||
}
|
||||
|
||||
void stream_destroy(_Offload_stream handle);
|
||||
|
||||
void move_cpu_el_after(CpuEl* cpu_what, CpuEl* cpu_after);
|
||||
void print_stream_cpu_list(const char *);
|
||||
|
||||
COIPIPELINE get_pipeline(_Offload_stream stream);
|
||||
|
||||
StreamMap get_stream_map() {
|
||||
return m_stream_map;
|
||||
}
|
||||
|
||||
// stop device process
|
||||
void fini_process(bool verbose);
|
||||
|
||||
// list of stacks active at the engine
|
||||
PersistDataList m_persist_list;
|
||||
|
||||
private:
|
||||
Engine() : m_index(-1), m_physical_index(-1), m_process(0), m_ready(false),
|
||||
m_proc_number(0), m_assigned_cpus(0), m_cpus(0), m_cpu_head(0)
|
||||
{}
|
||||
|
||||
~Engine() {
|
||||
m_ready = false;
|
||||
for (StreamMap::iterator it = m_stream_map.begin();
|
||||
it != m_stream_map.end(); it++) {
|
||||
Stream * stream = it->second;
|
||||
delete stream;
|
||||
}
|
||||
if (m_process != 0) {
|
||||
fini_process(false);
|
||||
}
|
||||
if (m_assigned_cpus) {
|
||||
delete m_assigned_cpus;
|
||||
}
|
||||
}
|
||||
|
||||
// set indexes
|
||||
void set_indexes(int logical_index, int physical_index) {
|
||||
m_index = logical_index;
|
||||
m_physical_index = physical_index;
|
||||
}
|
||||
|
||||
// set CPU mask
|
||||
void set_cpu_mask(micLcpuMask *cpu_mask)
|
||||
{
|
||||
m_assigned_cpus = cpu_mask;
|
||||
}
|
||||
|
||||
// start process on device
|
||||
void init_process();
|
||||
|
||||
void load_libraries(void);
|
||||
void init_ptr_data(void);
|
||||
|
||||
// performs library intialization on the device side
|
||||
pid_t init_device(void);
|
||||
|
||||
private:
|
||||
// get pipeline associated with a calling thread
|
||||
COIPIPELINE get_pipeline(void);
|
||||
|
||||
// get automatic vars set associated with the calling thread
|
||||
AutoSet& get_auto_vars(void);
|
||||
|
||||
// destructor for thread data
|
||||
static void destroy_thread_data(void *data);
|
||||
|
||||
private:
|
||||
typedef std::set<PtrData> PtrSet;
|
||||
typedef std::map<const void*, OffloadDescriptor*> SignalMap;
|
||||
|
||||
// device indexes
|
||||
int m_index;
|
||||
int m_physical_index;
|
||||
|
||||
// cpu mask
|
||||
micLcpuMask *m_assigned_cpus;
|
||||
|
||||
// number of COI pipes created for the engine
|
||||
long m_proc_number;
|
||||
|
||||
// process handle
|
||||
COIPROCESS m_process;
|
||||
|
||||
// If false, device either has not been initialized or new libraries
|
||||
// have been added.
|
||||
bool m_ready;
|
||||
mutex_t m_lock;
|
||||
|
||||
// List of libraries to be loaded
|
||||
TargetImageList m_images;
|
||||
|
||||
// var tables
|
||||
PtrDataTable m_ptr_set;
|
||||
PtrDataTable m_targetptr_set;
|
||||
|
||||
// signals
|
||||
SignalMap m_signal_map;
|
||||
mutex_t m_signal_lock;
|
||||
|
||||
// streams
|
||||
StreamMap m_stream_map;
|
||||
mutex_t m_stream_lock;
|
||||
int m_num_cores;
|
||||
int m_num_threads;
|
||||
CpuEl* m_cpus;
|
||||
CpuEl* m_cpu_head;
|
||||
|
||||
// List of dynamic libraries to be registred
|
||||
DynLibList m_dyn_libs;
|
||||
|
||||
// constants for accessing device function handles
|
||||
enum {
|
||||
c_func_compute = 0,
|
||||
#ifdef MYO_SUPPORT
|
||||
c_func_myo_init,
|
||||
c_func_myo_fini,
|
||||
#endif // MYO_SUPPORT
|
||||
c_func_init,
|
||||
c_func_var_table_size,
|
||||
c_func_var_table_copy,
|
||||
c_func_set_stream_affinity,
|
||||
c_funcs_total
|
||||
};
|
||||
static const char* m_func_names[c_funcs_total];
|
||||
|
||||
// device function handles
|
||||
COIFUNCTION m_funcs[c_funcs_total];
|
||||
|
||||
// int -> name mapping for device signals
|
||||
static const int c_signal_max = 32;
|
||||
static const char* c_signal_names[c_signal_max];
|
||||
};
|
||||
|
||||
#endif // OFFLOAD_ENGINE_H_INCLUDED
|
|
@ -1,384 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_env.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "offload_util.h"
|
||||
#include "liboffload_error_codes.h"
|
||||
|
||||
// for environment variables valid on all cards
|
||||
const int MicEnvVar::any_card = -1;
|
||||
|
||||
MicEnvVar::~MicEnvVar()
|
||||
{
|
||||
for (std::list<MicEnvVar::CardEnvVars*>::const_iterator
|
||||
it = card_spec_list.begin();
|
||||
it != card_spec_list.end(); it++) {
|
||||
CardEnvVars *card_data = *it;
|
||||
delete card_data;
|
||||
}
|
||||
}
|
||||
|
||||
MicEnvVar::VarValue::~VarValue()
|
||||
{
|
||||
free(env_var_value);
|
||||
}
|
||||
|
||||
MicEnvVar::CardEnvVars::~CardEnvVars()
|
||||
{
|
||||
for (std::list<MicEnvVar::VarValue*>::const_iterator it = env_vars.begin();
|
||||
it != env_vars.end(); it++) {
|
||||
VarValue *var_value = *it;
|
||||
delete var_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Searching for card in "card_spec_list" list with the same "number"
|
||||
|
||||
MicEnvVar::CardEnvVars* MicEnvVar::get_card(int number)
|
||||
{
|
||||
if (number == any_card) {
|
||||
return &common_vars;
|
||||
}
|
||||
for (std::list<MicEnvVar::CardEnvVars*>::const_iterator
|
||||
it = card_spec_list.begin();
|
||||
it != card_spec_list.end(); it++) {
|
||||
CardEnvVars *card_data = *it;
|
||||
if (card_data->card_number == number) {
|
||||
return card_data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Searching for environment variable in "env_var" list with the same name
|
||||
|
||||
MicEnvVar::VarValue* MicEnvVar::CardEnvVars::find_var(
|
||||
char* env_var_name,
|
||||
int env_var_name_length
|
||||
)
|
||||
{
|
||||
for (std::list<MicEnvVar::VarValue*>::const_iterator it = env_vars.begin();
|
||||
it != env_vars.end(); it++) {
|
||||
VarValue *var_value = *it;
|
||||
if (var_value->length == env_var_name_length &&
|
||||
!strncmp(var_value->env_var, env_var_name,
|
||||
env_var_name_length)) {
|
||||
return var_value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MicEnvVar::analyze_env_var(char *env_var_string)
|
||||
{
|
||||
char *env_var_name;
|
||||
char *env_var_def;
|
||||
int card_number;
|
||||
int env_var_name_length;
|
||||
MicEnvVarKind env_var_kind;
|
||||
|
||||
env_var_kind = get_env_var_kind(env_var_string,
|
||||
&card_number,
|
||||
&env_var_name,
|
||||
&env_var_name_length,
|
||||
&env_var_def);
|
||||
switch (env_var_kind) {
|
||||
case c_mic_var:
|
||||
case c_mic_card_var:
|
||||
add_env_var(card_number,
|
||||
env_var_name,
|
||||
env_var_name_length,
|
||||
env_var_def);
|
||||
break;
|
||||
case c_mic_card_env:
|
||||
mic_parse_env_var_list(card_number, env_var_def);
|
||||
break;
|
||||
case c_no_mic:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MicEnvVar::add_env_var(
|
||||
int card_number,
|
||||
char *env_var_name,
|
||||
int env_var_name_length,
|
||||
char *env_var_def
|
||||
)
|
||||
{
|
||||
VarValue *var;
|
||||
CardEnvVars *card;
|
||||
|
||||
// The case corresponds to common env var definition of kind
|
||||
// <mic-prefix>_<var>
|
||||
if (card_number == any_card) {
|
||||
card = &common_vars;
|
||||
}
|
||||
else {
|
||||
card = get_card(card_number);
|
||||
if (!card) {
|
||||
// definition for new card occurred
|
||||
card = new CardEnvVars(card_number);
|
||||
card_spec_list.push_back(card);
|
||||
}
|
||||
|
||||
}
|
||||
var = card->find_var(env_var_name, env_var_name_length);
|
||||
if (!var) {
|
||||
// put new env var definition in "env_var" list
|
||||
var = new VarValue(env_var_name, env_var_name_length, env_var_def);
|
||||
card->env_vars.push_back(var);
|
||||
}
|
||||
}
|
||||
|
||||
// The routine analyses string pointed by "env_var_string" argument
|
||||
// according to the following syntax:
|
||||
//
|
||||
// Specification of prefix for MIC environment variables
|
||||
// MIC_ENV_PREFIX=<mic-prefix>
|
||||
//
|
||||
// Setting single MIC environment variable
|
||||
// <mic-prefix>_<var>=<value>
|
||||
// <mic-prefix>_<card-number>_<var>=<value>
|
||||
|
||||
// Setting multiple MIC environment variables
|
||||
// <mic-prefix>_<card-number>_ENV=<env-vars>
|
||||
|
||||
MicEnvVarKind MicEnvVar::get_env_var_kind(
|
||||
char *env_var_string,
|
||||
int *card_number,
|
||||
char **env_var_name,
|
||||
int *env_var_name_length,
|
||||
char **env_var_def
|
||||
)
|
||||
{
|
||||
int len = strlen(prefix);
|
||||
char *c = env_var_string;
|
||||
int num = 0;
|
||||
bool card_is_set = false;
|
||||
|
||||
if (strncmp(c, prefix, len) != 0 || c[len] != '_') {
|
||||
return c_no_mic;
|
||||
}
|
||||
c += len + 1;
|
||||
|
||||
*card_number = any_card;
|
||||
if (isdigit(*c)) {
|
||||
while (isdigit (*c)) {
|
||||
num = (*c++ - '0') + (num * 10);
|
||||
}
|
||||
if (*c != '_') {
|
||||
return c_no_mic;
|
||||
}
|
||||
c++;
|
||||
*card_number = num;
|
||||
card_is_set = true;
|
||||
}
|
||||
if (!isalpha(*c)) {
|
||||
return c_no_mic;
|
||||
}
|
||||
*env_var_name = *env_var_def = c;
|
||||
if (strncmp(c, "ENV=", 4) == 0) {
|
||||
if (!card_is_set) {
|
||||
*env_var_name_length = 3;
|
||||
*env_var_name = *env_var_def = c;
|
||||
*env_var_def = strdup(*env_var_def);
|
||||
if (*env_var_def == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
return c_mic_var;
|
||||
}
|
||||
*env_var_def = c + strlen("ENV=");
|
||||
*env_var_def = strdup(*env_var_def);
|
||||
if (*env_var_def == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
return c_mic_card_env;
|
||||
}
|
||||
if (isalpha(*c)) {
|
||||
*env_var_name_length = 0;
|
||||
while (isalnum(*c) || *c == '_') {
|
||||
c++;
|
||||
(*env_var_name_length)++;
|
||||
}
|
||||
}
|
||||
if (*c != '=') {
|
||||
return c_no_mic;
|
||||
}
|
||||
*env_var_def = strdup(*env_var_def);
|
||||
if (*env_var_def == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
return card_is_set? c_mic_card_var : c_mic_var;
|
||||
}
|
||||
|
||||
// analysing <env-vars> in form:
|
||||
// <mic-prefix>_<card-number>_ENV=<env-vars>
|
||||
// where:
|
||||
//
|
||||
// <env-vars>:
|
||||
// <env-var>
|
||||
// <env-vars> | <env-var>
|
||||
//
|
||||
// <env-var>:
|
||||
// variable=value
|
||||
// variable="value"
|
||||
// variable=
|
||||
|
||||
void MicEnvVar::mic_parse_env_var_list(
|
||||
int card_number, char *env_vars_def_list)
|
||||
{
|
||||
char *c = env_vars_def_list;
|
||||
char *env_var_name;
|
||||
int env_var_name_length;
|
||||
char *env_var_def;
|
||||
bool var_is_quoted;
|
||||
|
||||
if (*c == '"') {
|
||||
c++;
|
||||
}
|
||||
while (*c != 0) {
|
||||
var_is_quoted = false;
|
||||
env_var_name = c;
|
||||
env_var_name_length = 0;
|
||||
if (isalpha(*c)) {
|
||||
while (isalnum(*c) || *c == '_') {
|
||||
c++;
|
||||
env_var_name_length++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LIBOFFLOAD_ERROR(c_mic_parse_env_var_list1);
|
||||
return;
|
||||
}
|
||||
if (*c != '=') {
|
||||
LIBOFFLOAD_ERROR(c_mic_parse_env_var_list2);
|
||||
return;
|
||||
}
|
||||
c++;
|
||||
|
||||
if (*c == '"') {
|
||||
var_is_quoted = true;
|
||||
c++;
|
||||
}
|
||||
// Environment variable values that contain | will need to be escaped.
|
||||
while (*c != 0 && *c != '|' &&
|
||||
(!var_is_quoted || *c != '"'))
|
||||
{
|
||||
// skip escaped symbol
|
||||
if (*c == '\\') {
|
||||
c++;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
if (var_is_quoted) {
|
||||
c++; // for "
|
||||
while (*c != 0 && *c != '|') {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
int sz = c - env_var_name;
|
||||
env_var_def = (char*)malloc(sz);
|
||||
if (env_var_def == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
memcpy(env_var_def, env_var_name, sz);
|
||||
env_var_def[sz] = 0;
|
||||
|
||||
if (*c == '|') {
|
||||
c++;
|
||||
while (*c != 0 && *c == ' ') {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
add_env_var(card_number,
|
||||
env_var_name,
|
||||
env_var_name_length,
|
||||
env_var_def);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all definitions for the card with number "card_num".
|
||||
// The returned result is vector of string pointers defining one
|
||||
// environment variable. The vector is terminated by NULL pointer.
|
||||
// In the beginning of the vector there are env vars defined as
|
||||
// <mic-prefix>_<card-number>_<var>=<value>
|
||||
// or
|
||||
// <mic-prefix>_<card-number>_ENV=<env-vars>
|
||||
// where <card-number> is equal to "card_num"
|
||||
// They are followed by definitions valid for any card
|
||||
// and absent in previous definitions.
|
||||
|
||||
char** MicEnvVar::create_environ_for_card(int card_num)
|
||||
{
|
||||
VarValue *var_value;
|
||||
VarValue *var_value_find;
|
||||
CardEnvVars *card_data = get_card(card_num);
|
||||
CardEnvVars *card_data_common;
|
||||
std::list<char*> new_env;
|
||||
char **rez;
|
||||
|
||||
if (!prefix) {
|
||||
return NULL;
|
||||
}
|
||||
// There is no personel env var definitions for the card with
|
||||
// number "card_num"
|
||||
if (!card_data) {
|
||||
return create_environ_for_card(any_card);
|
||||
}
|
||||
|
||||
for (std::list<MicEnvVar::VarValue*>::const_iterator
|
||||
it = card_data->env_vars.begin();
|
||||
it != card_data->env_vars.end(); it++) {
|
||||
var_value = *it;
|
||||
new_env.push_back(var_value->env_var_value);
|
||||
}
|
||||
|
||||
if (card_num != any_card) {
|
||||
card_data_common = get_card(any_card);
|
||||
for (std::list<MicEnvVar::VarValue*>::const_iterator
|
||||
it = card_data_common->env_vars.begin();
|
||||
it != card_data_common->env_vars.end(); it++) {
|
||||
var_value = *it;
|
||||
var_value_find = card_data->find_var(var_value->env_var,
|
||||
var_value->length);
|
||||
if (!var_value_find) {
|
||||
new_env.push_back(var_value->env_var_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int new_env_size = new_env.size();
|
||||
rez = (char**) malloc((new_env_size + 1) * sizeof(char*));
|
||||
if (rez == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
std::copy(new_env.begin(), new_env.end(), rez);
|
||||
rez[new_env_size] = 0;
|
||||
return rez;
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OFFLOAD_ENV_H_INCLUDED
|
||||
#define OFFLOAD_ENV_H_INCLUDED
|
||||
|
||||
#include <list>
|
||||
#include "offload_util.h"
|
||||
|
||||
// data structure and routines to parse MIC user environment and pass to MIC
|
||||
|
||||
enum MicEnvVarKind
|
||||
{
|
||||
c_no_mic, // not MIC env var
|
||||
c_mic_var, // for <mic-prefix>_<var>
|
||||
c_mic_card_var, // for <mic-prefix>_<card-number>_<var>
|
||||
c_mic_card_env // for <mic-prefix>_<card-number>_ENV
|
||||
};
|
||||
|
||||
struct DLL_LOCAL MicEnvVar {
|
||||
public:
|
||||
MicEnvVar() : prefix(0) {}
|
||||
~MicEnvVar();
|
||||
|
||||
void analyze_env_var(char *env_var_string);
|
||||
char** create_environ_for_card(int card_num);
|
||||
MicEnvVarKind get_env_var_kind(
|
||||
char *env_var_string,
|
||||
int *card_number,
|
||||
char **env_var_name,
|
||||
int *env_var_name_length,
|
||||
char **env_var_def
|
||||
);
|
||||
void add_env_var(
|
||||
int card_number,
|
||||
char *env_var_name,
|
||||
int env_var_name_length,
|
||||
char *env_var_def
|
||||
);
|
||||
|
||||
void set_prefix(const char *pref) {
|
||||
prefix = (pref && *pref != '\0') ? pref : 0;
|
||||
}
|
||||
|
||||
struct VarValue {
|
||||
public:
|
||||
char* env_var;
|
||||
int length;
|
||||
char* env_var_value;
|
||||
|
||||
VarValue(char* var, int ln, char* value)
|
||||
{
|
||||
env_var = var;
|
||||
length = ln;
|
||||
env_var_value = value;
|
||||
}
|
||||
~VarValue();
|
||||
};
|
||||
|
||||
struct CardEnvVars {
|
||||
public:
|
||||
|
||||
int card_number;
|
||||
std::list<struct VarValue*> env_vars;
|
||||
|
||||
CardEnvVars() { card_number = any_card; }
|
||||
CardEnvVars(int num) { card_number = num; }
|
||||
~CardEnvVars();
|
||||
|
||||
void add_new_env_var(int number, char *env_var, int length,
|
||||
char *env_var_value);
|
||||
VarValue* find_var(char* env_var_name, int env_var_name_length);
|
||||
};
|
||||
static const int any_card;
|
||||
|
||||
private:
|
||||
void mic_parse_env_var_list(int card_number, char *env_var_def);
|
||||
CardEnvVars* get_card(int number);
|
||||
|
||||
const char *prefix;
|
||||
std::list<struct CardEnvVars *> card_spec_list;
|
||||
CardEnvVars common_vars;
|
||||
};
|
||||
|
||||
#endif // OFFLOAD_ENV_H_INCLUDED
|
File diff suppressed because it is too large
Load diff
|
@ -1,541 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief The parts of the runtime library used only on the host
|
||||
*/
|
||||
|
||||
#ifndef OFFLOAD_HOST_H_INCLUDED
|
||||
#define OFFLOAD_HOST_H_INCLUDED
|
||||
|
||||
#ifndef TARGET_WINNT
|
||||
#include <unistd.h>
|
||||
#endif // TARGET_WINNT
|
||||
#include "offload_common.h"
|
||||
#include "offload_util.h"
|
||||
#include "offload_engine.h"
|
||||
#include "offload_env.h"
|
||||
#include "offload_orsl.h"
|
||||
#include "coi/coi_client.h"
|
||||
|
||||
// MIC engines.
|
||||
DLL_LOCAL extern Engine* mic_engines;
|
||||
DLL_LOCAL extern uint32_t mic_engines_total;
|
||||
|
||||
// DMA channel count used by COI and set via
|
||||
// OFFLOAD_DMA_CHANNEL_COUNT environment variable
|
||||
DLL_LOCAL extern uint32_t mic_dma_channel_count;
|
||||
|
||||
//! The target image is packed as follows.
|
||||
/*! 1. 8 bytes containing the size of the target binary */
|
||||
/*! 2. a null-terminated string which is the binary name */
|
||||
/*! 3. <size> number of bytes that are the contents of the image */
|
||||
/*! The address of symbol __offload_target_image
|
||||
is the address of this structure. */
|
||||
struct Image {
|
||||
int64_t size; //!< Size in bytes of the target binary name and contents
|
||||
char data[]; //!< The name and contents of the target image
|
||||
};
|
||||
|
||||
// The offload descriptor.
|
||||
class OffloadDescriptor
|
||||
{
|
||||
public:
|
||||
enum OmpAsyncLastEventType {
|
||||
c_last_not, // not last event
|
||||
c_last_write, // the last event that is write
|
||||
c_last_read, // the last event that is read
|
||||
c_last_runfunc // the last event that is runfunction
|
||||
};
|
||||
|
||||
OffloadDescriptor(
|
||||
int index,
|
||||
_Offload_status *status,
|
||||
bool is_mandatory,
|
||||
bool is_openmp,
|
||||
OffloadHostTimerData * timer_data
|
||||
) :
|
||||
m_device(mic_engines[index == -1 ? 0 : index % mic_engines_total]),
|
||||
m_is_mandatory(is_mandatory),
|
||||
m_is_openmp(is_openmp),
|
||||
m_inout_buf(0),
|
||||
m_func_desc(0),
|
||||
m_func_desc_size(0),
|
||||
m_num_in_dependencies(0),
|
||||
m_p_in_dependencies(0),
|
||||
m_in_deps(0),
|
||||
m_in_deps_total(0),
|
||||
m_in_deps_allocated(0),
|
||||
m_out_deps(0),
|
||||
m_out_deps_total(0),
|
||||
m_out_deps_allocated(0),
|
||||
m_vars(0),
|
||||
m_vars_extra(0),
|
||||
m_status(status),
|
||||
m_timer_data(timer_data),
|
||||
m_out_with_preallocated(false),
|
||||
m_preallocated_alloc(false),
|
||||
m_traceback_called(false),
|
||||
m_stream(-1),
|
||||
m_signal(0),
|
||||
m_has_signal(0),
|
||||
m_omp_async_last_event_type(c_last_not)
|
||||
{
|
||||
m_wait_all_devices = index == -1;
|
||||
}
|
||||
|
||||
~OffloadDescriptor()
|
||||
{
|
||||
if (m_in_deps != 0) {
|
||||
free(m_in_deps);
|
||||
}
|
||||
if (m_out_deps != 0) {
|
||||
free(m_out_deps);
|
||||
}
|
||||
if (m_func_desc != 0) {
|
||||
free(m_func_desc);
|
||||
}
|
||||
if (m_vars != 0) {
|
||||
free(m_vars);
|
||||
free(m_vars_extra);
|
||||
}
|
||||
}
|
||||
|
||||
bool offload(const char *name, bool is_empty,
|
||||
VarDesc *vars, VarDesc2 *vars2, int vars_total,
|
||||
const void **waits, int num_waits, const void **signal,
|
||||
int entry_id, const void *stack_addr,
|
||||
OffloadFlags offload_flags);
|
||||
|
||||
bool offload_finish(bool is_traceback);
|
||||
|
||||
bool is_signaled();
|
||||
|
||||
OffloadHostTimerData* get_timer_data() const {
|
||||
return m_timer_data;
|
||||
}
|
||||
|
||||
void set_stream(_Offload_stream stream) {
|
||||
m_stream = stream;
|
||||
}
|
||||
|
||||
_Offload_stream get_stream() {
|
||||
return(m_stream);
|
||||
}
|
||||
|
||||
Engine& get_device() {
|
||||
return m_device;
|
||||
}
|
||||
|
||||
void* get_signal() {
|
||||
return(m_signal);
|
||||
}
|
||||
|
||||
void set_signal(const void* signal) {
|
||||
m_has_signal = 1;
|
||||
m_signal = const_cast<void*>(signal);
|
||||
}
|
||||
|
||||
void cleanup();
|
||||
|
||||
uint32_t m_event_count;
|
||||
bool m_has_signal;
|
||||
|
||||
private:
|
||||
bool offload_wrap(const char *name, bool is_empty,
|
||||
VarDesc *vars, VarDesc2 *vars2, int vars_total,
|
||||
const void **waits, int num_waits, const void **signal,
|
||||
int entry_id, const void *stack_addr,
|
||||
OffloadFlags offload_flags);
|
||||
bool wait_dependencies(const void **waits, int num_waits,
|
||||
_Offload_stream stream);
|
||||
bool setup_descriptors(VarDesc *vars, VarDesc2 *vars2, int vars_total,
|
||||
int entry_id, const void *stack_addr);
|
||||
bool setup_misc_data(const char *name);
|
||||
bool send_pointer_data(bool is_async, void* info);
|
||||
bool send_noncontiguous_pointer_data(
|
||||
int i,
|
||||
PtrData* src_buf,
|
||||
PtrData* dst_buf,
|
||||
COIEVENT *event,
|
||||
uint64_t &sent_data,
|
||||
uint32_t in_deps_amount,
|
||||
COIEVENT *in_deps
|
||||
);
|
||||
bool receive_noncontiguous_pointer_data(
|
||||
int i,
|
||||
COIBUFFER dst_buf,
|
||||
COIEVENT *event,
|
||||
uint64_t &received_data,
|
||||
uint32_t in_deps_amount,
|
||||
COIEVENT *in_deps
|
||||
);
|
||||
|
||||
bool gather_copyin_data();
|
||||
|
||||
bool compute(void *);
|
||||
|
||||
bool receive_pointer_data(bool is_async, bool first_run, void * info);
|
||||
bool scatter_copyout_data();
|
||||
|
||||
bool find_ptr_data(PtrData* &ptr_data, void *base, int64_t disp,
|
||||
int64_t length, bool is_targptr,
|
||||
bool error_does_not_exist = true);
|
||||
|
||||
void find_device_ptr( int64_t* &device_ptr,
|
||||
void *host_ptr);
|
||||
|
||||
bool alloc_ptr_data(PtrData* &ptr_data, void *base, int64_t disp,
|
||||
int64_t length, int64_t alloc_disp, int align,
|
||||
bool is_targptr, bool is_prealloc, bool pin);
|
||||
bool create_preallocated_buffer(PtrData* ptr_data, void *base);
|
||||
bool init_static_ptr_data(PtrData *ptr_data);
|
||||
bool init_mic_address(PtrData *ptr_data);
|
||||
bool offload_stack_memory_manager(
|
||||
const void * stack_begin,
|
||||
int routine_id,
|
||||
int buf_size,
|
||||
int align,
|
||||
bool thread_specific_function_locals,
|
||||
bool *is_new);
|
||||
char *get_this_threads_cpu_stack_addr(
|
||||
const void * stack_begin,
|
||||
int routine_id,
|
||||
bool thread_specific_function_locals);
|
||||
PtrData *get_this_threads_mic_stack_addr(
|
||||
const void * stack_begin,
|
||||
int routine_id,
|
||||
bool thread_specific_function_locals);
|
||||
bool nullify_target_stack(COIBUFFER targ_buf, uint64_t size);
|
||||
|
||||
bool gen_var_descs_for_pointer_array(int i);
|
||||
|
||||
void get_stream_in_dependencies(uint32_t &in_deps_amount,
|
||||
COIEVENT* &in_deps);
|
||||
|
||||
void report_coi_error(error_types msg, COIRESULT res);
|
||||
_Offload_result translate_coi_error(COIRESULT res) const;
|
||||
|
||||
void setup_omp_async_info();
|
||||
|
||||
void setup_use_device_ptr(int i);
|
||||
|
||||
void register_event_call_back(void (*)(
|
||||
COIEVENT,
|
||||
const COIRESULT,
|
||||
const void*),
|
||||
const COIEVENT *event,
|
||||
const void *info);
|
||||
|
||||
void register_omp_event_call_back(const COIEVENT *event, const void *info);
|
||||
|
||||
private:
|
||||
typedef std::list<COIBUFFER> BufferList;
|
||||
|
||||
// extra data associated with each variable descriptor
|
||||
struct VarExtra {
|
||||
PtrData* src_data;
|
||||
PtrData* dst_data;
|
||||
AutoData* auto_data;
|
||||
int64_t cpu_disp;
|
||||
int64_t cpu_offset;
|
||||
void *alloc;
|
||||
union {
|
||||
CeanReadRanges *read_rng_src;
|
||||
NonContigDesc *noncont_desc;
|
||||
};
|
||||
CeanReadRanges *read_rng_dst;
|
||||
int64_t ptr_arr_offset;
|
||||
bool is_arr_ptr_el;
|
||||
OmpAsyncLastEventType omp_last_event_type;
|
||||
int64_t pointer_offset;
|
||||
uint16_t type_src;
|
||||
uint16_t type_dst;
|
||||
};
|
||||
|
||||
template<typename T> class ReadArrElements {
|
||||
public:
|
||||
ReadArrElements():
|
||||
ranges(NULL),
|
||||
el_size(sizeof(T)),
|
||||
offset(0),
|
||||
count(0),
|
||||
is_empty(true),
|
||||
base(NULL)
|
||||
{}
|
||||
|
||||
bool read_next(bool flag)
|
||||
{
|
||||
if (flag != 0) {
|
||||
if (is_empty) {
|
||||
if (ranges) {
|
||||
if (!get_next_range(ranges, &offset)) {
|
||||
// ranges are over
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// all contiguous elements are over
|
||||
else if (count != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
length_cur = size;
|
||||
}
|
||||
else {
|
||||
offset += el_size;
|
||||
}
|
||||
val = (T)get_el_value(base, offset, el_size);
|
||||
length_cur -= el_size;
|
||||
count++;
|
||||
is_empty = length_cur == 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
CeanReadRanges * ranges;
|
||||
T val;
|
||||
int el_size;
|
||||
int64_t size,
|
||||
offset,
|
||||
length_cur;
|
||||
bool is_empty;
|
||||
int count;
|
||||
char *base;
|
||||
};
|
||||
|
||||
// ptr_data for persistent auto objects
|
||||
PtrData* m_stack_ptr_data;
|
||||
PtrDataList m_destroy_stack;
|
||||
|
||||
// Engine
|
||||
Engine& m_device;
|
||||
|
||||
// true for offload_wait target(mic) stream(0)
|
||||
bool m_wait_all_devices;
|
||||
|
||||
// if true offload is mandatory
|
||||
bool m_is_mandatory;
|
||||
|
||||
// if true offload has openmp origin
|
||||
const bool m_is_openmp;
|
||||
|
||||
// The Marshaller for the inputs of the offloaded region.
|
||||
Marshaller m_in;
|
||||
|
||||
// The Marshaller for the outputs of the offloaded region.
|
||||
Marshaller m_out;
|
||||
|
||||
// List of buffers that are passed to dispatch call
|
||||
BufferList m_compute_buffers;
|
||||
|
||||
// List of buffers that need to be destroyed at the end of offload
|
||||
BufferList m_destroy_buffers;
|
||||
|
||||
// Variable descriptors
|
||||
VarDesc* m_vars;
|
||||
VarExtra* m_vars_extra;
|
||||
int m_vars_total;
|
||||
|
||||
// Pointer to a user-specified status variable
|
||||
_Offload_status *m_status;
|
||||
|
||||
// Function descriptor
|
||||
FunctionDescriptor* m_func_desc;
|
||||
uint32_t m_func_desc_size;
|
||||
|
||||
// Buffer for transferring copyin/copyout data
|
||||
COIBUFFER m_inout_buf;
|
||||
|
||||
|
||||
// Dependencies
|
||||
COIEVENT *m_in_deps;
|
||||
uint32_t m_in_deps_total;
|
||||
uint32_t m_in_deps_allocated;
|
||||
COIEVENT *m_out_deps;
|
||||
uint32_t m_out_deps_total;
|
||||
uint32_t m_out_deps_allocated;
|
||||
|
||||
// 2 variables defines input dependencies for current COI API.
|
||||
// The calls to routines as BufferWrite/PipelineRunFunction/BufferRead
|
||||
// is supposed to have input dependencies.
|
||||
// 2 variables below defines the number and vector of dependencies
|
||||
// in every current moment of offload.
|
||||
// So any phase of offload can use its values as input dependencies
|
||||
// for the COI API that the phase calls.
|
||||
// It means that all phases (of Write, RunFunction,Read) must keep
|
||||
// the variables correct to be used by following phase.
|
||||
// If some consequent offloads are connected (i.e. by the same stream)
|
||||
// the final 2 variables of the offload is used as initial inputs
|
||||
// for the next offload.
|
||||
uint32_t m_num_in_dependencies;
|
||||
COIEVENT *m_p_in_dependencies;
|
||||
|
||||
// Stream
|
||||
_Offload_stream m_stream;
|
||||
|
||||
// Signal
|
||||
void* m_signal;
|
||||
|
||||
// Timer data
|
||||
OffloadHostTimerData *m_timer_data;
|
||||
|
||||
// copyin/copyout data length
|
||||
uint64_t m_in_datalen;
|
||||
uint64_t m_out_datalen;
|
||||
|
||||
// a boolean value calculated in setup_descriptors. If true we need to do
|
||||
// a run function on the target. Otherwise it may be optimized away.
|
||||
bool m_need_runfunction;
|
||||
|
||||
// initialized value of m_need_runfunction;
|
||||
// is used to recognize offload_transfer
|
||||
bool m_initial_need_runfunction;
|
||||
|
||||
// a Boolean value set to true when OUT clauses with preallocated targetptr
|
||||
// is encountered to indicate that call receive_pointer_data needs to be
|
||||
// invoked again after call to scatter_copyout_data.
|
||||
bool m_out_with_preallocated;
|
||||
|
||||
// a Boolean value set to true if an alloc_if(1) is used with preallocated
|
||||
// targetptr to indicate the need to scatter_copyout_data even for
|
||||
// async offload
|
||||
bool m_preallocated_alloc;
|
||||
|
||||
// a Boolean value set to true if traceback routine is called
|
||||
bool m_traceback_called;
|
||||
|
||||
OmpAsyncLastEventType m_omp_async_last_event_type;
|
||||
};
|
||||
|
||||
// Initialization types for MIC
|
||||
enum OffloadInitType {
|
||||
c_init_on_start, // all devices before entering main
|
||||
c_init_on_offload, // single device before starting the first offload
|
||||
c_init_on_offload_all // all devices before starting the first offload
|
||||
};
|
||||
|
||||
// Determines if MIC code is an executable or a shared library
|
||||
extern "C" bool __offload_target_image_is_executable(const void *target_image);
|
||||
|
||||
// Initializes library and registers specified offload image.
|
||||
extern "C" bool __offload_register_image(const void* image);
|
||||
extern "C" void __offload_unregister_image(const void* image);
|
||||
|
||||
// Registers asynchronous task completion callback
|
||||
extern "C" void __offload_register_task_callback(void (*cb)(void *));
|
||||
|
||||
// Initializes offload runtime library.
|
||||
DLL_LOCAL extern int __offload_init_library(void);
|
||||
|
||||
// thread data for associating pipelines with threads
|
||||
DLL_LOCAL extern pthread_key_t mic_thread_key;
|
||||
|
||||
// location of offload_main executable
|
||||
// To be used if the main application has no offload and is not built
|
||||
// with -offload but dynamic library linked in has offload pragma
|
||||
DLL_LOCAL extern char* mic_device_main;
|
||||
|
||||
// Environment variables for devices
|
||||
DLL_LOCAL extern MicEnvVar mic_env_vars;
|
||||
|
||||
// CPU frequency
|
||||
DLL_LOCAL extern uint64_t cpu_frequency;
|
||||
|
||||
// LD_LIBRARY_PATH for KNC libraries
|
||||
DLL_LOCAL extern char* knc_library_path;
|
||||
|
||||
// LD_LIBRARY_PATH for KNL libraries
|
||||
DLL_LOCAL extern char* knl_library_path;
|
||||
|
||||
// stack size for target
|
||||
DLL_LOCAL extern uint32_t mic_stack_size;
|
||||
|
||||
// Preallocated memory size for buffers on MIC
|
||||
DLL_LOCAL extern uint64_t mic_buffer_size;
|
||||
|
||||
// Preallocated 4K page memory size for buffers on MIC
|
||||
DLL_LOCAL extern uint64_t mic_4k_buffer_size;
|
||||
|
||||
// Preallocated 2M page memory size for buffers on MIC
|
||||
DLL_LOCAL extern uint64_t mic_2m_buffer_size;
|
||||
|
||||
// Setting controlling inout proxy
|
||||
DLL_LOCAL extern bool mic_proxy_io;
|
||||
DLL_LOCAL extern char* mic_proxy_fs_root;
|
||||
|
||||
// Threshold for creating buffers with large pages
|
||||
DLL_LOCAL extern uint64_t __offload_use_2mb_buffers;
|
||||
|
||||
// offload initialization type
|
||||
DLL_LOCAL extern OffloadInitType __offload_init_type;
|
||||
|
||||
// Device number to offload to when device is not explicitly specified.
|
||||
DLL_LOCAL extern int __omp_device_num;
|
||||
|
||||
// target executable
|
||||
DLL_LOCAL extern TargetImage* __target_exe;
|
||||
|
||||
// is true if last loaded image is dll
|
||||
DLL_LOCAL extern bool __current_image_is_dll;
|
||||
// is true if myo library is loaded when dll is loaded
|
||||
DLL_LOCAL extern bool __myo_init_in_so;
|
||||
|
||||
// IDB support
|
||||
|
||||
// Called by the offload runtime after initialization of offload infrastructure
|
||||
// has been completed.
|
||||
extern "C" void __dbg_target_so_loaded();
|
||||
|
||||
// Called by the offload runtime when the offload infrastructure is about to be
|
||||
// shut down, currently at application exit.
|
||||
extern "C" void __dbg_target_so_unloaded();
|
||||
|
||||
// Null-terminated string containing path to the process image of the hosting
|
||||
// application (offload_main)
|
||||
#define MAX_TARGET_NAME 512
|
||||
extern "C" char __dbg_target_exe_name[MAX_TARGET_NAME];
|
||||
|
||||
// Integer specifying the process id
|
||||
extern "C" pid_t __dbg_target_so_pid;
|
||||
|
||||
// Integer specifying the 0-based device number
|
||||
extern "C" int __dbg_target_id;
|
||||
|
||||
// Set to non-zero by the host-side debugger to enable offload debugging
|
||||
// support
|
||||
extern "C" int __dbg_is_attached;
|
||||
|
||||
// Major version of the debugger support API
|
||||
extern "C" const int __dbg_api_major_version;
|
||||
|
||||
// Minor version of the debugger support API
|
||||
extern "C" const int __dbg_api_minor_version;
|
||||
|
||||
#endif // OFFLOAD_HOST_H_INCLUDED
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief Iterator of Variable tables list used by the runtime library
|
||||
*/
|
||||
|
||||
#ifndef OFFLOAD_ITERATOR_H_INCLUDED
|
||||
#define OFFLOAD_ITERATOR_H_INCLUDED
|
||||
|
||||
#include <iterator>
|
||||
#include "offload_table.h"
|
||||
|
||||
// The following class is for iteration over var table.
|
||||
// It was extracted and moved to this offload_iterator.h file from offload_table.h
|
||||
// to solve the problem with compiling with VS 2010. The problem was in incompatibility
|
||||
// of STL objects in VS 2010 with ones in later VS versions.
|
||||
|
||||
// var table list iterator
|
||||
class Iterator : public std::iterator<std::input_iterator_tag,
|
||||
VarTable::Entry> {
|
||||
public:
|
||||
Iterator() : m_node(0), m_entry(0) {}
|
||||
|
||||
explicit Iterator(TableList<VarTable>::Node *node) {
|
||||
new_node(node);
|
||||
}
|
||||
|
||||
Iterator& operator++() {
|
||||
if (m_entry != 0) {
|
||||
m_entry++;
|
||||
while (m_entry->name == 0) {
|
||||
m_entry++;
|
||||
}
|
||||
if (m_entry->name == reinterpret_cast<const char*>(-1)) {
|
||||
new_node(m_node->next);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Iterator &other) const {
|
||||
return m_entry == other.m_entry;
|
||||
}
|
||||
|
||||
bool operator!=(const Iterator &other) const {
|
||||
return m_entry != other.m_entry;
|
||||
}
|
||||
|
||||
const VarTable::Entry* operator*() const {
|
||||
return m_entry;
|
||||
}
|
||||
|
||||
private:
|
||||
void new_node(TableList<VarTable>::Node *node) {
|
||||
m_node = node;
|
||||
m_entry = 0;
|
||||
while (m_node != 0) {
|
||||
m_entry = m_node->table.entries;
|
||||
while (m_entry->name == 0) {
|
||||
m_entry++;
|
||||
}
|
||||
if (m_entry->name != reinterpret_cast<const char*>(-1)) {
|
||||
break;
|
||||
}
|
||||
m_node = m_node->next;
|
||||
m_entry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
TableList<VarTable>::Node *m_node;
|
||||
const VarTable::Entry *m_entry;
|
||||
};
|
||||
|
||||
#endif // OFFLOAD_ITERATOR_H_INCLUDED
|
File diff suppressed because it is too large
Load diff
|
@ -1,736 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <omp.h>
|
||||
#include "offload.h"
|
||||
#include "compiler_if_target.h"
|
||||
|
||||
// OpenMP API
|
||||
|
||||
void omp_set_default_device(int num) __GOMP_NOTHROW
|
||||
{
|
||||
}
|
||||
|
||||
int omp_get_default_device(void) __GOMP_NOTHROW
|
||||
{
|
||||
return mic_index;
|
||||
}
|
||||
|
||||
int omp_get_num_devices() __GOMP_NOTHROW
|
||||
{
|
||||
return mic_engines_total;
|
||||
}
|
||||
|
||||
// OpenMP 4.5 APIs
|
||||
|
||||
// COI supports 3-dim multiD transfers
|
||||
#define MAX_ARRAY_RANK 3
|
||||
|
||||
DLL_LOCAL void omp_target_alloc_target(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[2] = {0};
|
||||
size_t size;
|
||||
void* memory;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &size;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_out;
|
||||
vars[1].ptr = &memory;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 2, vars, NULL);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_alloc(%lld)\n", size);
|
||||
// We do not check for malloc returning NULL because the
|
||||
// specification of this API includes the possibility of failure.
|
||||
// The user will check the returned result
|
||||
memory = malloc(size);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_alloc allocated at %p\n", memory);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_target_free_target(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
void* memory;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &memory;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_free(%p)\n", memory);
|
||||
free(memory);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_free freed\n");
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_target_memcpy_target(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[3] = {0};
|
||||
void* dst;
|
||||
void* src;
|
||||
size_t length;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &dst;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_in;
|
||||
vars[1].ptr = &src;
|
||||
|
||||
vars[2].type.src = c_data;
|
||||
vars[2].type.dst = c_data;
|
||||
vars[2].direction.bits = c_parameter_in;
|
||||
vars[2].ptr = &length;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 3, vars, NULL);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_memcpy(%p, %p, %lld)\n",
|
||||
dst, src, length);
|
||||
memcpy(dst, src, length);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_memcpy done\n");
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
static size_t bytesize_at_this_dimension(
|
||||
size_t element_size,
|
||||
int num_dims,
|
||||
const size_t* dimensions
|
||||
)
|
||||
{
|
||||
if (num_dims > 1) {
|
||||
return dimensions[1] *
|
||||
bytesize_at_this_dimension(
|
||||
element_size, num_dims-1, dimensions+1);
|
||||
} else {
|
||||
return element_size;
|
||||
}
|
||||
}
|
||||
|
||||
static void memcpy_rect(
|
||||
char *dst,
|
||||
char *src,
|
||||
size_t element_size,
|
||||
int num_dims,
|
||||
const size_t *volume,
|
||||
const size_t *dst_offsets,
|
||||
const size_t *src_offsets,
|
||||
const size_t *dst_dimensions,
|
||||
const size_t *src_dimensions
|
||||
)
|
||||
{
|
||||
if (num_dims > 1) {
|
||||
int count = volume[0];
|
||||
int dst_index = dst_offsets[0];
|
||||
int src_index = src_offsets[0];
|
||||
size_t dst_element_size =
|
||||
bytesize_at_this_dimension(element_size, num_dims, dst_dimensions);
|
||||
size_t src_element_size =
|
||||
bytesize_at_this_dimension(element_size, num_dims, src_dimensions);
|
||||
for (; count>0; dst_index++, src_index++, count--) {
|
||||
memcpy_rect(dst+dst_element_size*dst_index,
|
||||
src+src_element_size*src_index,
|
||||
element_size, num_dims-1, volume+1,
|
||||
dst_offsets+1, src_offsets+1,
|
||||
dst_dimensions+1, src_dimensions+1);
|
||||
}
|
||||
} else {
|
||||
memcpy(dst+dst_offsets[0]*element_size,
|
||||
src+src_offsets[0]*element_size,
|
||||
element_size * volume[0]);
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_target_memcpy_rect_target(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
struct parameters {
|
||||
void *dst;
|
||||
void *src;
|
||||
size_t element_size;
|
||||
int num_dims;
|
||||
size_t array_info[MAX_ARRAY_RANK*5];
|
||||
} parameters;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = ¶meters;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_memcpy_rect(%p, %p, %lld, %d)\n",
|
||||
parameters.dst, parameters.src,
|
||||
parameters.element_size, parameters.num_dims);
|
||||
memcpy_rect(
|
||||
(char*)parameters.dst, (char*)parameters.src, parameters.element_size,
|
||||
parameters.num_dims,
|
||||
¶meters.array_info[0],
|
||||
¶meters.array_info[parameters.num_dims],
|
||||
¶meters.array_info[parameters.num_dims*2],
|
||||
¶meters.array_info[parameters.num_dims*3],
|
||||
¶meters.array_info[parameters.num_dims*4]);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "omp_target_memcpy_rect done\n");
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
// End of OpenMP 4.5 APIs
|
||||
|
||||
|
||||
// OpenMP API wrappers
|
||||
|
||||
static void omp_send_int_to_host(
|
||||
void *ofld_,
|
||||
int setting
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_out;
|
||||
vars[0].ptr = &setting;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
static int omp_get_int_from_host(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
int setting;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &setting;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_num_threads_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int num_threads;
|
||||
|
||||
num_threads = omp_get_int_from_host(ofld);
|
||||
omp_set_num_threads(num_threads);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_get_max_threads_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int num_threads;
|
||||
|
||||
num_threads = omp_get_max_threads();
|
||||
omp_send_int_to_host(ofld, num_threads);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_get_num_procs_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int num_procs;
|
||||
|
||||
num_procs = omp_get_num_procs();
|
||||
omp_send_int_to_host(ofld, num_procs);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_dynamic_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int dynamic;
|
||||
|
||||
dynamic = omp_get_int_from_host(ofld);
|
||||
omp_set_dynamic(dynamic);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_get_dynamic_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int dynamic;
|
||||
|
||||
dynamic = omp_get_dynamic();
|
||||
omp_send_int_to_host(ofld, dynamic);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_nested_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int nested;
|
||||
|
||||
nested = omp_get_int_from_host(ofld);
|
||||
omp_set_nested(nested);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_get_nested_lrb(
|
||||
void *ofld
|
||||
)
|
||||
{
|
||||
int nested;
|
||||
|
||||
nested = omp_get_nested();
|
||||
omp_send_int_to_host(ofld, nested);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_schedule_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[2] = {0};
|
||||
omp_sched_t kind;
|
||||
int modifier;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &kind;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_in;
|
||||
vars[1].ptr = &modifier;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 2, vars, NULL);
|
||||
omp_set_schedule(kind, modifier);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_get_schedule_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[2] = {0};
|
||||
omp_sched_t kind;
|
||||
int modifier;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_out;
|
||||
vars[0].ptr = &kind;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_out;
|
||||
vars[1].ptr = &modifier;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 2, vars, NULL);
|
||||
omp_get_schedule(&kind, &modifier);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
// lock API functions
|
||||
|
||||
DLL_LOCAL void omp_init_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_out;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_init_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_destroy_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_destroy_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_set_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_unset_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_unset_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_test_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[2] = {0};
|
||||
omp_lock_target_t lock;
|
||||
int result;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_out;
|
||||
vars[1].ptr = &result;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 2, vars, NULL);
|
||||
result = omp_test_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
// nested lock API functions
|
||||
|
||||
DLL_LOCAL void omp_init_nest_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_nest_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_out;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_init_nest_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_destroy_nest_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_nest_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_in;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_destroy_nest_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_set_nest_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_nest_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_set_nest_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_unset_nest_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[1] = {0};
|
||||
omp_nest_lock_target_t lock;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 1, vars, NULL);
|
||||
omp_unset_nest_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
DLL_LOCAL void omp_test_nest_lock_lrb(
|
||||
void *ofld_
|
||||
)
|
||||
{
|
||||
OFFLOAD ofld = (OFFLOAD) ofld_;
|
||||
VarDesc vars[2] = {0};
|
||||
omp_nest_lock_target_t lock;
|
||||
int result;
|
||||
|
||||
vars[0].type.src = c_data;
|
||||
vars[0].type.dst = c_data;
|
||||
vars[0].direction.bits = c_parameter_inout;
|
||||
vars[0].ptr = &lock;
|
||||
|
||||
vars[1].type.src = c_data;
|
||||
vars[1].type.dst = c_data;
|
||||
vars[1].direction.bits = c_parameter_out;
|
||||
vars[1].ptr = &result;
|
||||
|
||||
OFFLOAD_TARGET_ENTER(ofld, 2, vars, NULL);
|
||||
result = omp_test_nest_lock(&lock.lock);
|
||||
OFFLOAD_TARGET_LEAVE(ofld);
|
||||
}
|
||||
|
||||
// Target-side stubs for the host functions (to avoid unresolveds)
|
||||
// These are needed for the offloadm table
|
||||
|
||||
void omp_set_num_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
int omp_get_max_threads_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int omp_get_num_procs_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void omp_set_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
int omp_get_dynamic_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void omp_set_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
int num_threads
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
int omp_get_nested_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void omp_set_schedule_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_sched_t kind,
|
||||
int modifier
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_get_schedule_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_sched_t *kind,
|
||||
int *modifier
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_init_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_destroy_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_set_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_unset_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
int omp_test_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void omp_init_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_destroy_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_set_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void omp_unset_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
int omp_test_nest_lock_target(
|
||||
TARGET_TYPE target_type,
|
||||
int target_number,
|
||||
omp_nest_lock_target_t *lock
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_orsl.h"
|
||||
#include <stdlib.h>
|
||||
#include "offload_host.h"
|
||||
#include "orsl-lite/include/orsl-lite.h"
|
||||
|
||||
namespace ORSL {
|
||||
|
||||
static bool is_enabled = false;
|
||||
static const ORSLTag my_tag = (const ORSLTag) "Offload";
|
||||
|
||||
void init()
|
||||
{
|
||||
const char *env_var = getenv("OFFLOAD_ENABLE_ORSL");
|
||||
if (env_var != 0 && *env_var != '\0') {
|
||||
int64_t new_val;
|
||||
if (__offload_parse_int_string(env_var, new_val)) {
|
||||
is_enabled = new_val;
|
||||
}
|
||||
else {
|
||||
LIBOFFLOAD_ERROR(c_invalid_env_var_int_value,
|
||||
"OFFLOAD_ENABLE_ORSL");
|
||||
}
|
||||
}
|
||||
|
||||
if (is_enabled) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "ORSL is enabled\n");
|
||||
}
|
||||
else {
|
||||
OFFLOAD_DEBUG_TRACE(2, "ORSL is disabled\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool reserve(int device)
|
||||
{
|
||||
if (is_enabled) {
|
||||
int pnum = mic_engines[device].get_physical_index();
|
||||
ORSLBusySet bset;
|
||||
|
||||
bset.type = BUSY_SET_FULL;
|
||||
if (ORSLReserve(1, &pnum, &bset, my_tag) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool try_reserve(int device)
|
||||
{
|
||||
if (is_enabled) {
|
||||
int pnum = mic_engines[device].get_physical_index();
|
||||
ORSLBusySet bset;
|
||||
|
||||
bset.type = BUSY_SET_FULL;
|
||||
if (ORSLTryReserve(1, &pnum, &bset, my_tag) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void release(int device)
|
||||
{
|
||||
if (is_enabled) {
|
||||
int pnum = mic_engines[device].get_physical_index();
|
||||
ORSLBusySet bset;
|
||||
|
||||
bset.type = BUSY_SET_FULL;
|
||||
if (ORSLRelease(1, &pnum, &bset, my_tag) != 0) {
|
||||
// should never get here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ORSL
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_util.h"
|
||||
|
||||
#ifndef OFFLOAD_ORSL_H_INCLUDED
|
||||
#define OFFLOAD_ORSL_H_INCLUDED
|
||||
|
||||
// ORSL interface
|
||||
namespace ORSL {
|
||||
|
||||
DLL_LOCAL extern void init();
|
||||
|
||||
DLL_LOCAL extern bool reserve(int device);
|
||||
DLL_LOCAL extern bool try_reserve(int device);
|
||||
DLL_LOCAL extern void release(int device);
|
||||
|
||||
} // namespace ORSL
|
||||
|
||||
#endif // OFFLOAD_ORSL_H_INCLUDED
|
|
@ -1,671 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_table.h"
|
||||
#include "offload_common.h"
|
||||
|
||||
// Offload Library versioning
|
||||
// We initialize version to OFFLOAD_VERSION_16
|
||||
// 15.0 application downgrades this to 1500 for MYO to use the older version.
|
||||
// 15.0 pragma works without needing version-specific code.
|
||||
// 16.0-U2 added a call from ofldbegin.cpp to set the version explicitly.
|
||||
// Pre-16.0-U2 application will find pre-initialized version number as 1600.
|
||||
// Post 16.0-U2 application will set its own version explicitly.
|
||||
int offload_version = OFFLOAD_VERSION_16;
|
||||
int offload_version_count = 0;
|
||||
|
||||
#if !HOST_LIBRARY
|
||||
// Predefined offload entries
|
||||
extern void omp_set_num_threads_lrb(void*);
|
||||
extern void omp_get_max_threads_lrb(void*);
|
||||
extern void omp_get_num_procs_lrb(void*);
|
||||
extern void omp_set_dynamic_lrb(void*);
|
||||
extern void omp_get_dynamic_lrb(void*);
|
||||
extern void omp_set_nested_lrb(void*);
|
||||
extern void omp_get_nested_lrb(void*);
|
||||
extern void omp_set_schedule_lrb(void*);
|
||||
extern void omp_get_schedule_lrb(void*);
|
||||
|
||||
extern void omp_init_lock_lrb(void*);
|
||||
extern void omp_destroy_lock_lrb(void*);
|
||||
extern void omp_set_lock_lrb(void*);
|
||||
extern void omp_unset_lock_lrb(void*);
|
||||
extern void omp_test_lock_lrb(void*);
|
||||
|
||||
extern void omp_init_nest_lock_lrb(void*);
|
||||
extern void omp_destroy_nest_lock_lrb(void*);
|
||||
extern void omp_set_nest_lock_lrb(void*);
|
||||
extern void omp_unset_nest_lock_lrb(void*);
|
||||
extern void omp_test_nest_lock_lrb(void*);
|
||||
|
||||
// OpenMP 4.5 APIs
|
||||
extern void omp_target_alloc_target(void*);
|
||||
extern void omp_target_free_target(void*);
|
||||
extern void omp_target_memcpy_target(void*);
|
||||
extern void omp_target_memcpy_rect_target(void*);
|
||||
|
||||
// Predefined entries on the target side
|
||||
static FuncTable::Entry predefined_entries[] = {
|
||||
"omp_set_num_threads_target",
|
||||
(void*) &omp_set_num_threads_lrb,
|
||||
"omp_get_max_threads_target",
|
||||
(void*) &omp_get_max_threads_lrb,
|
||||
"omp_get_num_procs_target",
|
||||
(void*) &omp_get_num_procs_lrb,
|
||||
"omp_set_dynamic_target",
|
||||
(void*) &omp_set_dynamic_lrb,
|
||||
"omp_get_dynamic_target",
|
||||
(void*) &omp_get_dynamic_lrb,
|
||||
"omp_set_nested_target",
|
||||
(void*) &omp_set_nested_lrb,
|
||||
"omp_get_nested_target",
|
||||
(void*) &omp_get_nested_lrb,
|
||||
"omp_set_schedule_target",
|
||||
(void*) &omp_set_schedule_lrb,
|
||||
"omp_get_schedule_target",
|
||||
(void*) &omp_get_schedule_lrb,
|
||||
|
||||
"omp_init_lock_target",
|
||||
(void*) &omp_init_lock_lrb,
|
||||
"omp_destroy_lock_target",
|
||||
(void*) &omp_destroy_lock_lrb,
|
||||
"omp_set_lock_target",
|
||||
(void*) &omp_set_lock_lrb,
|
||||
"omp_unset_lock_target",
|
||||
(void*) &omp_unset_lock_lrb,
|
||||
"omp_test_lock_target",
|
||||
(void*) &omp_test_lock_lrb,
|
||||
|
||||
"omp_init_nest_lock_target",
|
||||
(void*) &omp_init_nest_lock_lrb,
|
||||
"omp_destroy_nest_lock_target",
|
||||
(void*) &omp_destroy_nest_lock_lrb,
|
||||
"omp_set_nest_lock_target",
|
||||
(void*) &omp_set_nest_lock_lrb,
|
||||
"omp_unset_nest_lock_target",
|
||||
(void*) &omp_unset_nest_lock_lrb,
|
||||
"omp_test_nest_lock_target",
|
||||
(void*) &omp_test_nest_lock_lrb,
|
||||
|
||||
"omp_target_alloc_target",
|
||||
(void*) &omp_target_alloc_target,
|
||||
"omp_target_free_target",
|
||||
(void*) &omp_target_free_target,
|
||||
"omp_target_memcpy_target",
|
||||
(void*) &omp_target_memcpy_target,
|
||||
"omp_target_memcpy_rect_target",
|
||||
(void*) &omp_target_memcpy_rect_target,
|
||||
|
||||
(const char*) -1,
|
||||
(void*) -1
|
||||
};
|
||||
|
||||
static FuncList::Node predefined_table = {
|
||||
{ predefined_entries, -1 },
|
||||
0, 0
|
||||
};
|
||||
|
||||
// Entry table
|
||||
FuncList __offload_entries(&predefined_table);
|
||||
#else
|
||||
FuncList __offload_entries;
|
||||
#endif // !HOST_LIBRARY
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Set library version
|
||||
void __offload_set_version(int v)
|
||||
{
|
||||
offload_version_count++;
|
||||
if (offload_version_count == 1)
|
||||
{
|
||||
offload_version = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mix of versions is not supported
|
||||
if (v != offload_version)
|
||||
{
|
||||
LIBOFFLOAD_ERROR(c_mixed_versions);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
// Function table. No predefined entries.
|
||||
FuncList __offload_funcs;
|
||||
|
||||
// Var table
|
||||
VarList __offload_vars;
|
||||
|
||||
// Given the function name returns the associtated function pointer
|
||||
const void* FuncList::find_addr(const char *name)
|
||||
{
|
||||
const void* func = 0;
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0 && strcmp(e->name, name) == 0) {
|
||||
func = e->func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
// Given the function pointer returns the associtated function name
|
||||
const char* FuncList::find_name(const void *func)
|
||||
{
|
||||
const char* name = 0;
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->func == func) {
|
||||
name = e->name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// Returns max name length from all tables
|
||||
int64_t FuncList::max_name_length(void)
|
||||
{
|
||||
if (m_max_name_len < 0) {
|
||||
m_lock.lock();
|
||||
|
||||
m_max_name_len = 0;
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
if (n->table.max_name_len < 0) {
|
||||
n->table.max_name_len = 0;
|
||||
|
||||
// calculate max name length in a single table
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0) {
|
||||
size_t len = strlen(e->name) + 1;
|
||||
if (n->table.max_name_len < len) {
|
||||
n->table.max_name_len = len;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// select max from all tables
|
||||
if (m_max_name_len < n->table.max_name_len) {
|
||||
m_max_name_len = n->table.max_name_len;
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
return m_max_name_len;
|
||||
}
|
||||
|
||||
// Debugging dump
|
||||
void FuncList::dump(void)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "Function table:\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "%p %s\n", e->func, e->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
// Debugging dump
|
||||
void VarList::dump(void)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "Var table:\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0) {
|
||||
#if HOST_LIBRARY
|
||||
OFFLOAD_DEBUG_TRACE(2, "%s %p %ld\n", e->name, e->addr,
|
||||
e->size);
|
||||
#else // HOST_LIBRARY
|
||||
OFFLOAD_DEBUG_TRACE(2, "%s %p\n", e->name, e->addr);
|
||||
#endif // HOST_LIBRARY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
//
|
||||
int64_t VarList::table_size(int64_t &nelems)
|
||||
{
|
||||
int64_t length = 0;
|
||||
|
||||
nelems = 0;
|
||||
|
||||
// calculate string table size and number of elements
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0) {
|
||||
length += strlen(e->name) + 1;
|
||||
nelems++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nelems * sizeof(BufEntry) + length;
|
||||
}
|
||||
|
||||
// copy table to the gven buffer
|
||||
void VarList::table_copy(void *buf, int64_t nelems)
|
||||
{
|
||||
BufEntry* elems = static_cast<BufEntry*>(buf);
|
||||
char* names = reinterpret_cast<char*>(elems + nelems);
|
||||
|
||||
// copy entries to buffer
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->name != (const char*) -1; e++) {
|
||||
if (e->name != 0) {
|
||||
// name field contains offset to the name from the beginning
|
||||
// of the buffer
|
||||
elems->name = names - static_cast<char*>(buf);
|
||||
elems->addr = reinterpret_cast<intptr_t>(e->addr);
|
||||
|
||||
// copy name to string table
|
||||
const char *name = e->name;
|
||||
while ((*names++ = *name++) != '\0');
|
||||
|
||||
elems++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// patch name offsets in a buffer
|
||||
void VarList::table_patch_names(void *buf, int64_t nelems)
|
||||
{
|
||||
BufEntry* elems = static_cast<BufEntry*>(buf);
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
elems[i].name += reinterpret_cast<intptr_t>(buf);
|
||||
}
|
||||
}
|
||||
|
||||
#if HOST_LIBRARY
|
||||
// 16.0 and earlier compilers used the following VarTable
|
||||
struct OldVarTable {
|
||||
const char* name;
|
||||
void* addr;
|
||||
// uint64_t var_alloc_type missing in 16.0 and earlier
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
static void convert_OldVarTable_to_NewVarTable(VarList::Node *vt_start)
|
||||
{
|
||||
int table_size = 0;
|
||||
char * new_var_table;
|
||||
OldVarTable *old_var_table;
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2,
|
||||
"Converting old var table to new var table to support backward compatiblity\n");
|
||||
|
||||
// Calculate size of memory to be malloced
|
||||
old_var_table = (OldVarTable *) vt_start->table.entries;
|
||||
while (old_var_table->name != (const char*) -1) {
|
||||
table_size++;
|
||||
old_var_table++;
|
||||
}
|
||||
|
||||
if (table_size != 0) {
|
||||
// Add 1 to table_size for end of table signature
|
||||
VarTable::Entry *new_var_table =
|
||||
new VarTable::Entry[table_size+1];
|
||||
|
||||
if (new_var_table == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
|
||||
old_var_table = (OldVarTable *) vt_start->table.entries;
|
||||
|
||||
// Update VarList with new table
|
||||
vt_start->table.entries = new_var_table;
|
||||
|
||||
// Fix up the new table value from old table
|
||||
for (int i=0; i< table_size; i++) {
|
||||
new_var_table->name = old_var_table->name;
|
||||
new_var_table->addr = old_var_table->addr;
|
||||
new_var_table->size = old_var_table->size;
|
||||
// Assign value of 0 for the missing field.
|
||||
// Implying it is neither IMPLICIT or LINK variable as
|
||||
// they were not supported in earlier compilers
|
||||
new_var_table->var_alloc_type = 0;
|
||||
old_var_table++;
|
||||
new_var_table++;
|
||||
}
|
||||
new_var_table->name = (const char *)-1;
|
||||
}
|
||||
|
||||
}
|
||||
#endif //HOST_LIBRARY
|
||||
|
||||
// Adds given list element to the global lookup table list
|
||||
extern "C" void __offload_register_tables(
|
||||
FuncList::Node *entry_table,
|
||||
FuncList::Node *func_table,
|
||||
VarList::Node *var_table
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering offload function entry table %p\n",
|
||||
entry_table);
|
||||
__offload_entries.add_table(entry_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering function table %p\n", func_table);
|
||||
__offload_funcs.add_table(func_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering var table %p\n", var_table);
|
||||
|
||||
// Compiler earlier than 17.0 used a different var_table.
|
||||
// Convert the old table to new var_table format.
|
||||
// Only the host table for LINUX has changed.
|
||||
#ifndef TARGET_WINNT
|
||||
#if HOST_LIBRARY
|
||||
if (offload_version < OFFLOAD_VERSION_17) {
|
||||
convert_OldVarTable_to_NewVarTable(var_table);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
__offload_vars.add_table(var_table);
|
||||
}
|
||||
|
||||
// Removes given list element from the global lookup table list
|
||||
extern "C" void __offload_unregister_tables(
|
||||
FuncList::Node *entry_table,
|
||||
FuncList::Node *func_table,
|
||||
VarList::Node *var_table
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "Unregistering offload function entry table %p\n",
|
||||
entry_table);
|
||||
__offload_entries.remove_table(entry_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Unregistering function table %p\n", func_table);
|
||||
__offload_funcs.remove_table(func_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Unregistering var table %p\n", var_table);
|
||||
#ifndef TARGET_WINNT
|
||||
#if HOST_LIBRARY
|
||||
if (offload_version < OFFLOAD_VERSION_17) {
|
||||
// Free the malloced var_table created for backward compatiblity
|
||||
delete var_table->table.entries;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
__offload_vars.remove_table(var_table);
|
||||
}
|
||||
|
||||
#ifdef MYO_SUPPORT
|
||||
|
||||
MYOVarTableList __offload_myo_var_tables;
|
||||
MYOVarTableList __offload_myo_vtable_tables;
|
||||
MYOFuncTableList __offload_myo_func_tables;
|
||||
MYOInitTableList __offload_myo_init_tables;
|
||||
|
||||
// Debugging dump
|
||||
void MYOVarTableList::dump(void)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "MYO Var tables:\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
OFFLOAD_DEBUG_TRACE(2, " MYO Var table:\n");
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->varName != MYO_TABLE_END_MARKER(); e++) {
|
||||
#ifdef TARGET_WINNT
|
||||
if (e->varName == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif // TARGET_WINNT
|
||||
OFFLOAD_DEBUG_TRACE(2, " %s %p\n",
|
||||
e->varName, e->sharedAddr);
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
// check if any shared variables
|
||||
bool MYOVarTableList::is_empty()
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "Are MYO Var tables empty?\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->varName != MYO_TABLE_END_MARKER(); e++) {
|
||||
#ifdef TARGET_WINNT
|
||||
if (e->varName == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif // TARGET_WINNT
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "No\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "Yes\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void MYOFuncTableList::dump(void)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "MYO Func tables:\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
OFFLOAD_DEBUG_TRACE(2, " MYO Func table:\n");
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->funcName != MYO_TABLE_END_MARKER(); e++) {
|
||||
#ifdef TARGET_WINNT
|
||||
if (e->funcName == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif // TARGET_WINNT
|
||||
#if HOST_LIBRARY
|
||||
OFFLOAD_DEBUG_TRACE(2, " %s %p %p\n",
|
||||
e->funcName, e->funcAddr, e->localThunkAddr);
|
||||
#else // HOST_LIBRARY
|
||||
OFFLOAD_DEBUG_TRACE(2, " %s %p %p %p\n",
|
||||
e->funcName, e->funcAddr, e->wrapFuncAddr, e->localThunkAddr);
|
||||
#endif // HOST_LIBRARY
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
// check if any shared functions
|
||||
bool MYOFuncTableList::is_empty()
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "Are MYO Func tables empty?\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
int count = 0;
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
e->funcName != MYO_TABLE_END_MARKER(); e++) {
|
||||
#ifdef TARGET_WINNT
|
||||
if (e->funcName == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif // TARGET_WINNT
|
||||
count++;
|
||||
if (count > 1) {
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "No\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "Yes\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void MYOInitTableList::dump(void)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "MYO Init tables:\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
OFFLOAD_DEBUG_TRACE(2, " MYO Init table:\n");
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
#ifdef TARGET_WINNT
|
||||
e->funcName != MYO_TABLE_END_MARKER(); e++) {
|
||||
if (e->funcName == 0) {
|
||||
continue;
|
||||
}
|
||||
OFFLOAD_DEBUG_TRACE(2, " %s %p\n", e->funcName, e->func);
|
||||
#else // TARGET_WINNT
|
||||
e->func != 0; e++) {
|
||||
OFFLOAD_DEBUG_TRACE(2, " %p\n", e->func);
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
// check if any shared functions
|
||||
bool MYOInitTableList::is_empty()
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "Are MYO Init tables empty?\n");
|
||||
|
||||
m_lock.lock();
|
||||
|
||||
for (Node *n = m_head; n != 0; n = n->next) {
|
||||
for (const Table::Entry *e = n->table.entries;
|
||||
#ifdef TARGET_WINNT
|
||||
e->funcName != MYO_TABLE_END_MARKER(); e++) {
|
||||
if (e->funcName == 0) {
|
||||
continue;
|
||||
}
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "No\n");
|
||||
return false;
|
||||
#else // TARGET_WINNT
|
||||
e->func != 0; e++) {
|
||||
#endif // TARGET_WINNT
|
||||
}
|
||||
}
|
||||
|
||||
m_lock.unlock();
|
||||
OFFLOAD_DEBUG_TRACE(3, "Yes\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" void __offload_myoRegisterTables1(
|
||||
MYOInitTableList::Node *init_table,
|
||||
MYOVarTableList::Node *shared_table,
|
||||
MYOVarTableList::Node *shared_vtable,
|
||||
MYOFuncTableList::Node *fptr_table
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering MYO shared var table %p\n",
|
||||
shared_table);
|
||||
__offload_myo_var_tables.add_table(shared_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering MYO shared vtable table %p\n",
|
||||
shared_vtable);
|
||||
__offload_myo_vtable_tables.add_table(shared_vtable);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering MYO function table %p\n", fptr_table);
|
||||
__offload_myo_func_tables.add_table(fptr_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Registering MYO init table %p\n", init_table);
|
||||
__offload_myo_init_tables.add_table(init_table);
|
||||
}
|
||||
|
||||
extern "C" void __offload_myoRemoveTables(
|
||||
MYOInitTableList::Node *init_table,
|
||||
MYOVarTableList::Node *shared_table,
|
||||
MYOVarTableList::Node *shared_vtable,
|
||||
MYOFuncTableList::Node *fptr_table
|
||||
)
|
||||
{
|
||||
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Removing MYO shared var table %p\n",
|
||||
shared_table);
|
||||
__offload_myo_var_tables.remove_table(shared_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Removing MYO shared vtable table %p\n",
|
||||
shared_vtable);
|
||||
__offload_myo_vtable_tables.remove_table(shared_vtable);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Removing MYO function table %p\n", fptr_table);
|
||||
__offload_myo_func_tables.remove_table(fptr_table);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Removing MYO init table %p\n", init_table);
|
||||
__offload_myo_init_tables.remove_table(init_table);
|
||||
}
|
||||
|
||||
#endif // MYO_SUPPORT
|
|
@ -1,468 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
\brief Function and Variable tables used by the runtime library
|
||||
*/
|
||||
|
||||
#ifndef OFFLOAD_TABLE_H_INCLUDED
|
||||
#define OFFLOAD_TABLE_H_INCLUDED
|
||||
|
||||
#include "offload_util.h"
|
||||
|
||||
#define OFFLOAD_VERSION_16 1600
|
||||
#define OFFLOAD_VERSION_17 1700
|
||||
|
||||
// Template representing double linked list of tables
|
||||
template <typename T> class TableList {
|
||||
public:
|
||||
// table type
|
||||
typedef T Table;
|
||||
|
||||
// List node
|
||||
struct Node {
|
||||
Table table;
|
||||
Node* prev;
|
||||
Node* next;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit TableList(Node *node = 0) : m_head(node) {}
|
||||
|
||||
void add_table(Node *node) {
|
||||
m_lock.lock();
|
||||
if (m_head != 0) {
|
||||
node->next = m_head;
|
||||
m_head->prev = node;
|
||||
}
|
||||
m_head = node;
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
void remove_table(Node *node) {
|
||||
if (node->next != 0) {
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
if (node->prev != 0) {
|
||||
node->prev->next = node->next;
|
||||
}
|
||||
if (m_head == node) {
|
||||
m_head = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
Node* m_head;
|
||||
mutex_t m_lock;
|
||||
};
|
||||
|
||||
// Function lookup table.
|
||||
struct FuncTable {
|
||||
//! Function table entry
|
||||
/*! This table contains functions created from offload regions. */
|
||||
/*! Each entry consists of a pointer to the function's "key"
|
||||
and the function address. */
|
||||
/*! Each shared library or executable may contain one such table. */
|
||||
/*! The end of the table is marked with an entry whose name field
|
||||
has value -1. */
|
||||
struct Entry {
|
||||
const char* name; //!< Name of the function
|
||||
void* func; //!< Address of the function
|
||||
};
|
||||
|
||||
// entries
|
||||
const Entry *entries;
|
||||
|
||||
// max name length
|
||||
int64_t max_name_len;
|
||||
};
|
||||
|
||||
// Function table
|
||||
class DLL_LOCAL FuncList : public TableList<FuncTable> {
|
||||
public:
|
||||
explicit FuncList(Node *node = 0) : TableList<Table>(node),
|
||||
m_max_name_len(-1)
|
||||
{}
|
||||
|
||||
// add table to the list
|
||||
void add_table(Node *node) {
|
||||
// recalculate max function name length
|
||||
m_max_name_len = -1;
|
||||
|
||||
// add table
|
||||
TableList<Table>::add_table(node);
|
||||
}
|
||||
|
||||
// find function address for the given name
|
||||
const void* find_addr(const char *name);
|
||||
|
||||
// find function name for the given address
|
||||
const char* find_name(const void *addr);
|
||||
|
||||
// max name length from all tables in the list
|
||||
int64_t max_name_length(void);
|
||||
|
||||
// debug dump
|
||||
void dump(void);
|
||||
|
||||
private:
|
||||
// max name length within from all tables
|
||||
int64_t m_max_name_len;
|
||||
};
|
||||
|
||||
#define VAR_ALLOC_TYPE uint64_t
|
||||
#define OPENMP_IMPLICIT 1 // Compiler promoted openmp declare var
|
||||
// due to implicit use without openmp declare
|
||||
#define OPENMP_LINK 2 // Openmp link clause in openmp declare
|
||||
|
||||
#define IS_OPENMP_IMPLICIT(var_alloc_type) (var_alloc_type & 1)
|
||||
#define IS_OPENMP_LINK(var_alloc_type) (var_alloc_type & 2)
|
||||
#define IS_OPENMP_IMPLICIT_OR_LINK(var_alloc_type) (var_alloc_type & 3)
|
||||
|
||||
// Table entry for static variables
|
||||
struct VarTable {
|
||||
//! Variable table entry
|
||||
/*! This table contains statically allocated variables marked with
|
||||
__declspec(target(mic) or #pragma omp declare target. */
|
||||
/*! Each entry consists of a pointer to the variable's "key",
|
||||
the variable address and its size in bytes. */
|
||||
/*! Because memory allocation is done from the host,
|
||||
the MIC table does not need the size of the variable. */
|
||||
/*! Padding to make the table entry size a power of 2 is necessary
|
||||
to avoid "holes" between table contributions from different object
|
||||
files on Windows when debug information is specified with /Zi. */
|
||||
struct Entry {
|
||||
const char* name; //!< Name of the variable
|
||||
void* addr; //!< Address of the variable
|
||||
|
||||
#if HOST_LIBRARY
|
||||
VAR_ALLOC_TYPE var_alloc_type;
|
||||
uint64_t size;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Table terminated by an entry with name == -1
|
||||
const Entry *entries;
|
||||
};
|
||||
|
||||
// List of var tables
|
||||
class DLL_LOCAL VarList : public TableList<VarTable> {
|
||||
public:
|
||||
VarList() : TableList<Table>()
|
||||
{}
|
||||
|
||||
// debug dump
|
||||
void dump();
|
||||
|
||||
public:
|
||||
|
||||
Node * get_head() {
|
||||
return m_head;
|
||||
}
|
||||
|
||||
public:
|
||||
// Entry representation in a copy buffer
|
||||
struct BufEntry {
|
||||
intptr_t name;
|
||||
intptr_t addr;
|
||||
};
|
||||
|
||||
// Calculate the number of elements in the table and
|
||||
// returns the size of buffer for the table
|
||||
int64_t table_size(int64_t &nelems);
|
||||
|
||||
// Copy table contents to given buffer. It is supposed to be large
|
||||
// enough to hold all elements as string table.
|
||||
void table_copy(void *buf, int64_t nelems);
|
||||
|
||||
// Patch name offsets in a table after it's been copied to other side
|
||||
static void table_patch_names(void *buf, int64_t nelems);
|
||||
};
|
||||
|
||||
DLL_LOCAL extern FuncList __offload_entries;
|
||||
DLL_LOCAL extern FuncList __offload_funcs;
|
||||
DLL_LOCAL extern VarList __offload_vars;
|
||||
|
||||
// Section names where the lookup tables are stored
|
||||
#ifdef TARGET_WINNT
|
||||
#define OFFLOAD_ENTRY_TABLE_SECTION_START ".OffloadEntryTable$a"
|
||||
#define OFFLOAD_ENTRY_TABLE_SECTION_END ".OffloadEntryTable$z"
|
||||
|
||||
#define OFFLOAD_FUNC_TABLE_SECTION_START ".OffloadFuncTable$a"
|
||||
#define OFFLOAD_FUNC_TABLE_SECTION_END ".OffloadFuncTable$z"
|
||||
|
||||
#define OFFLOAD_VAR_TABLE_SECTION_START ".OffloadVarTable$a"
|
||||
#define OFFLOAD_VAR_TABLE_SECTION_END ".OffloadVarTable$z"
|
||||
|
||||
#define OFFLOAD_CRTINIT_SECTION_START ".CRT$XCT"
|
||||
|
||||
#pragma section(OFFLOAD_CRTINIT_SECTION_START, read)
|
||||
|
||||
#else // TARGET_WINNT
|
||||
|
||||
#define OFFLOAD_ENTRY_TABLE_SECTION_START ".OffloadEntryTable."
|
||||
#define OFFLOAD_ENTRY_TABLE_SECTION_END ".OffloadEntryTable."
|
||||
|
||||
#define OFFLOAD_FUNC_TABLE_SECTION_START ".OffloadFuncTable."
|
||||
#define OFFLOAD_FUNC_TABLE_SECTION_END ".OffloadFuncTable."
|
||||
|
||||
#define OFFLOAD_VAR_TABLE_SECTION_START ".OffloadVarTable."
|
||||
#define OFFLOAD_VAR_TABLE_SECTION_END ".OffloadVarTable."
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
#pragma section(OFFLOAD_ENTRY_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_ENTRY_TABLE_SECTION_END, read, write)
|
||||
|
||||
#pragma section(OFFLOAD_FUNC_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_FUNC_TABLE_SECTION_END, read, write)
|
||||
|
||||
#pragma section(OFFLOAD_VAR_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_VAR_TABLE_SECTION_END, read, write)
|
||||
|
||||
|
||||
// Set library version
|
||||
extern "C" void __offload_set_version(int v);
|
||||
|
||||
// register/unregister given tables
|
||||
extern "C" void __offload_register_tables(
|
||||
FuncList::Node *entry_table,
|
||||
FuncList::Node *func_table,
|
||||
VarList::Node *var_table
|
||||
);
|
||||
|
||||
extern "C" void __offload_unregister_tables(
|
||||
FuncList::Node *entry_table,
|
||||
FuncList::Node *func_table,
|
||||
VarList::Node *var_table
|
||||
);
|
||||
|
||||
|
||||
#ifdef MYO_SUPPORT
|
||||
|
||||
#include <myotypes.h>
|
||||
#include <myoimpl.h>
|
||||
#include <myo.h>
|
||||
|
||||
#ifdef TARGET_WINNT
|
||||
#define MYO_TABLE_END_MARKER() reinterpret_cast<const char*>(-1)
|
||||
#else // TARGET_WINNT
|
||||
#define MYO_TABLE_END_MARKER() reinterpret_cast<const char*>(0)
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
// Host and Target-side MYO shared variable table entry layout
|
||||
typedef MyoiSharedVarEntry SharedTableEntry;
|
||||
|
||||
#if HOST_LIBRARY
|
||||
|
||||
// Host-side MYO function table entry layout
|
||||
typedef struct {
|
||||
//! Function Name
|
||||
const char *funcName;
|
||||
//! Function Address
|
||||
void *funcAddr;
|
||||
//! Local Thunk Address
|
||||
void *localThunkAddr;
|
||||
#ifdef TARGET_WINNT
|
||||
// Dummy to pad up to 32 bytes
|
||||
void *dummy;
|
||||
#endif // TARGET_WINNT
|
||||
} FptrTableEntry;
|
||||
|
||||
// Host-side MYO init routine table entry layout
|
||||
typedef struct {
|
||||
#ifdef TARGET_WINNT
|
||||
// Dummy to pad up to 16 bytes
|
||||
// Function Name
|
||||
const char *funcName;
|
||||
#endif // TARGET_WINNT
|
||||
void (*func)(MyoArena);
|
||||
} InitTableEntry;
|
||||
|
||||
#else // HOST_LIBRARY
|
||||
|
||||
// Target-side MYO function table entry layout
|
||||
typedef MyoiTargetSharedFptrEntry FptrTableEntry;
|
||||
|
||||
// Target-side MYO init routine table entry layout
|
||||
struct InitTableEntry {
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
#endif // HOST_LIBRARY
|
||||
|
||||
#ifdef TARGET_WINNT
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_TABLE_SECTION_START ".MyoSharedTable$a"
|
||||
#define OFFLOAD_MYO_SHARED_TABLE_SECTION_END ".MyoSharedTable$z"
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_VTABLE_SECTION_START ".MyoSharedVTable$a"
|
||||
#define OFFLOAD_MYO_SHARED_VTABLE_SECTION_END ".MyoSharedVTable$z"
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START ".MyoSharedInitTable$a"
|
||||
#define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END ".MyoSharedInitTable$z"
|
||||
|
||||
#define OFFLOAD_MYO_FPTR_TABLE_SECTION_START ".MyoFptrTable$a"
|
||||
#define OFFLOAD_MYO_FPTR_TABLE_SECTION_END ".MyoFptrTable$z"
|
||||
|
||||
#else // TARGET_WINNT
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_TABLE_SECTION_START ".MyoSharedTable."
|
||||
#define OFFLOAD_MYO_SHARED_TABLE_SECTION_END ".MyoSharedTable."
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_VTABLE_SECTION_START ".MyoSharedVTable."
|
||||
#define OFFLOAD_MYO_SHARED_VTABLE_SECTION_END ".MyoSharedVTable."
|
||||
|
||||
#define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START ".MyoSharedInitTable."
|
||||
#define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END ".MyoSharedInitTable."
|
||||
|
||||
#define OFFLOAD_MYO_FPTR_TABLE_SECTION_START ".MyoFptrTable."
|
||||
#define OFFLOAD_MYO_FPTR_TABLE_SECTION_END ".MyoFptrTable."
|
||||
|
||||
#endif // TARGET_WINNT
|
||||
|
||||
#pragma section(OFFLOAD_MYO_SHARED_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_MYO_SHARED_TABLE_SECTION_END, read, write)
|
||||
|
||||
#pragma section(OFFLOAD_MYO_SHARED_VTABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_MYO_SHARED_VTABLE_SECTION_END, read, write)
|
||||
|
||||
#pragma section(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END, read, write)
|
||||
|
||||
#pragma section(OFFLOAD_MYO_FPTR_TABLE_SECTION_START, read, write)
|
||||
#pragma section(OFFLOAD_MYO_FPTR_TABLE_SECTION_END, read, write)
|
||||
|
||||
// List of MYO shared variable tables
|
||||
struct MYOVarTable {
|
||||
typedef SharedTableEntry Entry;
|
||||
const Entry *entries;
|
||||
};
|
||||
|
||||
class MYOVarTableList : public TableList<MYOVarTable> {
|
||||
public:
|
||||
MYOVarTableList() : TableList<Table>()
|
||||
{}
|
||||
|
||||
// add table to the list
|
||||
void add_table(Node *node) {
|
||||
// add table
|
||||
TableList<Table>::add_table(node);
|
||||
}
|
||||
|
||||
// debug dump
|
||||
void dump(void);
|
||||
|
||||
// check if any shared variables
|
||||
bool is_empty();
|
||||
|
||||
// process the table contents for ordinary variables
|
||||
void process();
|
||||
|
||||
// process the table contents for vtable objects
|
||||
void process_vtable();
|
||||
};
|
||||
|
||||
// List of MYO shared function tables
|
||||
struct MYOFuncTable {
|
||||
typedef FptrTableEntry Entry;
|
||||
const Entry *entries;
|
||||
};
|
||||
|
||||
class MYOFuncTableList : public TableList<MYOFuncTable> {
|
||||
public:
|
||||
MYOFuncTableList() : TableList<Table>()
|
||||
{}
|
||||
|
||||
// add table to the list
|
||||
void add_table(Node *node) {
|
||||
// add table
|
||||
TableList<Table>::add_table(node);
|
||||
}
|
||||
|
||||
// debug dump
|
||||
void dump(void);
|
||||
|
||||
// check if any shared functions
|
||||
bool is_empty();
|
||||
|
||||
// process the table contents
|
||||
void process();
|
||||
};
|
||||
|
||||
// List of MYO shared variable initialization routine tables
|
||||
struct MYOInitTable {
|
||||
typedef InitTableEntry Entry;
|
||||
const Entry *entries;
|
||||
};
|
||||
|
||||
class MYOInitTableList : public TableList<MYOInitTable> {
|
||||
public:
|
||||
MYOInitTableList() : TableList<Table>()
|
||||
{}
|
||||
|
||||
// add table to the list
|
||||
void add_table(Node *node) {
|
||||
// add table
|
||||
TableList<Table>::add_table(node);
|
||||
}
|
||||
|
||||
// debug dump
|
||||
void dump(void);
|
||||
|
||||
// check if any init routines
|
||||
bool is_empty();
|
||||
|
||||
// process the table contents
|
||||
void process();
|
||||
};
|
||||
|
||||
extern MYOVarTableList __offload_myo_var_tables;
|
||||
extern MYOVarTableList __offload_myo_vtable_tables;
|
||||
extern MYOFuncTableList __offload_myo_func_tables;
|
||||
extern MYOInitTableList __offload_myo_init_tables;
|
||||
|
||||
extern "C" void __offload_myoRegisterTables1(
|
||||
MYOInitTableList::Node *init_table,
|
||||
MYOVarTableList::Node *shared_table,
|
||||
MYOVarTableList::Node *shared_vtable,
|
||||
MYOFuncTableList::Node *fptr_table
|
||||
);
|
||||
|
||||
extern "C" void __offload_myoRemoveTables(
|
||||
MYOInitTableList::Node *init_table,
|
||||
MYOVarTableList::Node *shared_table,
|
||||
MYOVarTableList::Node *shared_vtable,
|
||||
MYOFuncTableList::Node *fptr_table
|
||||
);
|
||||
|
||||
#endif // MYO_SUPPORT
|
||||
|
||||
#endif // OFFLOAD_TABLE_H_INCLUDED
|
|
@ -1,878 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "offload_target.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#ifdef SEP_SUPPORT
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif // SEP_SUPPORT
|
||||
#include <omp.h>
|
||||
#include <map>
|
||||
|
||||
// typedef offload_func_with_parms.
|
||||
// Pointer to function that represents an offloaded entry point.
|
||||
// The parameters are a temporary fix for parameters on the stack.
|
||||
typedef void (*offload_func_with_parms)(void *);
|
||||
|
||||
// Target console and file logging
|
||||
const char *prefix;
|
||||
int console_enabled = 0;
|
||||
int offload_report_level = 0;
|
||||
|
||||
// Trace information
|
||||
static const char* vardesc_direction_as_string[] = {
|
||||
"NOCOPY",
|
||||
"IN",
|
||||
"OUT",
|
||||
"INOUT"
|
||||
};
|
||||
static const char* vardesc_type_as_string[] = {
|
||||
"unknown",
|
||||
"data",
|
||||
"data_ptr",
|
||||
"func_ptr",
|
||||
"void_ptr",
|
||||
"string_ptr",
|
||||
"dv",
|
||||
"dv_data",
|
||||
"dv_data_slice",
|
||||
"dv_ptr",
|
||||
"dv_ptr_data",
|
||||
"dv_ptr_data_slice",
|
||||
"cean_var",
|
||||
"cean_var_ptr",
|
||||
"c_data_ptr_array",
|
||||
"c_extended_type",
|
||||
"c_func_ptr_array",
|
||||
"c_void_ptr_array",
|
||||
"c_string_ptr_array",
|
||||
"c_data_ptr_ptr",
|
||||
"c_func_ptr_ptr",
|
||||
"c_void_ptr_ptr",
|
||||
"c_string_ptr_ptr",
|
||||
"c_cean_var_ptr_ptr",
|
||||
};
|
||||
|
||||
int mic_index = -1;
|
||||
int mic_engines_total = -1;
|
||||
uint64_t mic_frequency = 0;
|
||||
int offload_number = 0;
|
||||
static std::map<void*, RefInfo*> ref_data;
|
||||
static mutex_t add_ref_lock;
|
||||
|
||||
#ifdef SEP_SUPPORT
|
||||
static const char* sep_monitor_env = "SEP_MONITOR";
|
||||
static bool sep_monitor = false;
|
||||
static const char* sep_device_env = "SEP_DEVICE";
|
||||
static const char* sep_device = "/dev/sep3.8/c";
|
||||
static int sep_counter = 0;
|
||||
|
||||
#define SEP_API_IOC_MAGIC 99
|
||||
#define SEP_IOCTL_PAUSE _IO (SEP_API_IOC_MAGIC, 31)
|
||||
#define SEP_IOCTL_RESUME _IO (SEP_API_IOC_MAGIC, 32)
|
||||
|
||||
static void add_ref_count(void * buf, bool created)
|
||||
{
|
||||
mutex_locker_t locker(add_ref_lock);
|
||||
RefInfo * info = ref_data[buf];
|
||||
|
||||
if (info) {
|
||||
info->count++;
|
||||
}
|
||||
else {
|
||||
info = new RefInfo((int)created,(long)1);
|
||||
}
|
||||
info->is_added |= created;
|
||||
ref_data[buf] = info;
|
||||
}
|
||||
|
||||
static void BufReleaseRef(void * buf)
|
||||
{
|
||||
mutex_locker_t locker(add_ref_lock);
|
||||
RefInfo * info = ref_data[buf];
|
||||
|
||||
if (info) {
|
||||
--info->count;
|
||||
if (info->count == 0 && info->is_added) {
|
||||
OFFLOAD_TRACE(1, "Calling COIBufferReleaseRef AddRef count = %d\n",
|
||||
((RefInfo *) ref_data[buf])->count);
|
||||
BufferReleaseRef(buf);
|
||||
info->is_added = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int VTPauseSampling(void)
|
||||
{
|
||||
int ret = -1;
|
||||
int handle = open(sep_device, O_RDWR);
|
||||
if (handle > 0) {
|
||||
ret = ioctl(handle, SEP_IOCTL_PAUSE);
|
||||
close(handle);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int VTResumeSampling(void)
|
||||
{
|
||||
int ret = -1;
|
||||
int handle = open(sep_device, O_RDWR);
|
||||
if (handle > 0) {
|
||||
ret = ioctl(handle, SEP_IOCTL_RESUME);
|
||||
close(handle);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif // SEP_SUPPORT
|
||||
|
||||
void OffloadDescriptor::offload(
|
||||
uint32_t buffer_count,
|
||||
void** buffers,
|
||||
void* misc_data,
|
||||
uint16_t misc_data_len,
|
||||
void* return_data,
|
||||
uint16_t return_data_len
|
||||
)
|
||||
{
|
||||
FunctionDescriptor *func = (FunctionDescriptor*) misc_data;
|
||||
const char *name = func->data;
|
||||
OffloadDescriptor ofld;
|
||||
char *in_data = 0;
|
||||
char *out_data = 0;
|
||||
char *timer_data = 0;
|
||||
|
||||
console_enabled = func->console_enabled;
|
||||
timer_enabled = func->timer_enabled;
|
||||
offload_report_level = func->offload_report_level;
|
||||
offload_number = func->offload_number;
|
||||
ofld.set_offload_number(func->offload_number);
|
||||
|
||||
#ifdef SEP_SUPPORT
|
||||
if (sep_monitor) {
|
||||
if (__sync_fetch_and_add(&sep_counter, 1) == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "VTResumeSampling\n");
|
||||
VTResumeSampling();
|
||||
}
|
||||
}
|
||||
#endif // SEP_SUPPORT
|
||||
|
||||
OFFLOAD_DEBUG_TRACE_1(2, ofld.get_offload_number(),
|
||||
c_offload_start_target_func,
|
||||
"Offload \"%s\" started\n", name);
|
||||
|
||||
// initialize timer data
|
||||
OFFLOAD_TIMER_INIT();
|
||||
|
||||
OFFLOAD_TIMER_START(c_offload_target_total_time);
|
||||
|
||||
OFFLOAD_TIMER_START(c_offload_target_descriptor_setup);
|
||||
|
||||
// get input/output buffer addresses
|
||||
if (func->in_datalen > 0 || func->out_datalen > 0) {
|
||||
if (func->data_offset != 0) {
|
||||
in_data = (char*) misc_data + func->data_offset;
|
||||
out_data = (char*) return_data;
|
||||
}
|
||||
else {
|
||||
char *inout_buf = (char*) buffers[--buffer_count];
|
||||
in_data = inout_buf;
|
||||
out_data = inout_buf;
|
||||
}
|
||||
}
|
||||
|
||||
// assign variable descriptors
|
||||
ofld.m_vars_total = func->vars_num;
|
||||
if (ofld.m_vars_total > 0) {
|
||||
uint64_t var_data_len = ofld.m_vars_total * sizeof(VarDesc);
|
||||
|
||||
ofld.m_vars = (VarDesc*) malloc(var_data_len);
|
||||
if (ofld.m_vars == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
memcpy(ofld.m_vars, in_data, var_data_len);
|
||||
|
||||
ofld.m_vars_extra =
|
||||
(VarExtra*) malloc(ofld.m_vars_total * sizeof(VarExtra));
|
||||
if (ofld.m_vars == NULL)
|
||||
LIBOFFLOAD_ERROR(c_malloc);
|
||||
|
||||
in_data += var_data_len;
|
||||
func->in_datalen -= var_data_len;
|
||||
}
|
||||
|
||||
// timer data
|
||||
if (func->timer_enabled) {
|
||||
uint64_t timer_data_len = OFFLOAD_TIMER_DATALEN();
|
||||
|
||||
timer_data = out_data;
|
||||
out_data += timer_data_len;
|
||||
func->out_datalen -= timer_data_len;
|
||||
}
|
||||
|
||||
// init Marshallers
|
||||
ofld.m_in.init_buffer(in_data, func->in_datalen);
|
||||
ofld.m_out.init_buffer(out_data, func->out_datalen);
|
||||
|
||||
// copy buffers to offload descriptor
|
||||
std::copy(buffers, buffers + buffer_count,
|
||||
std::back_inserter(ofld.m_buffers));
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_descriptor_setup);
|
||||
|
||||
// find offload entry address
|
||||
OFFLOAD_TIMER_START(c_offload_target_func_lookup);
|
||||
|
||||
offload_func_with_parms entry = (offload_func_with_parms)
|
||||
__offload_entries.find_addr(name);
|
||||
|
||||
if (entry == NULL) {
|
||||
#if OFFLOAD_DEBUG > 0
|
||||
if (console_enabled > 2) {
|
||||
__offload_entries.dump();
|
||||
}
|
||||
#endif
|
||||
LIBOFFLOAD_ERROR(c_offload_descriptor_offload, name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_func_lookup);
|
||||
|
||||
OFFLOAD_TIMER_START(c_offload_target_func_time);
|
||||
|
||||
// execute offload entry
|
||||
entry(&ofld);
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_func_time);
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_total_time);
|
||||
|
||||
// copy timer data to the buffer
|
||||
OFFLOAD_TIMER_TARGET_DATA(timer_data);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "Offload \"%s\" finished\n", name);
|
||||
|
||||
#ifdef SEP_SUPPORT
|
||||
if (sep_monitor) {
|
||||
if (__sync_sub_and_fetch(&sep_counter, 1) == 0) {
|
||||
OFFLOAD_DEBUG_TRACE(2, "VTPauseSampling\n");
|
||||
VTPauseSampling();
|
||||
}
|
||||
}
|
||||
#endif // SEP_SUPPORT
|
||||
}
|
||||
|
||||
void OffloadDescriptor::merge_var_descs(
|
||||
VarDesc *vars,
|
||||
VarDesc2 *vars2,
|
||||
int vars_total
|
||||
)
|
||||
{
|
||||
// number of variable descriptors received from host and generated
|
||||
// locally should match
|
||||
if (m_vars_total < vars_total) {
|
||||
LIBOFFLOAD_ERROR(c_merge_var_descs1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_vars_total; i++) {
|
||||
// instead of m_vars[i].type.src we will use m_vars_extra[i].type_src
|
||||
|
||||
if (i < vars_total) {
|
||||
// variable type must match
|
||||
if (m_vars[i].type.bits != vars[i].type.bits) {
|
||||
OFFLOAD_TRACE(2,
|
||||
"m_vars[%d].type.bits=%08x, vars[%d].type.bits=%08x\n",
|
||||
i, m_vars[i].type.bits, i, vars[i].type.bits);
|
||||
LIBOFFLOAD_ERROR(c_merge_var_descs2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (m_vars[i].type.src == c_extended_type) {
|
||||
VarDescExtendedType *etype =
|
||||
reinterpret_cast<VarDescExtendedType*>(vars[i].ptr);
|
||||
m_vars_extra[i].type_src = etype->extended_type;
|
||||
m_vars[i].ptr = etype->ptr;
|
||||
}
|
||||
else {
|
||||
m_vars_extra[i].type_src = m_vars[i].type.src;
|
||||
if (!(m_vars[i].flags.use_device_ptr &&
|
||||
m_vars[i].type.src == c_dv)) {
|
||||
m_vars[i].ptr = vars[i].ptr;
|
||||
}
|
||||
}
|
||||
// instead of m_vars[i].type.dst we will use m_vars_extra[i].type_dst
|
||||
if (i < vars_total && m_vars[i].type.dst == c_extended_type) {
|
||||
VarDescExtendedType *etype =
|
||||
reinterpret_cast<VarDescExtendedType*>(vars[i].into);
|
||||
m_vars_extra[i].type_dst = etype->extended_type;
|
||||
m_vars[i].into = etype->ptr;
|
||||
}
|
||||
else {
|
||||
m_vars_extra[i].type_dst = m_vars[i].type.dst;
|
||||
m_vars[i].into = vars[i].into;
|
||||
}
|
||||
|
||||
const char *var_sname = "";
|
||||
if (vars2 != NULL) {
|
||||
if (vars2[i].sname != NULL) {
|
||||
var_sname = vars2[i].sname;
|
||||
}
|
||||
}
|
||||
OFFLOAD_DEBUG_TRACE_1(2, get_offload_number(), c_offload_var,
|
||||
" VarDesc %d, var=%s, %s, %s\n",
|
||||
i, var_sname,
|
||||
vardesc_direction_as_string[m_vars[i].direction.bits],
|
||||
vardesc_type_as_string[m_vars_extra[i].type_src]);
|
||||
if (vars2 != NULL && vars2[i].dname != NULL) {
|
||||
OFFLOAD_TRACE(2, " into=%s, %s\n", vars2[i].dname,
|
||||
vardesc_type_as_string[m_vars_extra[i].type_dst]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_vars_extra[i].type_src = m_vars[i].type.src;
|
||||
m_vars_extra[i].type_dst = m_vars[i].type.dst;
|
||||
}
|
||||
|
||||
OFFLOAD_TRACE(2,
|
||||
" type_src=%d, type_dstn=%d, direction=%d, "
|
||||
"alloc_if=%d, free_if=%d, align=%d, mic_offset=%d, flags=0x%x, "
|
||||
"offset=%lld, size=%lld, count/disp=%lld, ptr=%p into=%p\n",
|
||||
m_vars_extra[i].type_src,
|
||||
m_vars_extra[i].type_dst,
|
||||
m_vars[i].direction.bits,
|
||||
m_vars[i].alloc_if,
|
||||
m_vars[i].free_if,
|
||||
m_vars[i].align,
|
||||
m_vars[i].mic_offset,
|
||||
m_vars[i].flags.bits,
|
||||
m_vars[i].offset,
|
||||
m_vars[i].size,
|
||||
m_vars[i].count,
|
||||
m_vars[i].ptr,
|
||||
m_vars[i].into);
|
||||
}
|
||||
}
|
||||
|
||||
void OffloadDescriptor::scatter_copyin_data()
|
||||
{
|
||||
OFFLOAD_TIMER_START(c_offload_target_scatter_inputs);
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "IN buffer @ %p size %lld\n",
|
||||
m_in.get_buffer_start(),
|
||||
m_in.get_buffer_size());
|
||||
OFFLOAD_DEBUG_DUMP_BYTES(2, m_in.get_buffer_start(),
|
||||
m_in.get_buffer_size());
|
||||
|
||||
// receive data
|
||||
for (int i = 0; i < m_vars_total; i++) {
|
||||
bool src_is_for_mic = (m_vars[i].direction.out ||
|
||||
m_vars[i].into == NULL);
|
||||
void** ptr_addr = src_is_for_mic ?
|
||||
static_cast<void**>(m_vars[i].ptr) :
|
||||
static_cast<void**>(m_vars[i].into);
|
||||
int type = src_is_for_mic ? m_vars_extra[i].type_src :
|
||||
m_vars_extra[i].type_dst;
|
||||
bool is_static = src_is_for_mic ?
|
||||
m_vars[i].flags.is_static :
|
||||
m_vars[i].flags.is_static_dstn;
|
||||
void *ptr = NULL;
|
||||
|
||||
if (m_vars[i].flags.alloc_disp) {
|
||||
int64_t offset = 0;
|
||||
m_in.receive_data(&offset, sizeof(offset));
|
||||
}
|
||||
if (VAR_TYPE_IS_DV_DATA_SLICE(type) ||
|
||||
VAR_TYPE_IS_DV_DATA(type)) {
|
||||
ArrDesc *dvp = (type == c_dv_data_slice || type == c_dv_data)?
|
||||
reinterpret_cast<ArrDesc*>(ptr_addr) :
|
||||
*reinterpret_cast<ArrDesc**>(ptr_addr);
|
||||
ptr_addr = reinterpret_cast<void**>(&dvp->Base);
|
||||
}
|
||||
// Set pointer values
|
||||
switch (type) {
|
||||
case c_data_ptr_array:
|
||||
{
|
||||
int j = m_vars[i].ptr_arr_offset;
|
||||
int max_el = j + m_vars[i].count;
|
||||
char *dst_arr_ptr = (src_is_for_mic)?
|
||||
*(reinterpret_cast<char**>(m_vars[i].ptr)) :
|
||||
reinterpret_cast<char*>(m_vars[i].into);
|
||||
|
||||
// if is_pointer is 1 it means that pointer array itself
|
||||
// is defined either via pointer or as class member.
|
||||
// i.e. arr_ptr[0:5] or this->ARR[0:5]
|
||||
if (m_vars[i].flags.is_pointer) {
|
||||
int64_t offset = 0;
|
||||
m_in.receive_data(&offset, sizeof(offset));
|
||||
dst_arr_ptr = *((char**)dst_arr_ptr) + offset;
|
||||
}
|
||||
for (; j < max_el; j++) {
|
||||
if (src_is_for_mic) {
|
||||
m_vars[j].ptr =
|
||||
dst_arr_ptr + m_vars[j].ptr_arr_offset;
|
||||
}
|
||||
else {
|
||||
m_vars[j].into =
|
||||
dst_arr_ptr + m_vars[j].ptr_arr_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case c_data:
|
||||
case c_void_ptr:
|
||||
case c_void_ptr_ptr:
|
||||
case c_cean_var:
|
||||
case c_dv:
|
||||
break;
|
||||
|
||||
case c_string_ptr:
|
||||
case c_data_ptr:
|
||||
case c_string_ptr_ptr:
|
||||
case c_data_ptr_ptr:
|
||||
case c_cean_var_ptr:
|
||||
case c_cean_var_ptr_ptr:
|
||||
case c_dv_ptr:
|
||||
// Don't need ptr_addr value for variables from stack buffer.
|
||||
// Stack buffer address is set at var_desc with #0.
|
||||
if (i != 0 && m_vars[i].flags.is_stack_buf) {
|
||||
break;
|
||||
}
|
||||
if (TYPE_IS_PTR_TO_PTR(m_vars_extra[i].type_src) ||
|
||||
TYPE_IS_PTR_TO_PTR(m_vars_extra[i].type_dst)) {
|
||||
int64_t offset;
|
||||
|
||||
m_in.receive_data(&offset, sizeof(offset));
|
||||
ptr_addr = reinterpret_cast<void**>(
|
||||
reinterpret_cast<char*>(*ptr_addr) + offset);
|
||||
|
||||
}
|
||||
|
||||
if (m_vars[i].alloc_if && !m_vars[i].flags.preallocated) {
|
||||
void *buf = NULL;
|
||||
if (m_vars[i].flags.sink_addr) {
|
||||
m_in.receive_data(&buf, sizeof(buf));
|
||||
}
|
||||
else {
|
||||
buf = m_buffers.front();
|
||||
m_buffers.pop_front();
|
||||
}
|
||||
if (buf) {
|
||||
if (!is_static) {
|
||||
if (!m_vars[i].flags.sink_addr) {
|
||||
// increment buffer reference
|
||||
OFFLOAD_TIMER_START(c_offload_target_add_buffer_refs);
|
||||
BufferAddRef(buf);
|
||||
OFFLOAD_TRACE(1, "Calling COIBufferAddRef %p\n", buf);
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_add_buffer_refs);
|
||||
}
|
||||
add_ref_count(buf, 0 == m_vars[i].flags.sink_addr);
|
||||
OFFLOAD_TRACE(1, " AddRef count = %d\n",
|
||||
((RefInfo *) ref_data[buf])->count);
|
||||
}
|
||||
ptr = static_cast<char*>(buf) +
|
||||
m_vars[i].mic_offset +
|
||||
(m_vars[i].flags.is_stack_buf ?
|
||||
0 : m_vars[i].offset);
|
||||
|
||||
}
|
||||
*ptr_addr = ptr;
|
||||
}
|
||||
else if (m_vars[i].flags.sink_addr) {
|
||||
void *buf;
|
||||
m_in.receive_data(&buf, sizeof(buf));
|
||||
void *ptr = static_cast<char*>(buf) +
|
||||
m_vars[i].mic_offset +
|
||||
(m_vars[i].flags.is_stack_buf ?
|
||||
0 : m_vars[i].offset);
|
||||
*ptr_addr = ptr;
|
||||
}
|
||||
break;
|
||||
|
||||
case c_func_ptr:
|
||||
case c_func_ptr_ptr:
|
||||
break;
|
||||
|
||||
case c_dv_data:
|
||||
case c_dv_ptr_data:
|
||||
case c_dv_data_slice:
|
||||
case c_dv_ptr_data_slice:
|
||||
if (m_vars[i].alloc_if) {
|
||||
void *buf;
|
||||
if (m_vars[i].flags.sink_addr) {
|
||||
m_in.receive_data(&buf, sizeof(buf));
|
||||
}
|
||||
else {
|
||||
buf = m_buffers.front();
|
||||
m_buffers.pop_front();
|
||||
}
|
||||
if (buf) {
|
||||
if (!is_static) {
|
||||
if (!m_vars[i].flags.sink_addr) {
|
||||
// increment buffer reference
|
||||
OFFLOAD_TIMER_START(c_offload_target_add_buffer_refs);
|
||||
BufferAddRef(buf);
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_add_buffer_refs);
|
||||
}
|
||||
add_ref_count(buf, 0 == m_vars[i].flags.sink_addr);
|
||||
}
|
||||
ptr = static_cast<char*>(buf) +
|
||||
m_vars[i].mic_offset + m_vars[i].offset;
|
||||
}
|
||||
*ptr_addr = ptr;
|
||||
}
|
||||
else if (m_vars[i].flags.sink_addr) {
|
||||
void *buf;
|
||||
m_in.receive_data(&buf, sizeof(buf));
|
||||
ptr = static_cast<char*>(buf) +
|
||||
m_vars[i].mic_offset + m_vars[i].offset;
|
||||
*ptr_addr = ptr;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_unknown_var_type, type);
|
||||
abort();
|
||||
}
|
||||
// Release obsolete buffers for stack of persistent objects.
|
||||
// The vardesc with i==0 and flags.is_stack_buf==TRUE is always for
|
||||
// stack buffer pointer.
|
||||
if (i == 0 &&
|
||||
m_vars[i].flags.is_stack_buf &&
|
||||
!m_vars[i].direction.bits &&
|
||||
m_vars[i].alloc_if &&
|
||||
m_vars[i].size != 0) {
|
||||
for (int j=0; j < m_vars[i].size; j++) {
|
||||
void *buf;
|
||||
m_in.receive_data(&buf, sizeof(buf));
|
||||
OFFLOAD_TRACE(4, "Releasing stack buffer %p\n", buf);
|
||||
BufferReleaseRef(buf);
|
||||
ref_data.erase(buf);
|
||||
}
|
||||
}
|
||||
// Do copyin
|
||||
switch (m_vars_extra[i].type_dst) {
|
||||
case c_data_ptr_array:
|
||||
break;
|
||||
case c_data:
|
||||
case c_void_ptr:
|
||||
case c_void_ptr_ptr:
|
||||
case c_cean_var:
|
||||
if (m_vars[i].direction.in &&
|
||||
!m_vars[i].flags.is_static_dstn) {
|
||||
int64_t size;
|
||||
int64_t disp;
|
||||
char* ptr = m_vars[i].into ?
|
||||
static_cast<char*>(m_vars[i].into) :
|
||||
static_cast<char*>(m_vars[i].ptr);
|
||||
if (m_vars_extra[i].type_dst == c_cean_var) {
|
||||
m_in.receive_data((&size), sizeof(int64_t));
|
||||
m_in.receive_data((&disp), sizeof(int64_t));
|
||||
}
|
||||
else {
|
||||
size = m_vars[i].size;
|
||||
disp = 0;
|
||||
}
|
||||
m_in.receive_data(ptr + disp, size);
|
||||
}
|
||||
break;
|
||||
|
||||
case c_dv:
|
||||
if (m_vars[i].direction.bits ||
|
||||
m_vars[i].alloc_if ||
|
||||
m_vars[i].free_if) {
|
||||
char* ptr = m_vars[i].into ?
|
||||
static_cast<char*>(m_vars[i].into) :
|
||||
static_cast<char*>(m_vars[i].ptr);
|
||||
m_in.receive_data(ptr + sizeof(uint64_t),
|
||||
m_vars[i].size - sizeof(uint64_t));
|
||||
}
|
||||
break;
|
||||
|
||||
case c_string_ptr:
|
||||
case c_data_ptr:
|
||||
case c_string_ptr_ptr:
|
||||
case c_data_ptr_ptr:
|
||||
case c_cean_var_ptr:
|
||||
case c_cean_var_ptr_ptr:
|
||||
case c_dv_ptr:
|
||||
case c_dv_data:
|
||||
case c_dv_ptr_data:
|
||||
case c_dv_data_slice:
|
||||
case c_dv_ptr_data_slice:
|
||||
break;
|
||||
|
||||
case c_func_ptr:
|
||||
case c_func_ptr_ptr:
|
||||
if (m_vars[i].direction.in) {
|
||||
m_in.receive_func_ptr((const void**) m_vars[i].ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_unknown_var_type, m_vars_extra[i].type_dst);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
OFFLOAD_TRACE(1, "Total copyin data received from host: [%lld] bytes\n",
|
||||
m_in.get_tfr_size());
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_scatter_inputs);
|
||||
|
||||
OFFLOAD_TIMER_START(c_offload_target_compute);
|
||||
}
|
||||
|
||||
void OffloadDescriptor::gather_copyout_data()
|
||||
{
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_compute);
|
||||
|
||||
OFFLOAD_TIMER_START(c_offload_target_gather_outputs);
|
||||
|
||||
for (int i = 0; i < m_vars_total; i++) {
|
||||
bool src_is_for_mic = (m_vars[i].direction.out ||
|
||||
m_vars[i].into == NULL);
|
||||
if (m_vars[i].flags.is_stack_buf) {
|
||||
continue;
|
||||
}
|
||||
switch (m_vars_extra[i].type_src) {
|
||||
case c_data_ptr_array:
|
||||
break;
|
||||
case c_data:
|
||||
case c_void_ptr:
|
||||
case c_void_ptr_ptr:
|
||||
case c_cean_var:
|
||||
if (m_vars[i].direction.out &&
|
||||
!m_vars[i].flags.is_static) {
|
||||
m_out.send_data(
|
||||
static_cast<char*>(m_vars[i].ptr) + m_vars[i].disp,
|
||||
m_vars[i].size);
|
||||
}
|
||||
break;
|
||||
|
||||
case c_dv:
|
||||
break;
|
||||
|
||||
case c_string_ptr:
|
||||
case c_data_ptr:
|
||||
case c_string_ptr_ptr:
|
||||
case c_data_ptr_ptr:
|
||||
case c_cean_var_ptr:
|
||||
case c_cean_var_ptr_ptr:
|
||||
case c_dv_ptr:
|
||||
if (m_vars[i].free_if &&
|
||||
src_is_for_mic &&
|
||||
!m_vars[i].flags.preallocated &&
|
||||
!m_vars[i].flags.is_static) {
|
||||
void *buf = *static_cast<char**>(m_vars[i].ptr) -
|
||||
m_vars[i].mic_offset -
|
||||
(m_vars[i].flags.is_stack_buf?
|
||||
0 : m_vars[i].offset);
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
// decrement buffer reference count
|
||||
OFFLOAD_TIMER_START(c_offload_target_release_buffer_refs);
|
||||
BufReleaseRef(buf);
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_release_buffer_refs);
|
||||
}
|
||||
if (m_vars[i].flags.preallocated && m_vars[i].alloc_if) {
|
||||
m_out.send_data((void*) m_vars[i].ptr, sizeof(void*));
|
||||
}
|
||||
break;
|
||||
|
||||
case c_func_ptr:
|
||||
case c_func_ptr_ptr:
|
||||
if (m_vars[i].direction.out) {
|
||||
m_out.send_func_ptr(*((void**) m_vars[i].ptr));
|
||||
}
|
||||
break;
|
||||
|
||||
case c_dv_data:
|
||||
case c_dv_ptr_data:
|
||||
case c_dv_data_slice:
|
||||
case c_dv_ptr_data_slice:
|
||||
if (src_is_for_mic &&
|
||||
m_vars[i].free_if &&
|
||||
!m_vars[i].flags.is_static) {
|
||||
ArrDesc *dvp = (m_vars_extra[i].type_src == c_dv_data ||
|
||||
m_vars_extra[i].type_src == c_dv_data_slice) ?
|
||||
static_cast<ArrDesc*>(m_vars[i].ptr) :
|
||||
*static_cast<ArrDesc**>(m_vars[i].ptr);
|
||||
|
||||
void *buf = reinterpret_cast<char*>(dvp->Base) -
|
||||
m_vars[i].mic_offset -
|
||||
m_vars[i].offset;
|
||||
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
// decrement buffer reference count
|
||||
OFFLOAD_TIMER_START(c_offload_target_release_buffer_refs);
|
||||
BufReleaseRef(buf);
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_release_buffer_refs);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_unknown_var_type, m_vars_extra[i].type_dst);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (m_vars[i].into) {
|
||||
switch (m_vars_extra[i].type_dst) {
|
||||
case c_data_ptr_array:
|
||||
break;
|
||||
case c_data:
|
||||
case c_void_ptr:
|
||||
case c_void_ptr_ptr:
|
||||
case c_cean_var:
|
||||
case c_dv:
|
||||
break;
|
||||
|
||||
case c_string_ptr:
|
||||
case c_data_ptr:
|
||||
case c_string_ptr_ptr:
|
||||
case c_data_ptr_ptr:
|
||||
case c_cean_var_ptr:
|
||||
case c_cean_var_ptr_ptr:
|
||||
case c_dv_ptr:
|
||||
if (m_vars[i].direction.in &&
|
||||
m_vars[i].free_if &&
|
||||
!m_vars[i].flags.is_static_dstn) {
|
||||
void *buf = *static_cast<char**>(m_vars[i].into) -
|
||||
m_vars[i].mic_offset -
|
||||
(m_vars[i].flags.is_stack_buf?
|
||||
0 : m_vars[i].offset);
|
||||
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
// decrement buffer reference count
|
||||
OFFLOAD_TIMER_START(
|
||||
c_offload_target_release_buffer_refs);
|
||||
BufReleaseRef(buf);
|
||||
OFFLOAD_TIMER_STOP(
|
||||
c_offload_target_release_buffer_refs);
|
||||
}
|
||||
break;
|
||||
|
||||
case c_func_ptr:
|
||||
case c_func_ptr_ptr:
|
||||
break;
|
||||
|
||||
case c_dv_data:
|
||||
case c_dv_ptr_data:
|
||||
case c_dv_data_slice:
|
||||
case c_dv_ptr_data_slice:
|
||||
if (m_vars[i].free_if &&
|
||||
m_vars[i].direction.in &&
|
||||
!m_vars[i].flags.is_static_dstn) {
|
||||
ArrDesc *dvp =
|
||||
(m_vars_extra[i].type_dst == c_dv_data_slice ||
|
||||
m_vars_extra[i].type_dst == c_dv_data) ?
|
||||
static_cast<ArrDesc*>(m_vars[i].into) :
|
||||
*static_cast<ArrDesc**>(m_vars[i].into);
|
||||
void *buf = reinterpret_cast<char*>(dvp->Base) -
|
||||
m_vars[i].mic_offset -
|
||||
m_vars[i].offset;
|
||||
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
// decrement buffer reference count
|
||||
OFFLOAD_TIMER_START(
|
||||
c_offload_target_release_buffer_refs);
|
||||
BufReleaseRef(buf);
|
||||
OFFLOAD_TIMER_STOP(
|
||||
c_offload_target_release_buffer_refs);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LIBOFFLOAD_ERROR(c_unknown_var_type, m_vars_extra[i].type_dst);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OFFLOAD_DEBUG_TRACE(2, "OUT buffer @ p %p size %lld\n",
|
||||
m_out.get_buffer_start(),
|
||||
m_out.get_buffer_size());
|
||||
|
||||
OFFLOAD_DEBUG_DUMP_BYTES(2,
|
||||
m_out.get_buffer_start(),
|
||||
m_out.get_buffer_size());
|
||||
|
||||
OFFLOAD_DEBUG_TRACE_1(1, get_offload_number(), c_offload_copyout_data,
|
||||
"Total copyout data sent to host: [%lld] bytes\n",
|
||||
m_out.get_tfr_size());
|
||||
|
||||
OFFLOAD_TIMER_STOP(c_offload_target_gather_outputs);
|
||||
}
|
||||
|
||||
void __offload_target_init(void)
|
||||
{
|
||||
#ifdef SEP_SUPPORT
|
||||
const char* env_var = getenv(sep_monitor_env);
|
||||
if (env_var != 0 && *env_var != '\0') {
|
||||
sep_monitor = atoi(env_var);
|
||||
}
|
||||
env_var = getenv(sep_device_env);
|
||||
if (env_var != 0 && *env_var != '\0') {
|
||||
sep_device = env_var;
|
||||
}
|
||||
#endif // SEP_SUPPORT
|
||||
|
||||
prefix = report_get_message_str(c_report_mic);
|
||||
|
||||
// init frequency
|
||||
mic_frequency = COIPerfGetCycleFrequency();
|
||||
}
|
||||
|
||||
// User-visible offload API
|
||||
|
||||
int _Offload_number_of_devices(void)
|
||||
{
|
||||
return mic_engines_total;
|
||||
}
|
||||
|
||||
int _Offload_get_device_number(void)
|
||||
{
|
||||
return mic_index;
|
||||
}
|
||||
|
||||
int _Offload_get_physical_device_number(void)
|
||||
{
|
||||
uint32_t index;
|
||||
EngineGetIndex(&index);
|
||||
return index;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue