[Beignet] [PATCH 5/6] Android: add android mk files.

Yang Rong rong.r.yang at intel.com
Mon Nov 9 18:40:16 PST 2015


Enable beignet's android make. Use libc++ as stl c++ library.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 Android.common.mk             |  30 +++++
 Android.mk                    |  14 +++
 backend/src/Android.mk        | 283 ++++++++++++++++++++++++++++++++++++++++++
 backend/src/libocl/Android.mk |  89 +++++++++++++
 src/Android.mk                | 123 ++++++++++++++++++
 utests/Android.mk             | 250 +++++++++++++++++++++++++++++++++++++
 6 files changed, 789 insertions(+)
 create mode 100644 Android.common.mk
 create mode 100644 Android.mk
 create mode 100644 backend/src/Android.mk
 create mode 100644 backend/src/libocl/Android.mk
 create mode 100644 src/Android.mk
 create mode 100644 utests/Android.mk

diff --git a/Android.common.mk b/Android.common.mk
new file mode 100644
index 0000000..27cccfb
--- /dev/null
+++ b/Android.common.mk
@@ -0,0 +1,30 @@
+#LOCAL_PATH:= $(call my-dir)
+
+#include $(CLEAR_VARS)
+TOP_C_INCLUDE := bionic $(BEIGNET_ROOT_PATH)/include
+TOP_CPPFLAGS := -Wall -Wno-invalid-offsetof -mfpmath=sse -fno-rtti -Wcast-align -std=c++0x -msse2 -msse3 -mssse3 -msse4.1 -D__ANDROID__
+TOP_CFLAGS := -Wall -mfpmath=sse -msse2 -Wcast-align -msse2 -msse3 -mssse3 -msse4.1 -D__ANDROID__
+
+LLVM_INCLUDE_DIRS := external/llvm/device/include\
+                     external/llvm/include \
+                     external/clang/include \
+                     
+LLVM_CFLAGS := -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
+LLVM_LFLAGS := -ldl -lm
+
+LLVM_FOUND := true
+
+DRM_INCLUDE_PATH := external/drm/intel external/drm/include/drm external/drm
+DRM_LIBRARY := libdrm
+DRM_FOUND := true
+
+THREAD_LIBS_INIT := libpthread
+
+DRM_INTEL_LIBRARY := libdrm_intel
+DRM_INTEL_FOUND := true
+
+GBE_LIBRARY := libgbe
+GBE_FOUND := false
+
+OCLIcd_FOUND := false
+
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..095f313
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+BEIGNET_ROOT_PATH := $(LOCAL_PATH)
+
+#subdirs := backend/src/libocl
+
+
+subdirs := backend/src/libocl \
+           backend/src \
+	   src \
+           utests \
+
+include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, $(subdirs)))
diff --git a/backend/src/Android.mk b/backend/src/Android.mk
new file mode 100644
index 0000000..9c93f81
--- /dev/null
+++ b/backend/src/Android.mk
@@ -0,0 +1,283 @@
+LOCAL_PATH:= $(call my-dir)
+include $(LOCAL_PATH)/../../Android.common.mk
+
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LLVM_ROOT_PATH := external/llvm
+CLANG_ROOT_PATH := external/clang
+
+include $(CLANG_ROOT_PATH)/clang.mk
+
+BACKEND_SRC_FILES:= \
+    ${ocl_blob_file} \
+    sys/vector.hpp \
+    sys/map.hpp \
+    sys/set.hpp \
+    sys/intrusive_list.hpp \
+    sys/intrusive_list.cpp \
+    sys/exception.hpp \
+    sys/assert.cpp \
+    sys/assert.hpp \
+    sys/alloc.cpp \
+    sys/alloc.hpp \
+    sys/mutex.cpp \
+    sys/mutex.hpp \
+    sys/platform.cpp \
+    sys/platform.hpp \
+    sys/cvar.cpp \
+    sys/cvar.hpp \
+    ir/context.cpp \
+    ir/context.hpp \
+    ir/profile.cpp \
+    ir/profile.hpp \
+    ir/type.cpp \
+    ir/type.hpp \
+    ir/unit.cpp \
+    ir/unit.hpp \
+    ir/constant.cpp \
+    ir/constant.hpp \
+    ir/sampler.cpp \
+    ir/sampler.hpp \
+    ir/image.cpp \
+    ir/image.hpp \
+    ir/half.cpp \
+    ir/half.hpp \
+    ir/instruction.cpp \
+    ir/instruction.hpp \
+    ir/liveness.cpp \
+    ir/register.cpp \
+    ir/register.hpp \
+    ir/function.cpp \
+    ir/function.hpp \
+    ir/value.cpp \
+    ir/value.hpp \
+    ir/lowering.cpp \
+    ir/lowering.hpp \
+    ir/printf.cpp \
+    ir/printf.hpp \
+    ir/immediate.hpp \
+    ir/immediate.cpp \
+    ir/structurizer.hpp \
+    ir/structurizer.cpp \
+    backend/context.cpp \
+    backend/context.hpp \
+    backend/program.cpp \
+    backend/program.hpp \
+    backend/program.h \
+    llvm/llvm_sampler_fix.cpp \
+    llvm/llvm_bitcode_link.cpp \
+    llvm/llvm_gen_backend.cpp \
+    llvm/llvm_passes.cpp \
+    llvm/llvm_scalarize.cpp \
+    llvm/llvm_intrinsic_lowering.cpp \
+    llvm/llvm_barrier_nodup.cpp \
+    llvm/llvm_printf_parser.cpp \
+    llvm/ExpandConstantExpr.cpp \
+    llvm/ExpandUtils.cpp \
+    llvm/PromoteIntegers.cpp \
+    llvm/ExpandLargeIntegers.cpp \
+    llvm/StripAttributes.cpp \
+    llvm/llvm_to_gen.cpp \
+    llvm/llvm_loadstore_optimization.cpp \
+    llvm/llvm_gen_backend.hpp \
+    llvm/llvm_gen_ocl_function.hxx \
+    llvm/llvm_unroll.cpp \
+    llvm/llvm_to_gen.hpp \
+    backend/gen/gen_mesa_disasm.c \
+    backend/gen_insn_selection.cpp \
+    backend/gen_insn_selection.hpp \
+    backend/gen_insn_selection_optimize.cpp \
+    backend/gen_insn_scheduling.cpp \
+    backend/gen_insn_scheduling.hpp \
+    backend/gen_insn_selection_output.cpp \
+    backend/gen_insn_selection_output.hpp \
+    backend/gen_reg_allocation.cpp \
+    backend/gen_reg_allocation.hpp \
+    backend/gen_context.cpp \
+    backend/gen_context.hpp \
+    backend/gen75_context.hpp \
+    backend/gen75_context.cpp \
+    backend/gen8_context.hpp \
+    backend/gen8_context.cpp \
+    backend/gen9_context.hpp \
+    backend/gen9_context.cpp \
+    backend/gen_program.cpp \
+    backend/gen_program.hpp \
+    backend/gen_program.h \
+    backend/gen7_instruction.hpp \
+    backend/gen8_instruction.hpp \
+    backend/gen_defs.hpp \
+    backend/gen_insn_compact.cpp \
+    backend/gen_encoder.hpp \
+    backend/gen_encoder.cpp \
+    backend/gen7_encoder.hpp \
+    backend/gen7_encoder.cpp \
+    backend/gen75_encoder.hpp \
+    backend/gen75_encoder.cpp \
+    backend/gen8_encoder.hpp \
+    backend/gen8_encoder.cpp \
+    backend/gen9_encoder.hpp \
+    backend/gen9_encoder.cpp
+
+#Generate GBEConfig for android
+LOCAL_MODULE := libgbe
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+generated_path := $(call local-generated-sources-dir)
+gbe_config_file = $(LOCAL_PATH)/GBEConfig.h
+$(shell echo "// the configured options and settings for LIBGBE" > $(gbe_config_file))
+$(shell echo "#define LIBGBE_VERSION_MAJOR 0" >> $(gbe_config_file))
+$(shell echo "#define LIBGBE_VERSION_MINOR 2" >> $(gbe_config_file))
+$(shell echo "#if defined(__ANDROID__)" >> $(gbe_config_file))
+$(shell echo "#if __x86_64__" >> $(gbe_config_file))
+$(shell echo "  #define GBE_OBJECT_DIR \"/system/lib64/libgbe.so\"" >> $(gbe_config_file))
+$(shell echo "  #define INTERP_OBJECT_DIR \"/system/lib64/libgbeinterp.so\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_BITCODE_BIN \"/system/lib/ocl/beignet.bc\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_HEADER_DIR \"/system/lib/ocl/include\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_PCH_OBJECT \"/system/lib/ocl/beignet.pch\"" >> $(gbe_config_file))
+$(shell echo "#else /*__x86_64__*/" >> $(gbe_config_file))
+$(shell echo "  #define GBE_OBJECT_DIR \"/system/lib/libgbe.so\"" >> $(gbe_config_file))
+$(shell echo "  #define INTERP_OBJECT_DIR \"/system/lib/libgbeinterp.so\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_BITCODE_BIN \"/system/lib/ocl/beignet.bc\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_HEADER_DIR \"/system/lib/ocl/include\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_PCH_OBJECT \"/system/lib/ocl/beignet.pch\"" >> $(gbe_config_file))
+$(shell echo "#endif" >> $(gbe_config_file))
+$(shell echo "#else /*__ANDROID__*/" >> $(gbe_config_file))
+$(shell echo "  #define GBE_OBJECT_DIR \"\"" >> $(gbe_config_file))
+$(shell echo "  #define INTERP_OBJECT_DIR \"\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_BITCODE_BIN \"`pwd $(TOP)`/$(generated_path)\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_HEADER_DIR \"`pwd $(TOP)`/$(generated_path)/libocl/include\"" >> $(gbe_config_file))
+$(shell echo "  #define OCL_PCH_OBJECT \"`pwd $(TOP)`/$(generated_path)\"" >> $(gbe_config_file))
+$(shell echo "#endif" >> $(gbe_config_file))
+
+#Build HOST libgbe.so
+LOCAL_C_INCLUDES := $(TOP_C_INCLUDE) \
+                    $(BEIGNET_ROOT_PATH) \
+                    $(LOCAL_PATH)/../ \
+                    $(LLVM_INCLUDE_DIRS)
+LOCAL_CPPFLAGS +=  $(LLVM_CFLAGS) -std=c++11 -fexceptions -DGBE_DEBUG=0 -DGBE_COMPILER_AVAILABLE=1 -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND
+LOCAL_CFLAGS +=  $(LLVM_CFLAGS) -fexceptions -DGBE_DEBUG=0 -DGBE_COMPILER_AVAILABLE=1 -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND
+LOCAL_LDLIBS += -lpthread -lm -ldl -lLLVM -lclang
+#LOCAL_STATIC_LIBRARIES := $(CLANG_MODULE_LIBS)
+LOCAL_SHARED_LIBRARIES := libclang
+
+TBLGEN_TABLES :=    \
+	         AttrList.inc    \
+                 Attrs.inc    \
+                 CommentCommandList.inc \
+                 CommentNodes.inc \
+                 DeclNodes.inc    \
+                 DiagnosticCommonKinds.inc   \
+                 DiagnosticDriverKinds.inc       \
+                 DiagnosticFrontendKinds.inc     \
+                 DiagnosticSemaKinds.inc
+
+LOCAL_SRC_FILES = $(BACKEND_SRC_FILES)
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(LLVM_GEN_INTRINSICS_MK)
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+
+#Build gbe_bin_generater
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := gbe_bin_generater.cpp
+
+LOCAL_C_INCLUDES := $(TOP_C_INCLUDE) \
+                    $(BEIGNET_ROOT_PATH) \
+                    $(LOCAL_PATH)/ \
+                    $(LLVM_INCLUDE_DIRS)
+LOCAL_MODULE := gbe_bin_generater
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS = $(LLVM_CFLAGS) -std=gnu++11 -fexceptions
+LOCAL_SHARED_LIBRARIES := libgbe
+LOCAL_LDLIBS += -lpthread -lm -ldl
+
+include $(BUILD_HOST_EXECUTABLE)
+
+
+#Build libgbeinterp.so
+include $(CLEAR_VARS)
+
+LLVM_ROOT_PATH := external/llvm
+include $(LLVM_ROOT_PATH)/llvm.mk
+
+LOCAL_C_INCLUDES := $(TOP_C_INCLUDE) \
+                    $(BEIGNET_ROOT_PATH) \
+                    $(LOCAL_PATH)/../ \
+                    $(LLVM_INCLUDE_DIRS)
+
+LOCAL_LDFLAGS := -Wl,--no-undefined
+
+LOCAL_CFLAGS += $(SUBDIR_C_CXX_FLAGS)
+LOCAL_CPPFLAGS += -Wl,-E -std=c++11 -DGBE_COMPILER_AVAILABLE=1
+
+LOCAL_MODULE := libgbeinterp
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := gbe_bin_interpreter.cpp
+LOCAL_SHARED_LIBRARIES := \
+libcutils \
+$(DRM_INTEL_LIBRARY) \
+$(DRM_LIBRARY)
+
+include $(LLVM_DEVICE_BUILD_MK)
+include $(BUILD_SHARED_LIBRARY)
+
+#Build targe libgbe.so
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_C_INCLUDES := $(TOP_C_INCLUDE) \
+                    $(BEIGNET_ROOT_PATH) \
+                    $(LOCAL_PATH)/../ \
+                    $(LLVM_INCLUDE_DIRS)
+
+SUBDIR_C_CXX_FLAGS := -fvisibility=hidden
+SUBDIR_C_CXX_FLAGS += -funroll-loops -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -fPIC -Wall
+SUBDIR_C_CXX_FLAGS += $(LLVM_CFLAGS)
+
+LOCAL_CPPFLAGS := $(SUBDIR_C_CXX_FLAGS)
+LOCAL_CPPFLAGS += -fno-rtti -std=c++11 -DGBE_DEBUG=1 -DGBE_COMPILER_AVAILABLE=1 -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND
+LOCAL_CPPFLAGS += -Wl,-E
+
+#LOCAL_SDK_VERSION := 19
+#LOCAL_NDK_STL_VARIANT := gnustl_static
+
+LOCAL_CFLAGS := $(SUBDIR_C_CXX_FLAGS)
+LOCAL_CFLAGS += -Wl,-E
+LOCAL_LDFLAGS := -Wl,--no-undefined
+LOCAL_LDLIBS := $(LLVM_LFLAGS)
+
+LOCAL_MODULE := libgbe
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_SHARED_LIBRARIES := \
+libcutils \
+$(DRM_INTEL_LIBRARY) \
+$(DRM_LIBRARY) \
+libclang
+#$(THREAD_LIBS_INIT)
+#$(DL_LIBS)
+
+#LOCAL_STATIC_LIBRARIES := $(CLANG_MODULE_LIBS)
+
+TBLGEN_TABLES :=    \
+	         AttrList.inc    \
+                 Attrs.inc    \
+                 CommentCommandList.inc \
+                 CommentNodes.inc \
+                 DeclNodes.inc    \
+                 DiagnosticCommonKinds.inc   \
+                 DiagnosticDriverKinds.inc       \
+                 DiagnosticFrontendKinds.inc     \
+                 DiagnosticSemaKinds.inc
+
+LOCAL_SRC_FILES := $(BACKEND_SRC_FILES)
+
+include $(CLANG_DEVICE_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(LLVM_GEN_INTRINSICS_MK)
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/backend/src/libocl/Android.mk b/backend/src/libocl/Android.mk
new file mode 100644
index 0000000..47ac5f1
--- /dev/null
+++ b/backend/src/libocl/Android.mk
@@ -0,0 +1,89 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libgbe
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+generated_sources := $(call local-generated-sources-dir)/libocl
+
+$(shell mkdir -p ${generated_sources}/include/)
+$(shell mkdir -p ${generated_sources}/src/)
+#$(shell echo "cat $(LOCAL_PATH)/tmpl/ocl_defines.tmpl.h \\> ${LIBOCL_BINARY_DIR}/include/ocl_defines.h")
+$(shell cat $(LOCAL_PATH)/tmpl/ocl_defines.tmpl.h > ${generated_sources}/include/ocl_defines.h)
+#$(shell echo "cat $(LOCAL_PATH)/../ocl_common_defines.h \\>\\> ${LIBOCL_BINARY_DIR}/include/ocl_defines.h")
+$(shell cat ${LOCAL_PATH}/../ocl_common_defines.h >> ${generated_sources}/include/ocl_defines.h)
+$(shell echo "Generate the header: ${generated_sources}/include/ocl_defines.h")
+
+define COPY_THE_HEADER
+    # Use the python script to generate the header files.
+    $(shell cp ${LOCAL_PATH}/include/$(1).h ${generated_sources}/include/$(1).h)
+endef
+define COPY_THE_SOURCE
+    # Use the python script to generate the header files.
+    $(shell cp ${LOCAL_PATH}/src/$(1).cl ${generated_sources}/src/$(1).cl)
+endef
+
+OCL_COPY_MODULES := ocl ocl_types ocl_float ocl_printf
+$(foreach _M_, ${OCL_COPY_MODULES}, $(eval $(call COPY_THE_HEADER,$(_M_))))
+
+OCL_COPY_MODULES := ocl_workitem ocl_atom ocl_async ocl_sync ocl_memcpy ocl_memset ocl_misc ocl_vload ocl_geometric ocl_image
+OCL_SOURCE_FILES := $(OCL_COPY_MODULES)
+$(foreach _M_, ${OCL_COPY_MODULES}, $(eval $(call COPY_THE_HEADER,$(_M_))))
+$(foreach _M_, ${OCL_COPY_MODULES}, $(eval $(call COPY_THE_SOURCE,$(_M_))))
+
+define GENERATE_HEADER_PY
+    # Use the python script to generate the header files.
+    $(shell cat ${LOCAL_PATH}/tmpl/$(1).tmpl.h > ${generated_sources}/include/$(1).h)
+    $(shell /usr/bin/python ${LOCAL_PATH}/script/gen_vector.py ${LOCAL_PATH}/script/$(1).def ${generated_sources}/include/$(1).h 1)
+    $(shell echo "#endif" >> ${generated_sources}/include/$(1).h)
+endef
+define GENERATE_SOURCE_PY
+    # Use the python script to generate the header files.
+    $(shell cat ${LOCAL_PATH}/tmpl/$(1).tmpl.cl > ${generated_sources}/src/$(1).cl)
+    $(shell /usr/bin/python ${LOCAL_PATH}/script/gen_vector.py ${LOCAL_PATH}/script/$(1).def ${generated_sources}/src/$(1).cl 0)
+endef
+
+OCL_COPY_MODULES_PY := ocl_common ocl_relational ocl_integer ocl_math ocl_simd
+OCL_SOURCE_FILES += $(OCL_COPY_MODULES_PY)
+$(foreach _M_, ${OCL_COPY_MODULES_PY}, $(eval $(call GENERATE_HEADER_PY,$(_M_))))
+$(foreach _M_, ${OCL_COPY_MODULES_PY}, $(eval $(call GENERATE_SOURCE_PY,$(_M_))))
+
+define GENERATE_HEADER_BASH
+    # Use the python script to generate the header files.\
+    $(shell ${LOCAL_PATH}/script/$(1).sh -p > ${generated_sources}/include/$(1).h)
+endef
+define GENERATE_SOURCE_BASH
+    # Use the python script to generate the header files.
+    $(shell ${LOCAL_PATH}/script/$(1).sh > ${generated_sources}/src/$(1).cl)
+endef
+OCL_COPY_MODULES_SH := ocl_as ocl_convert
+OCL_SOURCE_FILES += $(OCL_COPY_MODULES_SH)
+$(foreach _M_, ${OCL_COPY_MODULES_SH}, $(eval $(call GENERATE_HEADER_BASH,$(_M_))))
+$(foreach _M_, ${OCL_COPY_MODULES_SH}, $(eval $(call GENERATE_SOURCE_BASH,$(_M_))))
+
+CLANG_OCL_FLAGS := -fno-builtin -ffp-contract=off -cl-kernel-arg-info -DGEN7_SAMPLER_CLAMP_BORDER_WORKAROUND "-cl-std=CL1.2"
+define ADD_CL_TO_BC_TARGET
+    # Use the python script to generate the header files.
+    $(shell $(HOST_OUT)/bin/clang -cc1 ${CLANG_OCL_FLAGS} -I ${generated_sources}/include/ -emit-llvm-bc -triple spir -o ${generated_sources}/$(1).bc -x cl ${generated_sources}/src/$(1).cl)
+endef
+$(foreach _M_, ${OCL_SOURCE_FILES}, $(eval $(call ADD_CL_TO_BC_TARGET,$(_M_))))
+
+define COPY_THE_LL
+    # Use the python script to generate the header files.
+    $(shell cp ${LOCAL_PATH}/src/$(1).ll ${generated_sources}/src/$(1).ll)
+endef
+define ADD_LL_TO_BC_TARGET
+    # Use the python script to generate the header files.
+    $(shell $(HOST_OUT)/bin/llvm-as -o ${generated_sources}/$(1).bc ${generated_sources}/src/$(1).ll)
+endef
+OCL_LL_MODULES := ocl_barrier ocl_clz
+OCL_SOURCE_FILES += $(OCL_LL_MODULES)
+$(foreach _M_, ${OCL_LL_MODULES}, $(eval $(call COPY_THE_LL,$(_M_))))
+$(foreach _M_, ${OCL_LL_MODULES}, $(eval $(call ADD_LL_TO_BC_TARGET,$(_M_))))
+
+$(shell $(HOST_OUT)/bin/llvm-link -o ${generated_sources}/../beignet.bc $(addprefix ${generated_sources}/, $(addsuffix .bc, ${OCL_SOURCE_FILES})))
+
+$(shell $(HOST_OUT)/bin/clang -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${generated_sources}/include/ --relocatable-pch -emit-pch -isysroot ${generated_sources} -x cl ${generated_sources}/include/ocl.h -o ${generated_sources}/../beignet.pch)
+
+
diff --git a/src/Android.mk b/src/Android.mk
new file mode 100644
index 0000000..44481b2
--- /dev/null
+++ b/src/Android.mk
@@ -0,0 +1,123 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+include $(LOCAL_PATH)/../Android.common.mk
+
+ocl_config_file = $(LOCAL_PATH)/OCLConfig.h
+$(shell echo "// the configured options and settings for LIBCL" > $(ocl_config_file))
+$(shell echo "#define LIBCL_DRIVER_VERSION_MAJOR 0" >> $(ocl_config_file))
+$(shell echo "#define LIBCL_DRIVER_VERSION_MINOR 9" >> $(ocl_config_file))
+$(shell echo "#define LIBCL_C_VERSION_MAJOR 1" >> $(ocl_config_file))
+$(shell echo "#define LIBCL_C_VERSION_MINOR 2" >> $(ocl_config_file))
+
+LOCAL_C_INCLUDES := $(TOP_C_INCLUDE) $(BEIGNET_ROOT_PATH)/backend/src/backend/ $(BEIGNET_ROOT_PATH)
+LOCAL_C_INCLUDES += $(DRM_INCLUDE_PATH)
+LOCAL_C_INCLUDES += $(LLVM_INCLUDE_DIRS)
+LOCAL_C_INCLUDES += hardware/drm_gralloc
+LOCAL_CPPFLAGS := $(TOP_CPPFLAGS) -std=c++11
+LOCAL_CFLAGS := $(TOP_CFLAGS)
+OPTIONAL_EGL_LIBRARY :=
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+LOCAL_LDLIBS := -lm -ldl
+LOCAL_SHARED_LIBRARIES += liblog libcutils
+LOCAL_ADDITIONAL_DEPENDENCIES := $(GBE_BIN_GENERATER)
+LOCAL_MODULE := libcl
+
+LOCAL_REQUIRED_MODULES := $(HOST_OUT_EXECUTABLES)/gbe_bin_generater
+LOCAL_ADDITIONAL_DEPENDENCIES := $(BEIGNET_ROOT_PATH)/backend/src/Android.mk
+
+KERNEL_PATH := $(BEIGNET_ROOT_PATH)/src/kernels
+KERNEL_NAMES := cl_internal_copy_buf_align4 \
+                cl_internal_copy_buf_align16 \
+                cl_internal_copy_buf_unalign_same_offset \
+                cl_internal_copy_buf_unalign_dst_offset \
+                cl_internal_copy_buf_unalign_src_offset \
+                cl_internal_copy_buf_rect \
+                cl_internal_copy_buf_rect_align4 \
+                cl_internal_copy_image_1d_to_1d \
+                cl_internal_copy_image_2d_to_2d \
+                cl_internal_copy_image_3d_to_2d \
+                cl_internal_copy_image_2d_to_3d \
+                cl_internal_copy_image_3d_to_3d \
+                cl_internal_copy_image_2d_to_2d_array \
+                cl_internal_copy_image_1d_array_to_1d_array \
+                cl_internal_copy_image_2d_array_to_2d_array \
+                cl_internal_copy_image_2d_array_to_2d \
+                cl_internal_copy_image_2d_array_to_3d \
+                cl_internal_copy_image_3d_to_2d_array \
+                cl_internal_copy_image_2d_to_buffer \
+                cl_internal_copy_image_2d_to_buffer_align16 \
+                cl_internal_copy_image_3d_to_buffer \
+                cl_internal_copy_buffer_to_image_2d \
+                cl_internal_copy_buffer_to_image_2d_align16 \
+                cl_internal_copy_buffer_to_image_3d \
+                cl_internal_fill_buf_align8 \
+                cl_internal_fill_buf_align4 \
+                cl_internal_fill_buf_align2 \
+                cl_internal_fill_buf_unalign \
+                cl_internal_fill_buf_align128 \
+                cl_internal_fill_image_1d \
+                cl_internal_fill_image_1d_array \
+                cl_internal_fill_image_2d \
+                cl_internal_fill_image_2d_array \
+                cl_internal_fill_image_3d
+BUILT_IN_NAME := cl_internal_built_in_kernel
+
+GBE_BIN_GENERATER := $(HOST_OUT_EXECUTABLES)/gbe_bin_generater
+
+$(shell rm $(KERNEL_PATH)/$(BUILT_IN_NAME).cl)
+define GEN_INTERNAL_KER
+    # Use the python script to generate the header files.
+    $(shell $(GBE_BIN_GENERATER) -s $(KERNEL_PATH)/$(1).cl -o $(KERNEL_PATH)/$(1)_str.c)
+    $(shell cat $(KERNEL_PATH)/$(1).cl >> $(KERNEL_PATH)/$(BUILT_IN_NAME).cl)
+endef
+$(foreach KERNEL_NAME, ${KERNEL_NAMES}, $(eval $(call GEN_INTERNAL_KER,$(KERNEL_NAME))))
+
+$(shell $(GBE_BIN_GENERATER) -s $(KERNEL_PATH)/$(BUILT_IN_NAME).cl -o $(KERNEL_PATH)/$(BUILT_IN_NAME)_str.c)
+
+GIT_SHA1 = git_sha1.h
+$(shell chmod +x $(LOCAL_PATH)/git_sha1.sh)
+$(shell $(LOCAL_PATH)/git_sha1.sh $(LOCAL_PATH) ${GIT_SHA1})
+
+LOCAL_SRC_FILES:= \
+    $(addprefix kernels/,$(addsuffix _str.c, $(KERNEL_NAMES))) \
+    $(addprefix kernels/,$(addsuffix _str.c, $(BUILT_IN_NAME))) \
+    cl_api.c \
+    cl_alloc.c \
+    cl_kernel.c \
+    cl_program.c \
+    cl_gbe_loader.cpp \
+    cl_sampler.c \
+    cl_event.c \
+    cl_enqueue.c \
+    cl_image.c \
+    cl_mem.c \
+    cl_platform_id.c \
+    cl_extensions.c \
+    cl_device_id.c \
+    cl_context.c \
+    cl_command_queue.c \
+    cl_command_queue.h \
+    cl_command_queue_gen7.c \
+    cl_thread.c \
+    cl_driver.h \
+    cl_driver.cpp \
+    cl_driver_defs.c \
+    intel/intel_gpgpu.c \
+    intel/intel_batchbuffer.c \
+    intel/intel_driver.c \
+    performance.c
+
+LOCAL_SHARED_LIBRARIES := \
+libgbe \
+libdl \
+$(DRM_INTEL_LIBRARY) \
+$(DRM_LIBRARY) \
+$(OPTIONAL_EGL_LIBRARY) \
+libhardware
+
+LOCAL_CLANG := true
+include external/libcxx/libcxx.mk
+include $(BUILD_SHARED_LIBRARY)
diff --git a/utests/Android.mk b/utests/Android.mk
new file mode 100644
index 0000000..4c3189e
--- /dev/null
+++ b/utests/Android.mk
@@ -0,0 +1,250 @@
+MY_LOCAL_PATH := $(call my-dir)
+LOCAL_PATH:= $(MY_LOCAL_PATH)
+include $(CLEAR_VARS)
+
+include $(LOCAL_PATH)/../Android.common.mk
+
+SUBDIR_C_INCLUDES := $(TOP_C_INCLUDE) $(LOCAL_PATH)/../include
+SUBDIR_CPPFLAGS := $(TOP_CPPFLAGS)
+SUBDIR_CPPFLAGS += -fexceptions -std=c++11
+SUBDIR_LOCAL_CFLAGS := $(TOP_CFLAGS)
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+LOCAL_SRC_FILES:= \
+  utest_error.c \
+  utest_assert.cpp \
+  utest.cpp \
+  utest_file_map.cpp \
+  utest_helper.cpp \
+  compiler_basic_arithmetic.cpp \
+  compiler_displacement_map_element.cpp \
+  compiler_mandelbrot.cpp \
+  compiler_mandelbrot_alternate.cpp \
+  compiler_box_blur_float.cpp \
+  compiler_box_blur_image.cpp \
+  compiler_box_blur.cpp \
+  compiler_insert_to_constant.cpp \
+  compiler_argument_structure.cpp \
+  compiler_argument_structure_indirect.cpp \
+  compiler_argument_structure_select.cpp \
+  compiler_arith_shift_right.cpp \
+  compiler_mixed_pointer.cpp \
+  compiler_array0.cpp \
+  compiler_array.cpp \
+  compiler_array1.cpp \
+  compiler_array2.cpp \
+  compiler_array3.cpp \
+  compiler_array4.cpp \
+  compiler_byte_scatter.cpp \
+  compiler_ceil.cpp \
+  compiler_popcount.cpp \
+  compiler_convert_uchar_sat.cpp \
+  compiler_copy_buffer.cpp \
+  compiler_copy_image.cpp \
+  compiler_copy_image_1d.cpp \
+  compiler_copy_image_3d.cpp \
+  compiler_copy_buffer_row.cpp \
+  compiler_degrees.cpp \
+  compiler_step.cpp \
+  compiler_fabs.cpp \
+  compiler_abs.cpp \
+  compiler_abs_diff.cpp \
+  compiler_fill_image.cpp \
+  compiler_fill_image0.cpp \
+  compiler_fill_image_1d.cpp \
+  compiler_fill_image_3d.cpp \
+  compiler_fill_image_3d_2.cpp \
+  compiler_function_argument0.cpp \
+  compiler_function_argument1.cpp \
+  compiler_function_argument2.cpp \
+  compiler_function_argument.cpp \
+  compiler_function_constant0.cpp \
+  compiler_function_constant1.cpp \
+  compiler_function_constant.cpp \
+  compiler_global_constant.cpp \
+  compiler_global_constant_2.cpp \
+  compiler_group_size.cpp \
+  compiler_hadd.cpp \
+  compiler_if_else.cpp \
+  compiler_integer_division.cpp \
+  compiler_integer_remainder.cpp \
+  compiler_insert_vector.cpp \
+  compiler_lower_return0.cpp \
+  compiler_lower_return1.cpp \
+  compiler_lower_return2.cpp \
+  compiler_mad_hi.cpp \
+  compiler_mul_hi.cpp \
+  compiler_mad24.cpp \
+  compiler_mul24.cpp \
+  compiler_multiple_kernels.cpp \
+  compiler_radians.cpp \
+  compiler_rhadd.cpp \
+  compiler_rotate.cpp \
+  compiler_saturate.cpp \
+  compiler_saturate_sub.cpp \
+  compiler_shift_right.cpp \
+  compiler_short_scatter.cpp \
+  compiler_smoothstep.cpp \
+  compiler_uint2_copy.cpp \
+  compiler_uint3_copy.cpp \
+  compiler_uint8_copy.cpp \
+  compiler_uint16_copy.cpp \
+  compiler_uint3_unaligned_copy.cpp \
+  compiler_upsample_int.cpp \
+  compiler_upsample_long.cpp \
+  compiler_unstructured_branch0.cpp \
+  compiler_unstructured_branch1.cpp \
+  compiler_unstructured_branch2.cpp \
+  compiler_unstructured_branch3.cpp \
+  compiler_write_only_bytes.cpp \
+  compiler_write_only.cpp \
+  compiler_write_only_shorts.cpp \
+  compiler_switch.cpp \
+  compiler_bswap.cpp \
+  compiler_clz.cpp \
+  compiler_math.cpp \
+  compiler_atomic_functions.cpp \
+  compiler_async_copy.cpp \
+  compiler_async_stride_copy.cpp \
+  compiler_insn_selection_min.cpp \
+  compiler_insn_selection_max.cpp \
+  compiler_insn_selection_masked_min_max.cpp \
+  compiler_load_bool_imm.cpp \
+  compiler_global_memory_barrier.cpp \
+  compiler_local_memory_two_ptr.cpp \
+  compiler_local_memory_barrier.cpp \
+  compiler_local_memory_barrier_wg64.cpp \
+  compiler_local_memory_barrier_2.cpp \
+  compiler_local_slm.cpp \
+  compiler_movforphi_undef.cpp \
+  compiler_volatile.cpp \
+  compiler_copy_image1.cpp \
+  compiler_get_image_info.cpp \
+  compiler_get_image_info_array.cpp \
+  compiler_vect_compare.cpp \
+  compiler_vector_load_store.cpp \
+  compiler_vector_inc.cpp \
+  compiler_cl_finish.cpp \
+  get_cl_info.cpp \
+  builtin_atan2.cpp \
+  builtin_bitselect.cpp \
+  builtin_frexp.cpp \
+  builtin_mad_sat.cpp \
+  builtin_modf.cpp \
+  builtin_nextafter.cpp \
+  builtin_remquo.cpp \
+  builtin_shuffle.cpp \
+  builtin_shuffle2.cpp \
+  builtin_sign.cpp \
+  builtin_lgamma.cpp \
+  builtin_lgamma_r.cpp \
+  builtin_tgamma.cpp \
+  buildin_work_dim.cpp \
+  builtin_global_size.cpp \
+  builtin_local_size.cpp \
+  builtin_global_id.cpp \
+  builtin_num_groups.cpp \
+  builtin_local_id.cpp \
+  builtin_acos_asin.cpp \
+  builtin_pow.cpp \
+  builtin_convert_sat.cpp \
+  sub_buffer.cpp \
+  runtime_createcontext.cpp \
+  runtime_set_kernel_arg.cpp \
+  runtime_null_kernel_arg.cpp \
+  runtime_event.cpp \
+  runtime_barrier_list.cpp \
+  runtime_marker_list.cpp \
+  runtime_compile_link.cpp \
+  compiler_long.cpp \
+  compiler_long_2.cpp \
+  compiler_long_not.cpp \
+  compiler_long_hi_sat.cpp \
+  compiler_long_div.cpp \
+  compiler_long_convert.cpp \
+  compiler_long_shl.cpp \
+  compiler_long_shr.cpp \
+  compiler_long_asr.cpp \
+  compiler_long_mult.cpp \
+  compiler_long_cmp.cpp \
+  compiler_long_bitcast.cpp \
+  compiler_half.cpp \
+  compiler_function_argument3.cpp \
+  compiler_function_qualifiers.cpp \
+  compiler_bool_cross_basic_block.cpp \
+  compiler_private_const.cpp \
+  compiler_private_data_overflow.cpp \
+  compiler_getelementptr_bitcast.cpp \
+  compiler_sub_group_any.cpp \
+  compiler_sub_group_all.cpp \
+  compiler_time_stamp.cpp \
+  compiler_double_precision.cpp \
+  load_program_from_gen_bin.cpp \
+  load_program_from_spir.cpp \
+  get_arg_info.cpp \
+  profiling_exec.cpp \
+  enqueue_copy_buf.cpp \
+  enqueue_copy_buf_unaligned.cpp \
+  test_printf.cpp \
+  enqueue_fill_buf.cpp \
+  builtin_kernel_max_global_size.cpp \
+  image_1D_buffer.cpp \
+  image_from_buffer.cpp \
+  compare_image_2d_and_1d_array.cpp \
+  compiler_fill_image_1d_array.cpp \
+  compiler_fill_image_2d_array.cpp \
+  compiler_constant_expr.cpp \
+  compiler_assignment_operation_in_if.cpp \
+  vload_bench.cpp \
+  runtime_use_host_ptr_buffer.cpp \
+  runtime_alloc_host_ptr_buffer.cpp \
+  runtime_use_host_ptr_image.cpp \
+  compiler_get_sub_group_size.cpp \
+  compiler_get_sub_group_id.cpp \
+  compiler_sub_group_shuffle.cpp
+
+ifeq ($(EGL_FOUND),true)
+LOCAL_SRC_FILES += \
+    compiler_fill_gl_image.cpp
+SUBDIR_CPPFLAGS += -DHAS_EGL
+SUBDIR_CFLAGS += -DHAS_EGL
+endif
+
+LOCAL_SHARED_LIBRARIES := \
+libcl \
+libm \
+libdl
+
+LOCAL_C_INCLUDES := $(SUBDIR_C_INCLUDES)
+LOCAL_CPPFLAGS := $(SUBDIR_CPPFLAGS)
+LOCAL_CFLAGS := $(SURDIR_CFLAGS)
+LOCAL_MODULE := libutests
+
+LOCAL_CLANG := true
+include external/libcxx/libcxx.mk
+include $(BUILD_SHARED_LIBRARY)
+
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := utest_run
+LOCAL_SRC_FILES:= utest_run.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+libutests \
+libm \
+libdl
+
+LOCAL_C_INCLUDES := $(SUBDIR_C_INCLUDES)
+LOCAL_CPPFLAGS := $(SUBDIR_CPPFLAGS)
+LOCAL_CFLAGS := $(SURDIR_CFLAGS)
+
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := utest_run-x86
+LOCAL_MODULE_STEM_64 := utest_run-x86_64
+
+
+LOCAL_CLANG := true
+include external/libcxx/libcxx.mk
+include $(BUILD_EXECUTABLE)
+
-- 
2.1.4



More information about the Beignet mailing list