[Beignet] [PATCH V2] Add the pci id support for gbe_generate
Yang, Rong R
rong.r.yang at intel.com
Tue May 20 00:50:45 PDT 2014
LGTM, thanks.
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of junyan.he at inbox.com
Sent: Tuesday, May 20, 2014 3:07 PM
To: beignet at lists.freedesktop.org
Cc: Junyan He
Subject: [Beignet] [PATCH V2] Add the pci id support for gbe_generate
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 | 22 ++++++++++++++++++++--
src/CMakeLists.txt | 8 +++++++-
src/GetGenID.sh | 2 ++
utests/CMakeLists.txt | 7 ++++++-
4 files changed, 35 insertions(+), 4 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..a8af0da 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 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..a731ab0 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
)
--
1.8.3.2
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list