Skip to content

Commit 40098f4

Browse files
committed
adding auto-gemm script
1 parent 4b9a341 commit 40098f4

File tree

82 files changed

+14273
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+14273
-630
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020

2121
# flags.txt file
2222
*flags.txt
23+
24+
# vim temp files
25+
.*.swp

src/CMakeLists.txt

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,55 @@ option( BUILD_KTEST "A command line tool for testing single clBLAS kernel" ON )
2626
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
2727

2828
#enable or disable offline compilation for different devices. Currently only Hawaii, Bonaire, Tahiti have the option.
29-
option( OCL_OFFLINE_BUILD_HAWAII_KERNEL "Offline compile the OpenCL kernels for Hawaii device" OFF)
30-
option( OCL_OFFLINE_BUILD_BONAIRE_KERNEL "Offline compile the OpenCL kernels for Bonaire device" OFF)
31-
option( OCL_OFFLINE_BUILD_TAHITI_KERNEL "Offline compile the OpenCL kernels for Tathit device" OFF)
32-
33-
if( (OCL_OFFLINE_BUILD_HAWAII_KERNEL AND OCL_OFFLINE_BUILD_BONAIRE_KERNEL) OR (OCL_OFFLINE_BUILD_HAWAII_KERNEL AND OCL_OFFLINE_BUILD_TAHITI_KERNEL) OR (OCL_OFFLINE_BUILD_BONAIRE_KERNEL AND OCL_OFFLINE_BUILD_TAHITI_KERNEL))
34-
MESSAGE( WARNING "More than one device is chosen for offline compilation of static kernels. This might result in running out of heap memory with certain driver. Please consider offline compliation for ONE device only." )
35-
endif( )
36-
37-
if( NOT OCL_OFFLINE_BUILD_HAWAII_KERNEL )
29+
#option( OPENCL_OFFLINE_BUILD_HAWAII_KERNEL "Offline compile the OpenCL kernels for Hawaii device" OFF)
30+
#option( OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL "Offline compile the OpenCL kernels for Bonaire device" OFF)
31+
#option( OPENCL_OFFLINE_BUILD_TAHITI_KERNEL "Offline compile the OpenCL kernels for Tathit device" OFF)
32+
set( OPENCL_OFFLINE_BUILD_HAWAII_KERNEL OFF)
33+
set( OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL OFF)
34+
set( OPENCL_OFFLINE_BUILD_TAHITI_KERNEL OFF)
35+
36+
#if( (OPENCL_OFFLINE_BUILD_HAWAII_KERNEL AND OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL) OR (OPENCL_OFFLINE_BUILD_HAWAII_KERNEL AND OPENCL_OFFLINE_BUILD_TAHITI_KERNEL) OR (OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL AND OPENCL_OFFLINE_BUILD_TAHITI_KERNEL))
37+
# MESSAGE( WARNING "More than one device is chosen for offline compilation of static kernels. This might result in running out of heap memory with certain driver. Please consider offline compliation for ONE device only." )
38+
#endif( )
39+
40+
#if( NOT OPENCL_OFFLINE_BUILD_HAWAII_KERNEL )
3841
#use dynamic generated kernels
39-
MESSAGE(STATUS "Build dynamic Hawaii kernels.")
40-
MESSAGE(STATUS "Check OCL_OFFLINE_BUILD_HAWAII_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
42+
# MESSAGE(STATUS "Build dynamic Hawaii kernels.")
43+
# MESSAGE(STATUS "Check OPENCL_OFFLINE_BUILD_HAWAII_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
4144
add_definitions(-DCLBLAS_HAWAII_DYNAMIC_KERNEL)
42-
else()
43-
MESSAGE(STATUS "Build static Hawaii kernels.")
44-
MESSAGE(STATUS "Uncheck OCL_OFFLINE_BUILD_HAWAII_KERNEL to build kernls at run-time")
45-
MESSAGE(STATUS "Please ensure the presence of Hawaii device in the system. With certain driver/compiler flags, this might result in compile-time error.")
46-
endif( )
45+
#else()
46+
# MESSAGE(STATUS "Build static Hawaii kernels.")
47+
# MESSAGE(STATUS "Uncheck OPENCL_OFFLINE_BUILD_HAWAII_KERNEL to build kernls at run-time")
48+
# MESSAGE(STATUS "Please ensure the presence of Hawaii device in the system. With certain driver/compiler flags, this might result in compile-time error.")
49+
#endif( )
4750

48-
if( NOT OCL_OFFLINE_BUILD_BONAIRE_KERNEL )
51+
#if( NOT OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL )
4952
#use dynamic generated kernels
50-
MESSAGE(STATUS "Build dynamic Bonaire kernels.")
51-
MESSAGE(STATUS "Check OCL_OFFLINE_BUILD_BONAIRE_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
53+
# MESSAGE(STATUS "Build dynamic Bonaire kernels.")
54+
# MESSAGE(STATUS "Check OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
5255
add_definitions(-DCLBLAS_BONAIRE_DYNAMIC_KERNEL)
53-
else()
54-
MESSAGE(STATUS "Build static Bonaire kernels.")
55-
MESSAGE(STATUS "Uncheck OCL_OFFLINE_BUILD_BONAIRE_KERNEL to build kernls at run-time")
56-
MESSAGE(STATUS "Please ensure the presence of Bonaire device in the system. With certain driver/compiler flags, this might result in compile-time error.")
57-
endif( )
56+
#else()
57+
# MESSAGE(STATUS "Build static Bonaire kernels.")
58+
# MESSAGE(STATUS "Uncheck OPENCL_OFFLINE_BUILD_BONAIRE_KERNEL to build kernls at run-time")
59+
# MESSAGE(STATUS "Please ensure the presence of Bonaire device in the system. With certain driver/compiler flags, this might result in compile-time error.")
60+
#endif( )
5861

59-
if( NOT OCL_OFFLINE_BUILD_TAHITI_KERNEL )
62+
#if( NOT OPENCL_OFFLINE_BUILD_TAHITI_KERNEL )
6063
#use dynamic generated kernels
61-
MESSAGE(STATUS "Build dynamic Tahiti kernels.")
62-
MESSAGE(STATUS "Check OCL_OFFLINE_BUILD_TAHITI_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
64+
# MESSAGE(STATUS "Build dynamic Tahiti kernels.")
65+
# MESSAGE(STATUS "Check OPENCL_OFFLINE_BUILD_TAHITI_KERNEL to build kernls at compile-time. This will eliminates clBuildProgram() overhead and better kernel performance with certain driver.")
6366
add_definitions(-DCLBLAS_TAHITI_DYNAMIC_KERNEL)
64-
else( )
65-
MESSAGE(STATUS "Build static Tahiti kernels.")
66-
MESSAGE(STATUS "Uncheck OCL_OFFLINE_BUILD_TAHITI_KERNEL to build kernls at run-time")
67-
MESSAGE(STATUS "Please ensure the presence of Tahiti device in the system. With certain driver/compiler flags, this might result in compile-time error.")
68-
endif( )
67+
#else( )
68+
# MESSAGE(STATUS "Build static Tahiti kernels.")
69+
# MESSAGE(STATUS "Uncheck OPENCL_OFFLINE_BUILD_TAHITI_KERNEL to build kernls at run-time")
70+
# MESSAGE(STATUS "Please ensure the presence of Tahiti device in the system. With certain driver/compiler flags, this might result in compile-time error.")
71+
#endif( )
6972

7073

7174
# Ask the user to verify compiler version. If OpenCL 2.0 is supported. Certain public flags can be user
72-
set( OCL_VERSION "1.2" CACHE STRING "The version of OpenCL supported by your driver/device" )
73-
set_property( CACHE OCL_VERSION PROPERTY STRINGS 2.0 1.2 1.1 )
74-
message( STATUS "You have confirmed OpenCL ${OCL_VERSION} is supported in your system" )
75+
set( OPENCL_VERSION "1.2" CACHE STRING "The version of OpenCL supported by your driver/device" )
76+
set_property( CACHE OPENCL_VERSION PROPERTY STRINGS 2.0 1.2 1.1 )
77+
message( STATUS "You have confirmed OpenCL ${OPENCL_VERSION} is supported in your system" )
7578

7679
# By default test-correctness is linked and tested against ACML library.
7780
# However, test-correctness can instead use NETLIB as a reference library
@@ -172,16 +175,16 @@ if( UNIX )
172175
endif()
173176

174177
# set the path to specific OpenCL compiler
175-
set( OCL_COMPILER_DIR "OPENCL COMPILER PATH" CACHE PATH "OPENCL COMPILER PATH")
176-
if ( ${OCL_COMPILER_DIR} STREQUAL "OPENCL COMPILER PATH")
177-
message( STATUS "Use default OpenCL Compiler")
178+
set( OPENCL_COMPILER_DIR "OPENCL COMPILER PATH" CACHE PATH "OPENCL COMPILER PATH")
179+
if ( ${OPENCL_COMPILER_DIR} STREQUAL "OPENCL COMPILER PATH")
180+
message( STATUS "Using default OpenCL Compiler")
178181
set(ENV_PATH "$ENV{PATH}")
179182
else ()
180-
message( STATUS "OPENCL COMPILER: ${OCL_COMPILER_DIR}")
183+
message( STATUS "OPENCL COMPILER: ${OPENCL_COMPILER_DIR}")
181184
if(UNIX)
182-
set(ENV_PATH "${OCL_COMPILER_DIR}")
185+
set(ENV_PATH "${OPENCL_COMPILER_DIR}")
183186
else()
184-
set(ENV_PATH "${OCL_COMPILER_DIR}")
187+
set(ENV_PATH "${OPENCL_COMPILER_DIR}")
185188
endif()
186189
endif()
187190

src/client/clfunc_common.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ class clblasFunc
246246
props_[2] = 0;
247247
ctx_ = clCreateContext(props_, 1, &device_, NULL, NULL, &err);
248248
OPENCL_V_THROW(err, "creating context");
249-
queue_ = clCreateCommandQueue(ctx_, device_, 0, &err);
250-
249+
for (unsigned int i = 0; i < numQueues; i++) {
250+
queues_[i] = clCreateCommandQueue(ctx_, device_, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
251+
}
251252

252253
timer_id = timer.getUniqueID( "clfunc", 0 );
253254

@@ -258,16 +259,20 @@ class clblasFunc
258259
err = clblasSetup();
259260
if (err != CL_SUCCESS) {
260261
std::cerr << "clblasSetup() failed with %d\n";
261-
clReleaseCommandQueue(queue_);
262+
for (unsigned int i = 0; i < numQueues; i++) {
263+
clReleaseCommandQueue(queues_[i]);
264+
}
262265
clReleaseContext(ctx_);
263266
}
264267
}
265268

266269
virtual ~clblasFunc()
267270
{
268271
clblasTeardown();
269-
OPENCL_V_THROW( clReleaseCommandQueue(queue_),
270-
"releasing command queue" );
272+
273+
for (unsigned int i = 0; i < numQueues; i++) {
274+
OPENCL_V_THROW( clReleaseCommandQueue(queues_[i]), "releasing command queue" );
275+
}
271276
OPENCL_V_THROW( clReleaseContext(ctx_), "releasing context" );
272277
}
273278

@@ -337,7 +342,8 @@ class clblasFunc
337342
cl_device_id device_;
338343
cl_context_properties props_[3];
339344
cl_context ctx_;
340-
cl_command_queue queue_;
345+
static const unsigned int numQueues = 4;
346+
cl_command_queue queues_[numQueues];
341347
clblasOrder order_;
342348
cl_event event_;
343349
size_t maxMemAllocSize;

0 commit comments

Comments
 (0)