diff options
author | Junyan He <junyan.he@linux.intel.com> | 2014-05-20 15:07:29 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-22 13:31:47 +0800 |
commit | daae099a2aa79e1c985fac460e3f75a4a5e97ffc (patch) | |
tree | c14fdf39e29360ada7f6571b37fc3e6ab97be0f5 | |
parent | de996fa90c26997a9d2ecd22192c146a661161f3 (diff) |
Add the pci id support for gbe_generate
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
-rw-r--r-- | backend/src/gbe_bin_generater.cpp | 22 | ||||
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | src/GetGenID.sh | 2 | ||||
-rw-r--r-- | utests/CMakeLists.txt | 7 |
4 files changed, 35 insertions, 4 deletions
diff --git a/backend/src/gbe_bin_generater.cpp b/backend/src/gbe_bin_generater.cpp index 15bdbd1e..a8af0dae 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: @@ -194,7 +196,7 @@ void program_build_instance::build_program(void) throw(int) { // FIXME, we need to find a graceful way to generate internal binaries for difference // devices. - gbe_program opaque = gbe_program_new_from_source(0x0152, code, 0, build_opt.c_str(), NULL, NULL); + gbe_program opaque = gbe_program_new_from_source(gen_pci_id, code, 0, build_opt.c_str(), NULL, NULL); if (!opaque) throw FILE_BUILD_FAILED; @@ -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 8164a44a..f93ddcd5 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 00000000..3114bd82 --- /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 704438df..a731ab05 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}/../src/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 ) |