beignet-1.3.2-ship-test-tool.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Description: Ship utest_run testing tool
  2. Use ICD mode (to allow testing any ICD, not just beignet), but
  3. include builtin_kernel_block_motion_estimate_intel when testing beignet.
  4. Allow testing CPU devices (the "only GPU device is supported right now"
  5. comment appears to refer to beignet-the-ICD, not this test tool).
  6. Give meaningful errors when there is nothing to test.
  7. Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
  8. Forwarded: partly https://lists.freedesktop.org/archives/beignet/2016-October/008057.html https://lists.freedesktop.org/archives/beignet/2016-October/008059.html
  9. --- a/CMakeLists.txt
  10. +++ b/CMakeLists.txt
  11. @@ -23,7 +23,6 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL
  12. elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
  13. set(COMPILER "ICC")
  14. endif()
  15. -set (NOT_BUILD_STAND_ALONE_UTEST 1)
  16. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
  17. ${CMAKE_CURRENT_SOURCE_DIR}/include)
  18. @@ -328,7 +327,7 @@ ENDIF(BUILD_EXAMPLES)
  19. ADD_SUBDIRECTORY(include)
  20. ADD_SUBDIRECTORY(backend)
  21. ADD_SUBDIRECTORY(src)
  22. -ADD_SUBDIRECTORY(utests EXCLUDE_FROM_ALL)
  23. +ADD_SUBDIRECTORY(utests)
  24. # compile benchmark only if standalone compiler is not provided
  25. IF (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))
  26. --- a/utests/utest_helper.cpp
  27. +++ b/utests/utest_helper.cpp
  28. @@ -221,7 +221,7 @@ cl_do_kiss_path(const char *file, cl_device_id device)
  29. sub_path = "";
  30. if (kiss_path == NULL)
  31. - clpanic("set OCL_KERNEL_PATH. This is where the kiss kernels are", -1);
  32. + kiss_path="/usr/share/beignet/test_kernels";
  33. sz += strlen(kiss_path) + strlen(sub_path) + 2; /* +1 for end of string, +1 for '/' */
  34. if ((ker_path = (char*) malloc(sz)) == NULL)
  35. clpanic("Allocation failed", -1);
  36. @@ -443,9 +443,19 @@ cl_ocl_init(void)
  37. cl_context_properties *props = NULL;
  38. /* Get the platform number */
  39. - OCL_CALL (clGetPlatformIDs, 0, NULL, &platform_n);
  40. - printf("platform number %u\n", platform_n);
  41. - assert(platform_n >= 1);
  42. + status = clGetPlatformIDs(0, NULL, &platform_n);
  43. + if (platform_n < 1) {
  44. + fprintf(stderr, "No platforms found (check that the ICD to be tested is installed)\n");
  45. + status = CL_DEVICE_NOT_FOUND;
  46. + goto error;
  47. + }
  48. + if (status != CL_SUCCESS) {
  49. + fprintf(stderr, "error calling clGetPlatformIDs\n");
  50. + goto error;
  51. + }
  52. + if (platform_n > 1) {
  53. + fprintf(stderr, "%u platforms found - testing the first one (if this is not the one you want to test, uninstall any other ICDs)\n", platform_n);
  54. + }
  55. /* Get a valid platform */
  56. OCL_CALL (clGetPlatformIDs, 1, &platform, &platform_n);
  57. @@ -456,8 +466,22 @@ cl_ocl_init(void)
  58. GET_PLATFORM_STR_INFO(extensions, EXTENSIONS);
  59. /* Get the device (only GPU device is supported right now) */
  60. + cl_uint device_n;
  61. + status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 0, NULL, &device_n);
  62. + if (device_n < 1) {
  63. + fprintf(stderr, "No devices found in first platform (uninstall any ICDs that are not compatible with your hardware, check that you have permission to access the hardware)\n");
  64. + status = CL_DEVICE_NOT_FOUND;
  65. + goto error;
  66. + }
  67. + if (status != CL_SUCCESS) {
  68. + fprintf(stderr, "error calling clGetDeviceIDs\n");
  69. + goto error;
  70. + }
  71. + if (device_n > 1) {
  72. + fprintf(stderr, "%u devices found - testing the first one\n", device_n);
  73. + }
  74. try {
  75. - OCL_CALL (clGetDeviceIDs, platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
  76. + OCL_CALL (clGetDeviceIDs, platform, CL_DEVICE_TYPE_ALL, 1, &device, NULL);
  77. {
  78. size_t param_value_size;
  79. GET_DEVICE_STR_INFO(profile, PROFILE);
  80. --- a/utests/CMakeLists.txt
  81. +++ b/utests/CMakeLists.txt
  82. @@ -341,9 +341,7 @@ else(GEN_PCI_ID)
  83. DEPENDS ${GBE_BIN_FILE} ${kernel_bin}.cl)
  84. endif(GEN_PCI_ID)
  85. -if (NOT_BUILD_STAND_ALONE_UTEST)
  86. ADD_CUSTOM_TARGET(kernel_bin.bin DEPENDS ${kernel_bin}.bin)
  87. -endif (NOT_BUILD_STAND_ALONE_UTEST)
  88. add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated
  89. COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/generated -p
  90. @@ -392,6 +390,9 @@ if (NOT_BUILD_STAND_ALONE_UTEST)
  91. endif (NOT_BUILD_STAND_ALONE_UTEST)
  92. ADD_DEPENDENCIES (utests utest_generator)
  93. +set_target_properties(utest_run PROPERTIES INSTALL_RPATH ${BEIGNET_INSTALL_DIR})
  94. +install (TARGETS utests LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
  95. +install (TARGETS utest_run RUNTIME DESTINATION ${BEIGNET_INSTALL_DIR})
  96. ADD_EXECUTABLE(flat_address_space runtime_flat_address_space.cpp)
  97. TARGET_LINK_LIBRARIES(flat_address_space utests)