Commit df26a50d by Ilya Verbin Committed by Ilya Verbin

backport: Makefile.am (myo_inc_dir): Remove.

Merge liboffloadmic from upstream

liboffloadmic/
	* 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.

From-SVN: r238603
parent ab3af181
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
......
......@@ -37,7 +37,6 @@ SUBDIRS = . plugin
# Directories.
build_dir = $(top_builddir)
coi_inc_dir = $(top_srcdir)/include/coi
myo_inc_dir = $(top_srcdir)/include/myo
libgomp_dir = $(build_dir)/../libgomp
source_dir = $(top_srcdir)/runtime
......@@ -48,12 +47,12 @@ libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
# Target list.
if LIBOFFLOADMIC_HOST
nodist_toolexeclib_HEADERS = liboffloadmic_host.spec
toolexeclib_LTLIBRARIES = libcoi_host.la libmyo-client.la liboffloadmic_host.la
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 libmyo-service.la liboffloadmic_target.la
toolexeclib_LTLIBRARIES = libcoi_device.la liboffloadmic_target.la
nodist_libsubinclude_HEADERS = runtime/compiler_if_target.h
ofld_obj = ofldbegin.o ofldend.o
endif
......@@ -67,7 +66,7 @@ liboffloadmic_sources = runtime/dv_util.cpp \
runtime/offload_trace.cpp \
runtime/offload_util.cpp
liboffloadmic_cppflags = -DLINUX -DCOI_LIBRARY_VERSION=2 -DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -I$(coi_inc_dir) -I$(myo_inc_dir) -I$(source_dir) -I$(libgomp_dir)
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 \
......@@ -76,7 +75,6 @@ liboffloadmic_host_la_SOURCES = $(liboffloadmic_sources) \
runtime/offload_engine.cpp \
runtime/offload_env.cpp \
runtime/offload_host.cpp \
runtime/offload_myo_host.cpp \
runtime/offload_omp_host.cpp \
runtime/offload_orsl.cpp \
runtime/offload_timer_host.cpp \
......@@ -88,36 +86,27 @@ 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_myo_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 libmyo-service.la
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
libmyo_client_la_SOURCES = runtime/emulator/myo_client.cpp
libmyo_service_la_SOURCES = runtime/emulator/myo_service.cpp
libcoi_host_la_DEPENDENCIES = runtime/emulator/coi_version_linker_script.map
libcoi_device_la_DEPENDENCIES = runtime/emulator/coi_version_linker_script.map
libmyo_client_la_DEPENDENCIES = runtime/emulator/myo_version_linker_script.map
libmyo_service_la_DEPENDENCIES = runtime/emulator/myo_version_linker_script.map
libcoi_host_la_CPPFLAGS = -I$(coi_inc_dir)
libcoi_device_la_CPPFLAGS = -I$(coi_inc_dir)
libmyo_client_la_CPPFLAGS = -I$(myo_inc_dir)
libmyo_service_la_CPPFLAGS = -I$(myo_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
libmyo_client_la_LDFLAGS = -lrt -Wl,--version-script=$(source_dir)/emulator/myo_version_linker_script.map
libmyo_service_la_LDFLAGS = -lrt -Wl,--version-script=$(source_dir)/emulator/myo_version_linker_script.map
# ofldbegin, ofldend
all-local: $(ofld_obj)
......
......@@ -82,7 +82,7 @@ Notice revision \#20110804
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-2015, Intel Corporation. All rights reserved.
This document is Copyright \textcopyright 2014-2016, Intel Corporation. All rights reserved.
\pagenumbering{roman}
\tableofcontents
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -56,11 +56,11 @@ extern "C" {
#endif
#endif // DOXYGEN_SHOULD_SKIP_THIS
#define COI_MAX_ISA_x86_64_DEVICES 1
#define COI_MAX_ISA_MIC_DEVICES 128
#define COI_MAX_ISA_KNF_DEVICES COI_MAX_ISA_MIC_DEVICES
#define COI_MAX_ISA_KNC_DEVICES COI_MAX_ISA_MIC_DEVICES
#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
///////////////////////////////////////////////////////////////////////////////
///
......@@ -68,22 +68,35 @@ extern "C" {
///
typedef enum
{
COI_ISA_INVALID = 0, ///< Represents an invalid ISA.
COI_ISA_x86_64, ///< The ISA for an x86_64 host engine.
COI_ISA_MIC, ///< Special value used to represent any device
///< in the Intel(R) Many Integrated Core
///< architecture family.
COI_ISA_KNF, ///< ISA for L1OM devices.
COI_ISA_KNC ///< ISA for K1OM devices.
} COI_ISA_TYPE;
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_ISA_TYPE of the engine.
/// [out] The COI_DEVICE_TYPE of the engine.
///
/// @param out_pIndex
/// [out] The zero-based index of this engine in the collection of
......@@ -96,8 +109,8 @@ typedef enum
COIACCESSAPI
COIRESULT
COIEngineGetIndex(
COI_ISA_TYPE* out_pType,
uint32_t* out_pIndex);
COI_DEVICE_TYPE *out_pType,
uint32_t *out_pIndex);
#ifdef __cplusplus
} /* extern "C" */
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -54,20 +54,20 @@
#include <sched.h>
#ifndef UNREFERENCED_CONST_PARAM
#define UNREFERENCED_CONST_PARAM(P) { void* x UNUSED_ATTR = \
(void*)(uint64_t)P; \
}
(void*)(uint64_t)P; \
}
#endif
// This seems to work on everything.
// This seems to work on everything.
#ifndef UNREFERENCED_PARAM
#define UNREFERENCED_PARAM(P) (P = P)
#define UNREFERENCED_PARAM(P) (P = P)
#endif
#ifndef SYMBOL_VERSION
/* Linux support: */
/* Linux support: */
#define SYMBOL_VERSION( SYMBOL , VERSION ) SYMBOL ## VERSION
#define SYMBOL_VERSION( SYMBOL , VERSION ) SYMBOL ## VERSION
#endif
......@@ -86,30 +86,31 @@
/* 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)));
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)));
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));
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(unsigned int i=0;i<loopIterations;++i)
for (; i < loopIterations; ++i)
dst[i] = src1[i] & src2[i];
}
......@@ -117,8 +118,9 @@ static inline void COI_CPU_MASK_AND(COI_CPU_MASK dst, const COI_CPU_MASK src1, c
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(unsigned int i=0;i<loopIterations;++i)
for (; i < loopIterations; ++i)
dst[i] = src1[i] ^ src2[i];
}
......@@ -126,28 +128,30 @@ static inline void COI_CPU_MASK_XOR(COI_CPU_MASK dst, const COI_CPU_MASK src1, c
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(unsigned int i=0;i<loopIterations;++i)
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;
int cnt = 0;
for (;n;cnt++)
n &= (n-1);
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;
int cnt = 0;
const unsigned int loopIterations = sizeof(COI_CPU_MASK) / sizeof(cpu_mask[0]);
unsigned int i = 0;
for(unsigned int i=0;i < loopIterations;++i)
for (; i < loopIterations; ++i)
{
cnt += __COI_CountBits(cpu_mask[i]);
}
......@@ -155,11 +159,12 @@ static inline int COI_CPU_MASK_COUNT(const COI_CPU_MASK cpu_mask)
}
/* Roughly equivalent to CPU_EQUAL(). */
static inline int COI_CPU_MASK_EQUAL(const COI_CPU_MASK cpu_mask1,const COI_CPU_MASK cpu_mask2)
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(unsigned int i=0;i < loopIterations;++i)
for (; i < loopIterations; ++i)
{
if (cpu_mask1[i] != cpu_mask2[i])
return 0;
......@@ -169,51 +174,55 @@ static inline int COI_CPU_MASK_EQUAL(const COI_CPU_MASK cpu_mask1,const COI_CPU_
/* 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)
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
#if 0
/* Slightly slower version than the following #else/#endif block. Left here only to
document the intent of the code. */
for(unsigned int i=0;i < sizeof(cpu_set_t)*8;++i)
if (CPU_ISSET(i,src))
COI_CPU_MASK_SET(i,dest);
#else
for(unsigned int i=0;i < sizeof(COI_CPU_MASK)/sizeof(dest[0]);++i)
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(unsigned int j=0;j < 64;++j)
for (j = 0; j < 64; ++j)
{
if (CPU_ISSET(i*64+j,src))
if (CPU_ISSET(i * 64 + j, src))
dest[i] |= ((uint64_t)1) << j;
}
}
#endif
#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)
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
#if 0
/* Slightly slower version than the following #else/#endif block. Left here only to
document the intent of the code. */
for(unsigned int i=0;i < sizeof(COI_CPU_MASK)*8;++i)
if (COI_CPU_MASK_ISSET(i,src))
CPU_SET(i,dest);
#else
for(unsigned int i=0;i < sizeof(COI_CPU_MASK)/sizeof(src[0]);++i)
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(unsigned int j=0;j < 64;++j)
for (j = 0; j < 64; ++j)
{
const uint64_t bit = ((uint64_t)1) << j;
if (bit & cpu_mask)
CPU_SET(i*64+j,dest);
CPU_SET(i * 64 + j, dest);
}
}
#endif
#endif
}
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -59,67 +59,69 @@ 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.
///< system was initialized.
COI_ALREADY_INITIALIZED, ///< The function was called after the
///< system was initialized.
///< system was initialized.
COI_ALREADY_EXISTS, ///< Cannot complete the request due to
///< the existence of a similar object.
///< 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.
///< valid.
COI_OUT_OF_RANGE, ///< One of the arguments contains a value
///< that is invalid.
///< that is invalid.
COI_NOT_SUPPORTED, ///< This function is not currently
///< supported as used.
///< supported as used.
COI_TIME_OUT_REACHED, ///< The specified time out caused the
///< function to abort.
///< function to abort.
COI_MEMORY_OVERLAP, ///< The source and destination range
///< specified overlaps for the same
///< buffer.
///< specified overlaps for the same
///< buffer.
COI_ARGUMENT_MISMATCH, ///< The specified arguments are not
///< compatible.
///< compatible.
COI_SIZE_MISMATCH, ///< The specified size does not match the
///< expected size.
///< expected size.
COI_OUT_OF_MEMORY, ///< The function was unable to allocate
///< the required memory.
///< the required memory.
COI_INVALID_HANDLE, ///< One of the provided handles was not
///< valid.
///< valid.
COI_RETRY, ///< This function currently can't
///< complete, but might be able to later.
///< 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.
///< unlocked, but was locked.
COI_NOT_LOCKED, ///< The object was expected to be locked,
///< but was unlocked.
///< but was unlocked.
COI_MISSING_DEPENDENCY, ///< One or more dependent components
///< could not be found.
///< could not be found.
COI_UNDEFINED_SYMBOL, ///< One or more symbols the component
///< required was not defined in any
///< library.
///< 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.
///< the specified hardware.
COI_PROCESS_DIED,
COI_INVALID_FILE, ///< The file is invalid for its intended
///< usage in the function.
///< usage in the function.
COI_EVENT_CANCELED, ///< Event wait on a user event that
///< was unregistered or is being
///< unregistered returns
///< COI_EVENT_CANCELED.
///< 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.
///< 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.
///< 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 can not find user.
///< the user that requested an engine.
///< Only reported if daemon is set up for
///< authorization. Is also reported in
///< Windows if host can not 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;
} COIRESULT;
//////////////////////////////////////////////////////////////////////////////
///
......@@ -133,9 +135,9 @@ COIRESULT;
/// @return String version of the passed in COIRESULT code.
///
COIACCESSAPI
const char*
const char *
COIResultGetName(
COIRESULT in_ResultCode);
COIRESULT in_ResultCode);
#ifdef __cplusplus
} /* extern "C" */
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -48,10 +48,10 @@
* @file common/COITypes_common.h
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include <stdint.h>
#include <wchar.h>
#define COIACCESSAPI /* nothing */
#define COIACCESSAPI2 /* nothing */
#include <stdint.h>
#include <wchar.h>
#define COIACCESSAPI /* nothing */
#define COIACCESSAPI2 /* nothing */
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
......@@ -60,16 +60,19 @@ extern "C" {
#endif
struct coievent { uint64_t opaque[2]; };
struct coievent
{
uint64_t opaque[2];
};
typedef struct coiprocess * COIPROCESS;
typedef struct coipipeline * COIPIPELINE;
typedef struct coifunction * COIFUNCTION;
typedef struct coiengine * COIENGINE;
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 struct coibuffer *COIBUFFER;
typedef struct coilibrary *COILIBRARY;
typedef struct coimapinst *COIMAPINSTANCE;
typedef uint64_t COI_CPU_MASK[16];
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -48,8 +48,8 @@
* @file sink\COIBuffer_sink.h
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "../common/COITypes_common.h"
#include "../common/COIResult_common.h"
#include "../common/COITypes_common.h"
#include "../common/COIResult_common.h"
#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifdef __cplusplus
......@@ -85,7 +85,7 @@ extern "C" {
///
COIRESULT
COIBufferAddRef(
void* in_pBuffer);
void *in_pBuffer);
//////////////////////////////////////////////////////////////////////////////
......@@ -121,7 +121,7 @@ COIBufferAddRef(
///
COIRESULT
COIBufferReleaseRef(
void* in_pBuffer);
void *in_pBuffer);
#ifdef __cplusplus
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -52,9 +52,9 @@
#include "../common/COIResult_common.h"
#ifdef __FreeBSD__
#define COINATIVELIBEXPORT_VISIBILITY "extern"
#define COINATIVELIBEXPORT_VISIBILITY "extern"
#else
#define COINATIVELIBEXPORT_VISIBILITY "default"
#define COINATIVELIBEXPORT_VISIBILITY "default"
#endif
#ifdef __cplusplus
......@@ -106,13 +106,13 @@ extern "C" {
///
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);
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);
///////////////////////////////////////////////////////////////////////////////
///
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -96,6 +96,75 @@ COIProcessWaitForShutdown();
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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -48,10 +48,10 @@
* @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"
#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
......@@ -85,8 +85,8 @@ typedef struct COI_ENGINE_INFO
/// The version string identifying the driver.
coi_wchar_t DriverVersion[COI_MAX_DRIVER_VERSION_STR_LEN];
/// The ISA supported by the engine.
COI_ISA_TYPE ISA;
/// The DeviceType supported by the engine.
COI_DEVICE_TYPE ISA;
/// The number of cores on the engine.
uint32_t NumCores;
......@@ -134,9 +134,9 @@ typedef struct COI_ENGINE_INFO
///////////////////////////////////////////////////////////////////////////////
///
/// Returns information related to a specified engine. Note that if Intel(R)
/// Coprocessor Offload Infrastructure (Intel(R) COI) is unable to query
/// a value it will be returned as zero but the call will still succeed.
/// 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
......@@ -165,26 +165,19 @@ typedef struct COI_ENGINE_INFO
COIACCESSAPI
COIRESULT
COIEngineGetInfo(
COIENGINE in_EngineHandle,
uint32_t in_EngineInfoSize,
COI_ENGINE_INFO* out_pEngineInfo);
COIENGINE in_EngineHandle,
uint32_t in_EngineInfoSize,
COI_ENGINE_INFO *out_pEngineInfo);
///////////////////////////////////////////////////////////////////////////////
///
/// Returns the number of engines in the system that match the provided ISA.
/// Returns the number of engines in the system that match the provided device type.
///
/// Note that while it is possible to enumerate different types of Intel(R)
/// Xeon Phi(TM) coprocessors on a single host this is not currently
/// supported. Intel(R) Coprocessor Offload Infrastructure (Intel(R) COI)
/// makes an assumption that all Intel(R) Xeon Phi(TM) coprocessors found
/// in the system are the same architecture as the first coprocessor device.
/// The number of available coprocessor devices (i.e. cards connected via PCIe)
/// is detected by the COI runtime.
///
/// Also, note that this function returns the number of engines that Intel(R)
/// Coprocessor Offload Infrastructure (Intel(R) COI) is able to detect. Not
/// all of them may be online.
///
/// @param in_ISA
/// @param in_DeviceType
/// [in] Specifies the ISA type of the engine requested.
///
/// @param out_pNumEngines
......@@ -193,38 +186,40 @@ COIEngineGetInfo(
///
/// @return COI_SUCCESS if the function completed without error.
///
/// @return COI_DOES_NOT_EXIST if the in_ISA parameter is not valid.
/// @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_ISA_TYPE in_ISA,
uint32_t* out_pNumEngines);
COI_DEVICE_TYPE in_DeviceType,
uint32_t *out_pNumEngines);
///////////////////////////////////////////////////////////////////////////////
///
/// Returns the handle of a user specified engine.
///
/// @param in_ISA
/// @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_ISA parameter.
/// collection is defined by the in_DeviceType parameter.
///
/// @param out_pEngineHandle
/// [out] The address of an COIENGINE handle.
/// [out] The address of a COIENGINE handle.
///
/// @return COI_SUCCESS if the function completed without error.
///
/// @return COI_DOES_NOT_EXIST if the in_ISA parameter is not valid.
/// @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_ISA parameter.
/// the number of engines that match the in_DeviceType parameter.
///
/// @return COI_INVALID_POINTER if the out_pEngineHandle parameter is NULL.
///
......@@ -237,9 +232,37 @@ COIEngineGetCount(
COIACCESSAPI
COIRESULT
COIEngineGetHandle(
COI_ISA_TYPE in_ISA,
uint32_t in_EngineIndex,
COIENGINE* out_pEngineHandle);
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" */
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -147,12 +147,12 @@ extern "C" {
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);
uint16_t in_NumEvents,
const COIEVENT *in_pEvents,
int32_t in_TimeoutMilliseconds,
uint8_t in_WaitForAll,
uint32_t *out_pNumSignaled,
uint32_t *out_pSignaledIndices);
......@@ -174,7 +174,7 @@ COIEventWait(
COIACCESSAPI
COIRESULT
COIEventRegisterUserEvent(
COIEVENT* out_pEvent);
COIEVENT *out_pEvent);
///////////////////////////////////////////////////////////////////////////////
......@@ -188,12 +188,12 @@ COIEventRegisterUserEvent(
///
/// @return COI_INVALID_HANDLE if in_Event is not a UserEvent
///
/// @return COI_SUCCESS an event is successfully registered
/// @return COI_SUCCESS if an event is successfully unregistered
///
COIACCESSAPI
COIRESULT
COIEventUnregisterUserEvent(
COIEVENT in_Event);
COIEVENT in_Event);
//////////////////////////////////////////////////////////////////////////////
......@@ -225,9 +225,9 @@ COIEventUnregisterUserEvent(
/// they can interpret it as they choose.
///
typedef void (*COI_EVENT_CALLBACK)(
COIEVENT in_Event,
COIEVENT in_Event,
const COIRESULT in_Result,
const void* in_UserData);
const void *in_UserData);
......@@ -285,10 +285,10 @@ typedef void (*COI_EVENT_CALLBACK)(
COIACCESSAPI
COIRESULT
COIEventRegisterCallback(
const COIEVENT in_Event,
COI_EVENT_CALLBACK in_Callback,
const void* in_UserData,
const uint64_t in_Flags);
const COIEVENT in_Event,
COI_EVENT_CALLBACK in_Callback,
const void *in_UserData,
const uint64_t in_Flags);
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......@@ -159,10 +159,10 @@ typedef enum COI_ACCESS_FLAGS
COIACCESSAPI
COIRESULT
COIPipelineCreate(
COIPROCESS in_Process,
COI_CPU_MASK in_Mask,
uint32_t in_StackSize,
COIPIPELINE* out_pPipeline);
COIPROCESS in_Process,
COI_CPU_MASK in_Mask,
uint32_t in_StackSize,
COIPIPELINE *out_pPipeline);
///////////////////////////////////////////////////////////////////////////////
///
......@@ -177,7 +177,7 @@ COIPipelineCreate(
COIACCESSAPI
COIRESULT
COIPipelineDestroy(
COIPIPELINE in_Pipeline);
COIPIPELINE in_Pipeline);
//////////////////////////////////////////////////////////////////////////////
......@@ -194,8 +194,8 @@ COIPipelineDestroy(
/// 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. Pinned buffers and buffers that
/// are AddRef'd need to be accounted for available memory space. In other
/// 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
......@@ -322,8 +322,8 @@ COIPipelineDestroy(
/// @return COI_ARGUMENT_MISMATCH if in_pReturnValue is non-NULL but
/// in_ReturnValueLen is zero.
///
/// @return COI_RETRY if any input buffers, which are not pinned buffers,
/// are still mapped when passed to the run function.
/// @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.
......@@ -334,18 +334,18 @@ COIPipelineDestroy(
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);
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);
//////////////////////////////////////////////////////////////////////////////
......@@ -369,8 +369,8 @@ COIPipelineRunFunction(
COIACCESSAPI
COIRESULT
COIPipelineGetEngine(
COIPIPELINE in_Pipeline,
COIENGINE* out_pEngine);
COIPIPELINE in_Pipeline,
COIENGINE *out_pEngine);
//////////////////////////////////////////////////////////////////////////////
///
......@@ -404,10 +404,10 @@ COIPipelineGetEngine(
COIACCESSAPI
COIRESULT
COIPipelineSetCPUMask(
COIPROCESS in_Process,
uint32_t in_CoreID,
uint8_t in_ThreadID,
COI_CPU_MASK* out_pMask);
COIPROCESS in_Process,
uint32_t in_CoreID,
uint8_t in_ThreadID,
COI_CPU_MASK *out_pMask);
//////////////////////////////////////////////////////////////////////////////
///
......@@ -426,7 +426,7 @@ COIPipelineSetCPUMask(
COIACCESSAPI
COIRESULT
COIPipelineClearCPUMask(
COI_CPU_MASK* in_Mask);
COI_CPU_MASK *in_Mask);
#ifdef __cplusplus
} /* extern "C" */
......
/*
* Copyright 2010-2015 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.
*/
/**
Description: Define the types used by APIs of MYO programming.
*/
#ifndef _MYO_TYPES_H_
#define _MYO_TYPES_H_
#include <string.h> /* For size_t */
/** @ingroup MYO
* @addtogroup MYOTYPES
@{
* @file myotypes.h
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! MYO Status
*/
typedef enum {
MYO_SUCCESS = 0, /*!< Success */
MYO_ERROR, /*!< Error */
MYO_INVALID_ENV, /*!< Invalid Env */
MYO_INVALID_ARGUMENT, /*!< Invalid Argument */
MYO_NOT_INITIALIZED, /*!< Not Initialized */
MYO_ALREADY_FINALIZED,/*!< Already Finalized */
MYO_BUF_ERROR, /*!< Buffer Error */
MYO_OUT_OF_RANGE, /*!< Out of Range */
MYO_OUT_OF_MEMORY, /*!< Out of Memory */
MYO_ALREADY_EXISTS, /*!< Already Exists */
MYO_EOF, /*!< EOF */
MYO_FEATURE_NOT_IMPLEMENTED = -1, /*!< Feature not implemented (see myoiSupportsFeature(). */
} MyoError;
/*! Arena Ownership */
typedef enum {
MYO_ARENA_MINE = 1, /*!< Arena MINE Ownership */
MYO_ARENA_OURS, /*!< Arena OURS Ownership */
} MyoOwnershipType;
/*! MYO Features */
typedef enum {
/*!< EVERY VALUE that is less than MYO_FEATURE_BEGIN is not implemented. */
MYO_FEATURE_BEGIN = 1, /*!< The first feature that is supported. */
MYO_FEATURE_POST_LIB_INIT = MYO_FEATURE_BEGIN, /*!< Allows specifying a function to be executed immediately */
/* after myoiLibInit() completes. This feature was implemented in version */
/* 3.3 of MPSS. */
/* MYO_FEATURE_FUTURE_CAPABILITY = 2, at some time in the future, as new features are added to MYO, new enumeration constants */
/* will be added to the MyoFeatureType, and the value of the new enumeration constant will be greater */
/* than the current value of MYO_FEATURE_LAST constant, and then the MYO_FEATURE_LAST constant too, */
/* will be changed to be the value of the new enumeration constant. For example, in April, 2014, */
/* the POST_LIB_INIT feature was implemented in version 3.3 of MPSS, and the MYO_FEATURE_BEGIN */
/* enumeration constant is the same as the MYO_FEATURE_LAST enumeration constant, and both are equal */
/* to 1. */
/* Suppose in December, 2014, a new feature is added to the MYO library, for version 3.4 of MPSS. */
/* Then, MYO_FEATURE_BEGIN enumeration constant will be still the value 1, but the MYO_FEATURE_LAST */
/* enumeration constant will be set to 2. */
/* At runtime, one client binary can determine if the MYO that is installed is capable of any */
/* capability. For example, suppose a future client binary queries version 3.3 of MYO if it is */
/* capable of some future feature. Version 3.3 of MYO will indicate that the feature is not */
/* implemented to the client. But, conversely, suppose the future client queries version 3.4 of MYO */
/* if it is capable of some future feature. Version 3.4 of MYO will indicate that the feature isd */
/* supported. */
/* */
/* Date: | MYO_FEATURE_BEGIN: | MYO_FEATURE_LAST: | MPSS VERSION: | myoiSupportsFeature(MYO_FEATURE_FUTURE_CAPABILITY) */
/* ---------------+---------------------+--------------------+---------------+--------------------------------------------------- */
/* April, 2014 | 1 | 1 | 3.3 | MYO_FEATURE_NOT_IMPLEMENTED */
/* December, 2014 | 1 | 2 | 3.4 | MYO_SUCCESS */
/* ---------------+---------------------+--------------------+---------------+--------------------------------------------------- */
MYO_FEATURE_LAST = MYO_FEATURE_POST_LIB_INIT, /*!< The last feature that is supported. */
/*!< EVERY VALUE that is greater than MYO_FEATURE_LAST is not implemented. */
/*!< EVERY VALUE that is greater than or equal to MYO_FEATURE_BEGIN AND less than or equal to MYO_FEATURE_LAST is implemented. */
} MyoFeatureType; /* (For more information, please also see myoiSupportsFeature() function declaration.) */
/*************************************************************
* define the property of MYO Arena
***********************************************************/
#define MYO_CONSISTENCY_MODE 0x3
#define MYO_RELEASE_CONSISTENCY 0x1
#define MYO_STRONG_RELEASE_CONSISTENCY 0x2
#define MYO_STRONG_CONSISTENCY 0x3
#define MYO_UPDATE_ON_DEMAND 0x8
#define MYO_UPDATE_ON_ACQUIRE 0x10
#define MYO_RECORD_DIRTY 0x20
#define MYO_NOT_RECORD_DIRTY 0x40
#define MYO_ONE_VERSION 0x80
#define MYO_MULTI_VERSIONS 0x100
#define MYO_CONSISTENCY 0x200
#define MYO_NO_CONSISTENCY 0x400
#define MYO_HOST_TO_DEVICE 0x800
#define MYO_DEVICE_TO_HOST 0x1000
#define MYO_HYBRID_UPDATE 0x2000
typedef unsigned int MyoArena;
typedef void * MyoMutex;
typedef void * MyoSem;
typedef void * MyoBarrier;
#ifdef __cplusplus
}
#endif
#endif // _MYO_TYPES_H_
/*! @} */
......@@ -59,7 +59,7 @@ else # PLUGIN_TARGET
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 -lmyo-service -lgomp -rdynamic
AM_LDFLAGS = -L$(liboffload_dir)/.libs -L$(libgomp_dir)/.libs -loffloadmic_target -lcoi_device -lgomp -rdynamic
endif
main_target_image.h: offload_target_main
......
......@@ -326,7 +326,7 @@ target_install_dir = $(accel_search_dir)/lib/gcc/$(accel_target)/$(gcc_version)$
@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 -lmyo-service -lgomp -rdynamic
@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
......
/* Plugin for offload execution on Intel MIC devices.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
Copyright (C) 2014-2016 Free Software Foundation, Inc.
Contributed by Ilya Verbin <ilya.verbin@intel.com>.
......@@ -40,8 +40,6 @@
#include "main_target_image.h"
#include "gomp-constants.h"
#define LD_LIBRARY_PATH_ENV "LD_LIBRARY_PATH"
#define MIC_LD_LIBRARY_PATH_ENV "MIC_LD_LIBRARY_PATH"
#define OFFLOAD_ACTIVE_WAIT_ENV "OFFLOAD_ACTIVE_WAIT"
#ifdef DEBUG
......@@ -134,41 +132,12 @@ __attribute__((constructor))
static void
init (void)
{
const char *ld_lib_path = getenv (LD_LIBRARY_PATH_ENV);
const char *mic_lib_path = getenv (MIC_LD_LIBRARY_PATH_ENV);
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);
if (!ld_lib_path)
goto out;
/* Add path specified in LD_LIBRARY_PATH to MIC_LD_LIBRARY_PATH, which is
required by liboffloadmic. */
if (!mic_lib_path)
setenv (MIC_LD_LIBRARY_PATH_ENV, ld_lib_path, 1);
else
{
size_t len = strlen (mic_lib_path) + strlen (ld_lib_path) + 2;
bool use_alloca = len <= 2048;
char *mic_lib_path_new = (char *) (use_alloca ? alloca (len)
: malloc (len));
if (!mic_lib_path_new)
{
fprintf (stderr, "%s: Can't allocate memory\n", __FILE__);
exit (1);
}
sprintf (mic_lib_path_new, "%s:%s", mic_lib_path, ld_lib_path);
setenv (MIC_LD_LIBRARY_PATH_ENV, mic_lib_path_new, 1);
if (!use_alloca)
free (mic_lib_path_new);
}
out:
address_table = new ImgDevAddrMap;
image_descriptors = new ImgDescMap;
num_devices = _Offload_number_of_devices ();
......
/* Plugin for offload execution on Intel MIC devices.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
Copyright (C) 2014-2016 Free Software Foundation, Inc.
Contributed by Ilya Verbin <ilya.verbin@intel.com>.
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -395,4 +395,27 @@ void __arr_desc_dump(
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
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -66,6 +66,17 @@ struct CeanReadRanges {
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))
......@@ -108,6 +119,14 @@ DLL_LOCAL void __arr_desc_dump(
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);
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -456,7 +456,7 @@ bool init(void)
EngineGetInfo =
(COIRESULT (*)(COIENGINE, uint32_t, COI_ENGINE_INFO*))
DL_sym(lib_handle, "COIEngineGetInfo", COI_VERSION1);
if (COIEngineGetInfo == 0) {
if (EngineGetInfo == 0) {
OFFLOAD_DEBUG_TRACE(2, "Failed to find %s in COI library\n",
"COIEngineGetInfo");
fini();
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -34,6 +34,7 @@
#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>
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -161,6 +161,8 @@ extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
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,
......@@ -171,8 +173,8 @@ extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
// make sure libray is initialized and at least one device is available
if (!__offload_init_library()) {
LIBOFFLOAD_ERROR(c_device_is_not_available);
exit(1);
OFFLOAD_DEBUG_TRACE(2, "No device available, fall back to host\n");
return NULL;
}
// OFFLOAD_TIMER_INIT must follow call to __offload_init_library
......@@ -377,6 +379,10 @@ static int offload_offload_wrap(
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);
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -422,7 +422,7 @@ SYMBOL_VERSION (COIBufferCreate, 1) (uint64_t in_Size,
const int ullong_max_len = 20;
/* Features of liboffloadmic. */
assert (in_Type == COI_BUFFER_NORMAL);
assert (in_Type == COI_BUFFER_NORMAL || in_Type == COI_BUFFER_OPENCL);
assert ((in_Flags & COI_SINK_MEMORY) == 0);
assert ((in_Flags & COI_SAME_ADDRESS_SINKS) == 0);
assert ((in_Flags & COI_SAME_ADDRESS_SINKS_AND_SOURCE) == 0);
......@@ -1617,7 +1617,7 @@ SYMBOL_VERSION (COIEngineGetInfo, 1) (COIENGINE in_EngineHandle, // Ignored
assert (out_pEngineInfo != NULL);
out_pEngineInfo->ISA = COI_ISA_x86_64;
out_pEngineInfo->ISA = COI_DEVICE_KNL;
out_pEngineInfo->NumCores = 1;
out_pEngineInfo->NumThreads = 8;
out_pEngineInfo->CoreMaxFrequency = SYMBOL_VERSION(COIPerfGetCycleFrequency,1)() / 1000000;
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......
/*
* Copyright 2010-2015 Intel Corporation.
* 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
......
/*
Copyright (c) 2014-2015 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.
*/
/* We don't need to implement any MYO client functions. */
/*
Copyright (c) 2014-2015 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 "myo_service.h"
#include "myo_version_asm.h"
extern "C"
{
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoAcquire, 1) ()
{
MYOTRACE ("myoAcquire");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoRelease, 1) ()
{
MYOTRACE ("myoRelease");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI void
SYMBOL_VERSION (myoSharedAlignedFree, 1) (void *ptr)
{
MYOTRACE ("myoSharedAlignedFree");
assert (false);
}
MYOACCESSAPI void*
SYMBOL_VERSION (myoSharedAlignedMalloc, 1) (size_t size,
size_t alignment)
{
MYOTRACE ("myoSharedAlignedMalloc");
assert (false);
return 0;
}
MYOACCESSAPI void
SYMBOL_VERSION (myoSharedFree, 1) (void *ptr)
{
MYOTRACE ("myoSharedFree");
assert (false);
}
MYOACCESSAPI void*
SYMBOL_VERSION (myoSharedMalloc, 1) (size_t size)
{
MYOTRACE ("myoSharedMalloc");
assert (false);
return 0;
}
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoiLibInit, 1) (void *args,
void *init_func)
{
MYOTRACE ("myoiLibInit");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI void
SYMBOL_VERSION (myoiLibFini, 1) ()
{
MYOTRACE ("myoiLibFini");
assert (false);
}
MyoError
SYMBOL_VERSION (myoiMicVarTableRegister, 1) (void *table,
int num)
{
MYOTRACE ("myoiMicVarTableRegister");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoiRemoteFuncRegister, 1) (MyoiRemoteFuncType type,
const char *name)
{
MYOTRACE ("myoiRemoteFuncRegister");
/* Looks like we have nothing to do here. */
return MYO_SUCCESS;
}
MyoError
SYMBOL_VERSION (myoiTargetFptrTableRegister, 1) (void *table,
int num,
int ordered)
{
MYOTRACE ("myoiTargetFptrTableRegister");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoArenaRelease, 1) (MyoArena in_Arena)
{
MYOTRACE ("myoArenaRelease");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI MyoError
SYMBOL_VERSION (myoArenaAcquire, 1) (MyoArena in_Arena)
{
MYOTRACE ("myoArenaAcquire");
assert (false);
return MYO_ERROR;
}
MYOACCESSAPI void
SYMBOL_VERSION (myoArenaAlignedFree, 1) (MyoArena in_Arena, void *in_pPtr)
{
MYOTRACE ("myoArenaAlignedFree");
assert (false);
}
MYOACCESSAPI void *
SYMBOL_VERSION (myoArenaAlignedMalloc, 1) (MyoArena in_Arena, size_t in_Size,
size_t in_Alignment)
{
MYOTRACE ("myoArenaAlignedMalloc");
assert (false);
return 0;
}
} // extern "C"
/*
Copyright (c) 2014-2015 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 MYO_SERVICE_H_INCLUDED
#define MYO_SERVICE_H_INCLUDED
#include <myo.h>
#include <myoimpl.h>
#include <myotypes.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define SYMBOL_VERSION(SYMBOL,VERSION) SYMBOL ## VERSION
#define MYOERROR(...) \
{ \
fprintf (stderr, "MYO ERROR - TARGET: "); \
fprintf (stderr, __VA_ARGS__); \
fprintf (stderr, "\n"); \
perror (NULL); \
return MYO_ERROR; \
}
#ifdef DEBUG
#define MYOTRACE(...) \
{ \
fprintf (stderr, "MYO TRACE - TARGET: "); \
fprintf (stderr, __VA_ARGS__); \
fprintf (stderr, "\n"); \
}
#else
#define MYOTRACE(...) {}
#endif
#endif // MYO_SERVICE_H_INCLUDED
/*
* Copyright 2010-2015 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.
*/
/*Version for Symbols( only Functions currently versioned)
Only that Linux Host Side code is versioned currently*/
#if (! defined MYO_MIC_CARD) && (! defined _WIN32)
__asm__(".symver myoArenaAlignedMalloc1,myoArenaAlignedMalloc@@MYO_1.0");
__asm__(".symver myoArenaAlignedFree1,myoArenaAlignedFree@@MYO_1.0");
__asm__(".symver myoArenaAcquire1,myoArenaAcquire@@MYO_1.0");
__asm__(".symver myoArenaRelease1,myoArenaRelease@@MYO_1.0");
__asm__(".symver myoAcquire1,myoAcquire@@MYO_1.0");
__asm__(".symver myoRelease1,myoRelease@@MYO_1.0");
__asm__(".symver myoSharedAlignedFree1,myoSharedAlignedFree@@MYO_1.0");
__asm__(".symver myoSharedAlignedMalloc1,myoSharedAlignedMalloc@@MYO_1.0");
__asm__(".symver myoSharedFree1,myoSharedFree@@MYO_1.0");
__asm__(".symver myoSharedMalloc1,myoSharedMalloc@@MYO_1.0");
__asm__(".symver myoiLibInit1,myoiLibInit@@MYO_1.0");
__asm__(".symver myoiLibFini1,myoiLibFini@@MYO_1.0");
__asm__(".symver myoiMicVarTableRegister1,myoiMicVarTableRegister@@MYO_1.0");
__asm__(".symver myoiRemoteFuncRegister1,myoiRemoteFuncRegister@@MYO_1.0");
__asm__(".symver myoiTargetFptrTableRegister1,myoiTargetFptrTableRegister@@MYO_1.0");
#endif
/*
* Copyright 2010-2015 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.
***/
MYO_1.0
{
global:
myoArenaAlignedMalloc;
myoArenaAlignedFree;
myoArenaAcquire;
myoArenaRelease;
myoAcquire;
myoRelease;
myoSharedAlignedFree;
myoSharedAlignedMalloc;
myoSharedFree;
myoSharedMalloc;
myoiLibInit;
myoiLibFini;
myoiMicVarTableRegister;
myoiRemoteFuncRegister;
myoiTargetFptrTableRegister;
local:
*;
};
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -63,6 +63,9 @@ void __liboffload_error_support(error_types input_tag, ...)
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;
......@@ -70,7 +73,7 @@ void __liboffload_error_support(error_types input_tag, ...)
write_message(stderr, msg_c_offload1, args);
break;
case c_unknown_var_type:
write_message(stderr, c_unknown_var_type, args);
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);
......@@ -129,6 +132,21 @@ void __liboffload_error_support(error_types input_tag, ...)
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;
......@@ -270,21 +288,34 @@ void __liboffload_error_support(error_types input_tag, ...)
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;
......@@ -297,6 +328,15 @@ void __liboffload_error_support(error_types input_tag, ...)
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);
}
......@@ -422,6 +462,7 @@ char const * report_get_message_str(error_types input_tag)
LIBOFFLOAD_ERROR(c_report_unknown_trace_node);
abort();
}
return 0;
}
char const * report_get_host_stage_str(int i)
......@@ -483,6 +524,7 @@ char const * report_get_host_stage_str(int i)
LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
abort();
}
return 0;
}
char const * report_get_target_stage_str(int i)
......@@ -515,4 +557,5 @@ char const * report_get_target_stage_str(int i)
LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
abort();
}
return 0;
}
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -43,6 +43,7 @@ typedef enum
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,
......@@ -63,6 +64,11 @@ typedef enum
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,
......@@ -107,6 +113,7 @@ typedef enum
c_no_target_exe,
c_incorrect_affinity,
c_cannot_set_affinity,
c_mixed_versions,
c_report_host,
c_report_target,
c_report_title,
......@@ -172,15 +179,21 @@ typedef enum
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_unload_library,
c_target_myo_library,
c_myo_dl_sym,
c_bad_myo_free
} error_types;
enum OffloadHostPhase {
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
!
! Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
! 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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -35,16 +35,19 @@
#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 not compatible with Windows
// <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
......@@ -93,7 +96,7 @@ typedef struct {
size_t data_received; /* number of bytes received by host */
} _Offload_status;
typedef uint64_t _Offload_stream;
typedef int64_t _Offload_stream;
#define OFFLOAD_STATUS_INIT(x) \
((x).result = OFFLOAD_DISABLED)
......@@ -119,11 +122,23 @@ extern int _Offload_stream_destroy(
_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
......@@ -165,6 +180,129 @@ 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(
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,
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,
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(
void *host_ptr,
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(
void *host_ptr,
int device_num
) __GOMP_NOTHROW;
// End of OpenMP 4.5 APIs
/* OpenMP API wrappers */
/* Set num_threads on target */
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -58,6 +58,10 @@
#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
......@@ -181,15 +185,30 @@ enum OffloadItemType {
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_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)
(t) == c_dv_ptr || \
TYPE_IS_PTR_TO_PTR(t))
#define VAR_TYPE_IS_SCALAR(t) ((t) == c_data || \
(t) == c_void_ptr || \
......@@ -202,7 +221,6 @@ enum OffloadItemType {
#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
......@@ -228,7 +246,7 @@ union varDescFlags {
uint32_t targetptr : 1;
//! "preallocated" modifier used
uint32_t preallocated : 1;
//! Needs documentation
//! pointer to a pointer array
uint32_t is_pointer : 1;
//! buffer address is sent in data
......@@ -244,8 +262,14 @@ union varDescFlags {
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;
};
......@@ -384,6 +408,21 @@ 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
{
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -39,7 +39,7 @@
#include "offload_common.h"
#include "coi/coi_client.h"
#define SIGNAL_IS_REMOVED ((OffloadDescriptor *)-1)
#define SIGNAL_HAS_COMPLETED ((OffloadDescriptor *)-1)
const int64_t no_stream = -1;
// Address range
......@@ -83,7 +83,7 @@ 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)
ref_count(0), is_static(false), is_omp_associate(false)
{}
//
......@@ -93,7 +93,9 @@ public:
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)
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 {
......@@ -104,7 +106,7 @@ public:
}
long add_reference() {
if (is_static) {
if (is_omp_associate || (is_static && !var_alloc_type)) {
return LONG_MAX;
}
#ifndef TARGET_WINNT
......@@ -115,7 +117,7 @@ public:
}
long remove_reference() {
if (is_static) {
if (is_omp_associate || (is_static && !var_alloc_type)) {
return LONG_MAX;
}
#ifndef TARGET_WINNT
......@@ -126,7 +128,7 @@ public:
}
long get_reference() const {
if (is_static) {
if (is_omp_associate || (is_static && !var_alloc_type)) {
return LONG_MAX;
}
return ref_count;
......@@ -151,6 +153,11 @@ public:
// 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:
......@@ -362,10 +369,16 @@ struct Stream
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();
all_streams[++m_streams_count] = new Stream(device, number_of_cpus);
result = ++m_streams_count;
all_streams[m_streams_count] = new Stream(device, number_of_cpus);
m_stream_lock.unlock();
return(m_streams_count);
return(result);
}
static uint64_t get_streams_count() {
return m_streams_count;
}
typedef std::map<uint64_t, Stream*> StreamMap;
......@@ -390,12 +403,21 @@ struct Stream
};
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) { \
......@@ -420,6 +442,10 @@ struct Engine {
return m_process;
}
bool get_ready() {
return m_ready;
}
uint64_t get_thread_id(void);
// initialize device
......@@ -539,7 +565,7 @@ struct Engine {
if (it != m_signal_map.end()) {
desc = it->second;
if (remove) {
it->second = SIGNAL_IS_REMOVED;
it->second = SIGNAL_HAS_COMPLETED;
}
}
}
......@@ -548,8 +574,23 @@ struct Engine {
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() {
......@@ -564,10 +605,11 @@ struct Engine {
private:
Engine() : m_index(-1), m_physical_index(-1), m_process(0), m_ready(false),
m_proc_number(0)
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;
......@@ -576,6 +618,9 @@ private:
if (m_process != 0) {
fini_process(false);
}
if (m_assigned_cpus) {
delete m_assigned_cpus;
}
}
// set indexes
......@@ -584,6 +629,12 @@ private:
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();
......@@ -611,6 +662,9 @@ private:
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;
......@@ -634,11 +688,12 @@ private:
mutex_t m_signal_lock;
// streams
StreamMap m_stream_map;
mutex_t m_stream_lock;
int m_num_cores;
int m_num_threads;
std::bitset<COI_MAX_HW_THREADS> m_cpus;
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;
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -212,14 +212,14 @@ MicEnvVarKind MicEnvVar::get_env_var_kind(
*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);
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);
if (*env_var_def == NULL)
LIBOFFLOAD_ERROR(c_malloc);
return c_mic_card_env;
}
if (isalpha(*c)) {
......@@ -234,7 +234,7 @@ MicEnvVarKind MicEnvVar::get_env_var_kind(
}
*env_var_def = strdup(*env_var_def);
if (*env_var_def == NULL)
LIBOFFLOAD_ERROR(c_malloc);
LIBOFFLOAD_ERROR(c_malloc);
return card_is_set? c_mic_card_var : c_mic_var;
}
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -88,6 +88,8 @@ public:
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),
......@@ -102,6 +104,8 @@ public:
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;
......@@ -146,6 +150,24 @@ public:
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,
......@@ -183,19 +205,34 @@ private:
bool receive_pointer_data(bool is_async, bool first_run, void * info);
bool scatter_copyout_data();
void cleanup();
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 *is_new);
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);
......@@ -205,10 +242,20 @@ private:
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;
......@@ -220,11 +267,17 @@ private:
int64_t cpu_disp;
int64_t cpu_offset;
void *alloc;
CeanReadRanges *read_rng_src;
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 {
......@@ -320,17 +373,36 @@ private:
// 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;
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;
......@@ -396,8 +468,11 @@ DLL_LOCAL extern MicEnvVar mic_env_vars;
// CPU frequency
DLL_LOCAL extern uint64_t cpu_frequency;
// LD_LIBRARY_PATH for MIC libraries
DLL_LOCAL extern char* mic_library_path;
// 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;
......@@ -427,6 +502,11 @@ 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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 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_MYO_HOST_H_INCLUDED
#define OFFLOAD_MYO_HOST_H_INCLUDED
#include <myotypes.h>
#include <myoimpl.h>
#include <myo.h>
#include "offload.h"
// undefine the following since offload.h defines them to malloc and free if __INTEL_OFFLOAD
// is not defined which is the case when building the offload library
#undef _Offload_shared_malloc
#undef _Offload_shared_free
#undef _Offload_shared_aligned_malloc
#undef _Offload_shared_aligned_free
#include "offload_table.h"
// This function retained for compatibility with 15.0
extern "C" void __offload_myoRegisterTables(
InitTableEntry *init_table,
SharedTableEntry *shared_table,
FptrTableEntry *fptr_table
);
// Process shared variable, shared vtable and function and init routine tables.
// In .dlls/.sos these will be collected together.
// In the main program, all collected tables will be processed.
extern "C" bool __offload_myoProcessTables(
const void* image,
MYOInitTableList::Node *init_table,
MYOVarTableList::Node *shared_table,
MYOVarTableList::Node *shared_vtable,
MYOFuncTableList::Node *fptr_table
);
extern void __offload_myoFini(void);
extern bool __offload_myo_init_is_deferred(const void *image);
#endif // OFFLOAD_MYO_HOST_H_INCLUDED
/*
Copyright (c) 2014-2015 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_myo_target.h"
#include "offload_target.h"
extern "C" void __cilkrts_cilk_for_32(void*, void*, uint32_t, int32_t);
extern "C" void __cilkrts_cilk_for_64(void*, void*, uint64_t, int32_t);
#pragma weak __cilkrts_cilk_for_32
#pragma weak __cilkrts_cilk_for_64
static void CheckResult(const char *func, MyoError error) {
if (error != MYO_SUCCESS) {
LIBOFFLOAD_ERROR(c_myotarget_checkresult, func, error);
exit(1);
}
}
static void __offload_myo_shared_table_process(SharedTableEntry *entry)
{
int entries = 0;
SharedTableEntry *t_start;
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, entry);
t_start = entry;
while (t_start->varName != 0) {
OFFLOAD_DEBUG_TRACE_1(4, 0, c_offload_mic_myo_shared,
"myo shared entry name = \"%s\" addr = %p\n",
t_start->varName, t_start->sharedAddr);
t_start++;
entries++;
}
if (entries > 0) {
OFFLOAD_DEBUG_TRACE(3, "myoiMicVarTableRegister(%p, %d)\n", entry,
entries);
CheckResult("myoiMicVarTableRegister",
myoiMicVarTableRegister(entry, entries));
}
}
static void __offload_myo_shared_vtable_process(SharedTableEntry *entry)
{
int entries = 0;
SharedTableEntry *t_start;
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, entry);
t_start = entry;
while (t_start->varName != 0) {
OFFLOAD_DEBUG_TRACE_1(4, 0, c_offload_mic_myo_shared,
"myo shared vtable entry name"
" = \"%s\" addr = %p\n",
t_start->varName, t_start->sharedAddr);
t_start++;
entries++;
}
if (entries > 0) {
OFFLOAD_DEBUG_TRACE(3, "myoiMicVarTableRegister(%p, %d)\n", entry,
entries);
CheckResult("myoiMicVarTableRegister",
myoiMicVarTableRegister(entry, entries));
}
}
static void __offload_myo_fptr_table_process(
FptrTableEntry *entry
)
{
int entries = 0;
FptrTableEntry *t_start;
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, entry);
t_start = entry;
while (t_start->funcName != 0) {
OFFLOAD_DEBUG_TRACE_1(4, 0, c_offload_mic_myo_fptr,
"myo fptr entry name = \"%s\" addr = %p\n",
t_start->funcName, t_start->funcAddr);
t_start++;
entries++;
}
if (entries > 0) {
OFFLOAD_DEBUG_TRACE(3, "myoiTargetFptrTableRegister(%p, %d, 0)\n",
entry, entries);
CheckResult("myoiTargetFptrTableRegister",
myoiTargetFptrTableRegister(entry, entries, 0));
}
}
void __offload_myo_shared_init_table_process(InitTableEntry* entry)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, entry);
for (; entry->func != 0; entry++) {
// Invoke the function to init the shared memory
OFFLOAD_DEBUG_TRACE(3, "Invoked a shared init function @%p\n",
(void *)(entry->func));
entry->func();
}
}
extern "C" void __offload_myoAcquire(void)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
CheckResult("myoAcquire", myoAcquire());
}
extern "C" void __offload_myoRelease(void)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
CheckResult("myoRelease", myoRelease());
}
extern "C" void __intel_cilk_for_32_offload_wrapper(void *args_)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
struct S {
void *M1;
unsigned int M2;
unsigned int M3;
char closure[];
} *args = (struct S*) args_;
__cilkrts_cilk_for_32(args->M1, args->closure, args->M2, args->M3);
}
extern "C" void __intel_cilk_for_64_offload_wrapper(void *args_)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
struct S {
void *M1;
uint64_t M2;
uint64_t M3;
char closure[];
} *args = (struct S*) args_;
__cilkrts_cilk_for_64(args->M1, args->closure, args->M2, args->M3);
}
static void __offload_myo_once_init(void)
{
CheckResult("myoiRemoteFuncRegister",
myoiRemoteFuncRegister(
(MyoiRemoteFuncType) __intel_cilk_for_32_offload_wrapper,
"__intel_cilk_for_32_offload"));
CheckResult("myoiRemoteFuncRegister",
myoiRemoteFuncRegister(
(MyoiRemoteFuncType) __intel_cilk_for_64_offload_wrapper,
"__intel_cilk_for_64_offload"));
}
extern "C" void __offload_myoRegisterTables(
SharedTableEntry *shared_table,
FptrTableEntry *fptr_table
)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
// one time registration of Intel(R) Cilk(TM) language entries
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
pthread_once(&once_control, __offload_myo_once_init);
// register module's tables
if (shared_table->varName == 0 && fptr_table->funcName == 0) {
return;
}
__offload_myo_shared_table_process(shared_table);
__offload_myo_fptr_table_process(fptr_table);
}
extern "C" void __offload_myoProcessTables(
InitTableEntry* init_table,
SharedTableEntry *shared_table,
SharedTableEntry *shared_vtable,
FptrTableEntry *fptr_table
)
{
OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
// one time registration of Intel(R) Cilk(TM) language entries
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
pthread_once(&once_control, __offload_myo_once_init);
// register module's tables
// check slot-1 of the function table because
// slot-0 is predefined with --vtable_initializer--
if (shared_table->varName == 0 &&
shared_vtable->varName == 0 &&
fptr_table[1].funcName == 0) {
return;
}
__offload_myo_shared_table_process(shared_table);
__offload_myo_shared_vtable_process(shared_vtable);
__offload_myo_fptr_table_process(fptr_table);
}
extern "C" void* _Offload_shared_malloc(size_t size)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%lld)\n", __func__, size);
return myoSharedMalloc(size);
}
extern "C" void _Offload_shared_free(void *ptr)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, ptr);
myoSharedFree(ptr);
}
extern "C" void* _Offload_shared_aligned_malloc(size_t size, size_t align)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%lld, %lld)\n", __func__, size, align);
return myoSharedAlignedMalloc(size, align);
}
extern "C" void _Offload_shared_aligned_free(void *ptr)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%p)\n", __func__, ptr);
myoSharedAlignedFree(ptr);
}
extern "C" void* _Offload_shared_aligned_arena_malloc(
MyoArena arena,
size_t size,
size_t align
)
{
OFFLOAD_DEBUG_TRACE(
3, "%s(%u, %lld, %lld)\n", __func__, arena, size, align);
return myoArenaAlignedMalloc(arena, size, align);
}
extern "C" void _Offload_shared_aligned_arena_free(
MyoArena arena,
void *ptr
)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%u, %p)\n", __func__, arena, ptr);
myoArenaAlignedFree(arena, ptr);
}
extern "C" void _Offload_shared_arena_acquire(
MyoArena arena
)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%u)\n", __func__, arena);
myoArenaAcquire(arena);
}
extern "C" void _Offload_shared_arena_release(
MyoArena arena
)
{
OFFLOAD_DEBUG_TRACE(3, "%s(%u)\n", __func__, arena);
myoArenaRelease(arena);
}
// temporary workaround for blocking behavior of myoiLibInit/Fini calls
extern "C" void __offload_myoLibInit()
{
OFFLOAD_DEBUG_TRACE(3, "%s()\n", __func__);
CheckResult("myoiLibInit", myoiLibInit(0, 0));
}
extern "C" void __offload_myoLibFini()
{
OFFLOAD_DEBUG_TRACE(3, "%s()\n", __func__);
myoiLibFini();
}
/*
Copyright (c) 2014-2015 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_MYO_TARGET_H_INCLUDED
#define OFFLOAD_MYO_TARGET_H_INCLUDED
#include "offload.h"
// undefine the following since offload.h defines them to malloc and free if __INTEL_OFFLOAD
// is not defined which is the case when building the offload library
#undef _Offload_shared_malloc
#undef _Offload_shared_free
#undef _Offload_shared_aligned_malloc
#undef _Offload_shared_aligned_free
#include "offload_table.h"
// This function retained for compatibility with 15.0
extern "C" void __offload_myoRegisterTables(
SharedTableEntry *shared_table,
FptrTableEntry *fptr_table
);
// Process shared variable, shared vtable and function and init routine tables.
// On the target side the contents of the tables are registered with MYO.
extern "C" void __offload_myoProcessTables(
InitTableEntry* init_table,
SharedTableEntry *shared_table,
SharedTableEntry *shared_vtable,
FptrTableEntry *fptr_table
);
extern "C" void __offload_myoAcquire(void);
extern "C" void __offload_myoRelease(void);
// Call the compiler-generated routines for initializing shared variables.
// This can only be done after shared memory allocation has been done.
extern void __offload_myo_shared_init_table_process(InitTableEntry* entry);
// temporary workaround for blocking behavior for myoiLibInit/Fini calls
extern "C" void __offload_myoLibInit();
extern "C" void __offload_myoLibFini();
#endif // OFFLOAD_MYO_TARGET_H_INCLUDED
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -48,6 +48,182 @@ 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 = &parameters;
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,
&parameters.array_info[0],
&parameters.array_info[parameters.num_dims],
&parameters.array_info[parameters.num_dims*2],
&parameters.array_info[parameters.num_dims*3],
&parameters.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(
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -31,6 +31,16 @@
#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*);
......@@ -55,6 +65,12 @@ 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",
......@@ -98,6 +114,15 @@ static FuncTable::Entry predefined_entries[] = {
"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
};
......@@ -113,6 +138,28 @@ FuncList __offload_entries(&predefined_table);
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;
......@@ -296,6 +343,62 @@ void VarList::table_patch_names(void *buf, int64_t nelems)
}
}
#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,
......@@ -311,6 +414,17 @@ extern "C" void __offload_register_tables(
__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);
}
......@@ -329,6 +443,14 @@ extern "C" void __offload_unregister_tables(
__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);
}
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -37,6 +37,9 @@
#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:
......@@ -135,6 +138,15 @@ private:
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
......@@ -152,12 +164,8 @@ struct VarTable {
void* addr; //!< Address of the variable
#if HOST_LIBRARY
VAR_ALLOC_TYPE var_alloc_type;
uint64_t size;
#ifdef TARGET_WINNT
// padding to make entry size a power of 2
uint64_t padding;
#endif // TARGET_WINNT
#endif
};
......@@ -240,6 +248,9 @@ DLL_LOCAL extern VarList __offload_vars;
#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,
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -43,6 +43,7 @@ public:
~OffloadDescriptor() {
if (m_vars != 0) {
free(m_vars);
free(m_vars_extra);
}
}
......@@ -96,6 +97,14 @@ private:
VarDesc* m_vars;
int m_vars_total;
int m_offload_number;
// extra data associated with each variable descriptor
struct VarExtra {
uint16_t type_src;
uint16_t type_dst;
};
VarExtra* m_vars_extra;
};
// one time target initialization in main
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -30,12 +30,16 @@
#if HOST_LIBRARY
#include "offload_table.h"
#ifdef MYO_SUPPORT
#include "offload_myo_host.h"
#endif // MYO_SUPPORT
#else
#include "compiler_if_target.h"
#include "offload_target.h"
#ifdef MYO_SUPPORT
#include "offload_myo_target.h"
#endif
#endif // MYO_SUPPORT
#endif // HOST_LIBRARY
// Initializes library and registers specified offload image.
// Don't use this declarations from offload_host.h as offload_table.h
......@@ -254,6 +258,9 @@ static void offload_init()
{
bool success;
// Set offload version
__offload_set_version(OFFLOAD_VERSION_17);
// register offload tables
__offload_register_tables(&__offload_entry_node,
&__offload_func_node,
......@@ -295,8 +302,6 @@ static void offload_init()
#ifndef TARGET_WINNT
static void offload_fini_so() __attribute__((destructor(101)));
#else // TARGET_WINNT
static void offload_init_so();
#endif // TARGET_WINNT
static void offload_fini()
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......@@ -30,11 +30,15 @@
#if HOST_LIBRARY
#include "offload_table.h"
#ifdef MYO_SUPPORT
#include "offload_myo_host.h"
#endif // MYO_SUPPORT
#else
#include "offload_target.h"
#ifdef MYO_SUPPORT
#include "offload_myo_target.h"
#endif
#endif // MYO_SUPPORT
#endif // HOST_LIBRARY
#ifdef TARGET_WINNT
#define ALLOCATE(name) __declspec(allocate(name))
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
/*
Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment