Skip to content

Commit

Permalink
* review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
srkreddy1238 committed Jan 26, 2023
1 parent 52dfa69 commit 3df9362
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
14 changes: 8 additions & 6 deletions apps/cpp_clml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ if(NOT DEFINED CLML_SDK)
message( FATAL_ERROR "CLML_SDK Not set, forcing exit." )
endif(NOT DEFINED CLML_SDK)

if (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY STREQUAL "ONLY")
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
endif()

find_library(CLML_LIBRARIES NAMES libOpenCL.so NO_DEFAULT_PATH PATHS ${CLML_SDK}/lib ${CLML_SDK}/lib64)

# CMake/Android variables
set( ANDROID_STL c++_static CACHE STRING "Target Android STL") # default

# Source variables
set( OPENCL_INCLUDE_DIRS ${CLML_SDK} CACHE PATH "filepath to OpenCL headers")
set( ANDROID_SOURCE_TREE /path/to/android/au/ CACHE FILEPATH "optional filepath to the Android AU Tree, for building examples using ION Buffers") # tree required to build ION/DMA Buffer samples

#c++ 11 is required
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# set(CMAKE_CXX_FLAGS "-Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

#we do not want to pass -fno-exceptions
if(${CMAKE_CXX_FLAGS} MATCHES "-fno-exceptions")
Expand Down Expand Up @@ -54,4 +56,4 @@ include_directories(

add_executable(clml_run ${COMMON_SOURCE_FILES})
target_link_options(clml_run PRIVATE -Wl,--unresolved-symbols=ignore-in-shared-libs)
target_link_libraries(clml_run ${CLML_SDK}/lib64/libOpenCL.so z)
target_link_libraries(clml_run ${CLML_LIBRARIES} z)
13 changes: 2 additions & 11 deletions apps/cpp_clml/clml_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,11 @@ CLMLRunner::CLMLRunner(std::string name, ToolArgs& args, cl_platform_id arg_plat
CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS);

for (cl_uint i = 0; i < numVersions; ++i) {
#if CL_QCOM_ML_OPS_H_MAJOR_VERSION == 2
if (majorVersions[i] == 2) {
this->h_ClmlIntf = clGetMLInterfaceV2QCOM(0);
if (majorVersions[i] == CL_QCOM_ML_OPS_H_MAJOR_VERSION) {
this->h_ClmlIntf = GET_ML_INTERFACE(0);
LOG(INFO) << "CLML Target version:" << majorVersions[i];
break;
}
#endif
#if CL_QCOM_ML_OPS_H_MAJOR_VERSION == 3
if (majorVersions[i] == 3) {
this->h_ClmlIntf = clGetMLInterfaceV3QCOM(0);
LOG(INFO) << "CLML Target version:" << majorVersions[i];
break;
}
#endif
}
CLML_SDK_TEST_AND_EXIT(this->h_ClmlIntf != NULL);

Expand Down
15 changes: 7 additions & 8 deletions apps/cpp_clml/clml_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
} \
}

#define CAT_I(a, b) a##b
#define CAT(a, b) CAT_I(a, b)
#define GET_ML_INTERFACE CAT(CAT(clGetMLInterfaceV, CL_QCOM_ML_OPS_H_MAJOR_VERSION), QCOM)
#define GET_ML_API_INTERFACE CAT(CAT(CLMLInterfaceV, CL_QCOM_ML_OPS_H_MAJOR_VERSION), QCOM)

namespace tvm {
namespace runtime {

Expand Down Expand Up @@ -221,14 +226,8 @@ class CLMLRunner {
/*! \brief Unused tensor used across various ops */
std::shared_ptr<cl_ml_tensor_memory_desc_qcom> unusedTensor;

#if CL_QCOM_ML_OPS_H_MAJOR_VERSION == 2
/*! \brief V2 ML API interface */
CLMLInterfaceV2QCOM* h_ClmlIntf = NULL;
#endif
#if CL_QCOM_ML_OPS_H_MAJOR_VERSION == 3
/*! \brief V3 ML API interface */
CLMLInterfaceV3QCOM* h_ClmlIntf = NULL;
#endif
/*! \brief ML API interface */
GET_ML_API_INTERFACE* h_ClmlIntf = NULL;
/*! \brief Tuning cache object */
cl_ml_tuningcache_qcom tuning_cache = NULL;
/*! \brief Flag to inticate a tuning run */
Expand Down
2 changes: 1 addition & 1 deletion apps/cpp_clml/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int ExecuteModel(ToolArgs& args) {
result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
CLML_SDK_TEST_AND_EXIT(device_id && result == CL_SUCCESS);

ExtensionStringPresent(platform, device_id);
CLML_SDK_TEST_AND_EXIT(ExtensionStringPresent(platform, device_id) == true);

context = clCreateContext(0, 1, &device_id, NULL, NULL, &result);
CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS);
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/contrib/CLML.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if(USE_CLML_GRAPH_EXECUTOR)
include_directories(${CLML_INCLUDE_DIRS})
find_library(EXTERN_CLML_COMPUTE_LIB
NAMES OpenCL libOpenCL
HINTS "${CLML_PATH}" "${CLML_PATH}/lib64"
HINTS "${CLML_PATH}" "${CLML_PATH}/lib" "${CLML_PATH}/lib64"
)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${EXTERN_CLML_COMPUTE_LIB})
list(APPEND RUNTIME_SRCS ${CLML_CONTRIB_SRC})
Expand Down

0 comments on commit 3df9362

Please sign in to comment.