[Beignet] [PATCH] Add the pci id support for gbe_generate
He Junyan
junyan.he at inbox.com
Mon May 19 22:32:57 PDT 2014
ping for review
On Tue, 2014-05-13 at 09:34 +0800, junyan.he at inbox.com wrote:
> From: Junyan He <junyan.he at linux.intel.com>
>
> Signed-off-by: Junyan He <junyan.he at linux.intel.com>
> ---
> backend/src/gbe_bin_generater.cpp | 20 +++++++++++++++++++-
> src/CMakeLists.txt | 8 +++++++-
> src/GetGenID.sh | 2 ++
> utests/CMakeLists.txt | 7 ++++++-
> 4 files changed, 34 insertions(+), 3 deletions(-)
> create mode 100755 src/GetGenID.sh
>
> diff --git a/backend/src/gbe_bin_generater.cpp b/backend/src/gbe_bin_generater.cpp
> index 15bdbd1..b6248ae 100644
> --- a/backend/src/gbe_bin_generater.cpp
> +++ b/backend/src/gbe_bin_generater.cpp
> @@ -46,6 +46,8 @@ using namespace std;
> #define FILE_BUILD_FAILED 3
> #define FILE_SERIALIZATION_FAILED 4
>
> +static int gen_pci_id = 0;
> +
> class program_build_instance {
>
> protected:
> @@ -249,7 +251,7 @@ int main (int argc, const char **argv)
> argv_saved.push_back(string(argv[i]));
> }
>
> - while ( (oc = getopt(argc, (char * const *)argv, "o:p:s")) != -1 ) {
> + while ( (oc = getopt(argc, (char * const *)argv, "t:o:p:s")) != -1 ) {
> switch (oc) {
> case 'p':
> {
> @@ -283,6 +285,22 @@ int main (int argc, const char **argv)
> used_index[optind-1] = 1;
> break;
>
> + case 't':
> + {
> + char *s = optarg;
> + if (optarg[0] == '0' && (optarg[1] == 'x' || optarg[1] == 'X'))
> + s += 2;
> +
> + if (s[0] < '0' || s[0] > '9') {
> + cout << "Invalid target option argument" << endl;
> + return 1;
> + }
> +
> + gen_pci_id = (s[0] - '0') << 12 | (s[1] - '0') << 8 | (s[2] - '0') << 4 | (s[3] - '0');
> + used_index[optind-1] = 1;
> + break;
> + }
> +
> case 's':
> program_build_instance::set_str_fmt_out(true);
> used_index[optind-1] = 1;
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index 8164a44..f93ddcd 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -4,6 +4,12 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
> ${CMAKE_CURRENT_SOURCE_DIR}/../backend/src/backend/
> ${CMAKE_CURRENT_SOURCE_DIR}/../include
> ${MESA_SOURCE_INCLUDES})
> +
> +set(GEN_PCI_ID)
> +execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/GetGenID.sh"
> + OUTPUT_VARIABLE GEN_PCI_ID)
> +message(STATUS "Platform Gen PCI id is " ${GEN_PCI_ID})
> +
> macro (MakeKernelBinStr KERNEL_PATH KERNEL_FILES)
> foreach (KF ${KERNEL_FILES})
> set (input_file ${KERNEL_PATH}/${KF}.cl)
> @@ -12,7 +18,7 @@ foreach (KF ${KERNEL_FILES})
> add_custom_command(
> OUTPUT ${output_file}
> COMMAND rm -rf ${output_file}
> - COMMAND ${GBE_BIN_GENERATER} -s ${input_file} -o${output_file}
> + COMMAND ${GBE_BIN_GENERATER} -s ${input_file} -o${output_file} -t${GEN_PCI_ID}
> DEPENDS ${input_file} ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater)
> endforeach (KF)
> endmacro (MakeKernelBinStr)
> diff --git a/src/GetGenID.sh b/src/GetGenID.sh
> new file mode 100755
> index 0000000..3114bd8
> --- /dev/null
> +++ b/src/GetGenID.sh
> @@ -0,0 +1,2 @@
> +#!/bin/bash
> +lspci -nn | grep "Gen .* Graphics" -i | grep "\[8086:.*\]" -o | awk -F : '{print $2}' | awk -F ] '{print $1}'
> diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
> index 704438d..2a9ea66 100644
> --- a/utests/CMakeLists.txt
> +++ b/utests/CMakeLists.txt
> @@ -180,10 +180,15 @@ set (utests_sources
> utest_file_map.cpp
> utest_helper.cpp)
>
> +set(GEN_PCI_ID)
> +execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/GetGenID.sh"
> + OUTPUT_VARIABLE GEN_PCI_ID)
> +
> +message(STATUS "Platform Gen PCI id is " ${GEN_PCI_ID})
> SET (kernel_bin ${CMAKE_CURRENT_SOURCE_DIR}/../kernels/compiler_ceil)
> ADD_CUSTOM_COMMAND(
> OUTPUT ${kernel_bin}.bin
> - COMMAND ${GBE_BIN_GENERATER} ${kernel_bin}.cl -o${kernel_bin}.bin
> + COMMAND ${GBE_BIN_GENERATER} ${kernel_bin}.cl -o${kernel_bin}.bin -t${GEN_PCI_ID}
> DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/../backend/src/gbe_bin_generater ${kernel_bin}.cl
> )
>
More information about the Beignet
mailing list