Implemented simple operation cache
This commit is contained in:
@@ -568,7 +568,7 @@ mproduct_parameters::mproduct_parameters(unsigned int simd_width
|
||||
void mproduct::enqueue_block(cl::CommandQueue & queue, int_t M, int_t N, int_t K,
|
||||
array_infos const & A, array_infos const & B, array_infos const & C,
|
||||
value_scalar const & alpha, value_scalar const & beta,
|
||||
std::vector<cl_ext::lazy_compiler> & programs, unsigned int label, int id)
|
||||
std::vector<cl_ext::lazy_compiler> & programs, unsigned int label, int id, operation_cache * cache)
|
||||
{
|
||||
if (A.shape1==0 || A.shape2==0 || B.shape1==0 || B.shape2==0 || C.shape1==0 || C.shape2==0)
|
||||
return;
|
||||
@@ -596,6 +596,9 @@ mproduct_parameters::mproduct_parameters(unsigned int simd_width
|
||||
fun.set_arguments(beta.dtype(), beta.values());
|
||||
|
||||
queue.enqueueNDRangeKernel(kernel, cl::NullRange, grange, lrange);
|
||||
|
||||
if(cache)
|
||||
cache->push_back(queue, kernel, cl::NullRange, grange, lrange);
|
||||
}
|
||||
|
||||
array_infos mproduct::create_slice(array_infos & M, int_t s0_0, int_t s0_1, int_t s1_0, int_t s1_1, bool swap)
|
||||
@@ -646,7 +649,7 @@ mproduct_parameters::mproduct_parameters(unsigned int simd_width
|
||||
return infos(expressions, d0, d1, d2);
|
||||
}
|
||||
|
||||
void mproduct::enqueue(cl::CommandQueue & queue, std::vector<cl_ext::lazy_compiler> & programs, unsigned int label, expressions_tuple const & expressions)
|
||||
void mproduct::enqueue(cl::CommandQueue & queue, std::vector<cl_ext::lazy_compiler> & programs, unsigned int label, expressions_tuple const & expressions, operation_cache * cache)
|
||||
{
|
||||
using namespace tools;
|
||||
|
||||
@@ -684,7 +687,7 @@ mproduct_parameters::mproduct_parameters(unsigned int simd_width
|
||||
{
|
||||
enqueue_block(queue, M, N, K, create_slice(pA, 0, M, 0, K, swap_A),
|
||||
create_slice(pB, 0, K, 0, N, swap_B),
|
||||
create_slice(pC, 0, M, 0, N, false), *_1, *_0, programs, label, 1);
|
||||
create_slice(pC, 0, M, 0, N, false), *_1, *_0, programs, label, 1, cache);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -692,17 +695,17 @@ mproduct_parameters::mproduct_parameters(unsigned int simd_width
|
||||
int_t lN = N / p_.nL * p_.nL;
|
||||
int_t lK = K / p_.kL * p_.kL;
|
||||
|
||||
enqueue_block(queue, lM, lN, lK, create_slice(pA, 0, lM, 0, lK, swap_A), create_slice(pB, 0, lK, 0, lN, swap_B), create_slice(pC, 0, lM, 0, lN, false), *_1, *_0, programs, label, 0);
|
||||
enqueue_block(queue, lM, lN, K - lK, create_slice(pA, 0, lM, lK, K, swap_A), create_slice(pB, lK, K, 0, lN, swap_B), create_slice(pC, 0, lM, 0, lN, false), *_1, *_1, programs, label, 1);
|
||||
enqueue_block(queue, lM, lN, lK, create_slice(pA, 0, lM, 0, lK, swap_A), create_slice(pB, 0, lK, 0, lN, swap_B), create_slice(pC, 0, lM, 0, lN, false), *_1, *_0, programs, label, 0, cache);
|
||||
enqueue_block(queue, lM, lN, K - lK, create_slice(pA, 0, lM, lK, K, swap_A), create_slice(pB, lK, K, 0, lN, swap_B), create_slice(pC, 0, lM, 0, lN, false), *_1, *_1, programs, label, 1, cache);
|
||||
|
||||
enqueue_block(queue, lM, N - lN, lK, create_slice(pA, 0, lM, 0, lK, swap_A), create_slice(pB, 0, lK, lN, N, swap_B), create_slice(pC, 0, lM, lN, N, false), *_1, *_0, programs, label, 1);
|
||||
enqueue_block(queue, lM, N - lN, K - lK, create_slice(pA, 0, lM, lK, K, swap_A), create_slice(pB, lK, K, lN, N, swap_B), create_slice(pC, 0, lM, lN, N, false), *_1, *_1, programs, label, 1);
|
||||
enqueue_block(queue, lM, N - lN, lK, create_slice(pA, 0, lM, 0, lK, swap_A), create_slice(pB, 0, lK, lN, N, swap_B), create_slice(pC, 0, lM, lN, N, false), *_1, *_0, programs, label, 1, cache);
|
||||
enqueue_block(queue, lM, N - lN, K - lK, create_slice(pA, 0, lM, lK, K, swap_A), create_slice(pB, lK, K, lN, N, swap_B), create_slice(pC, 0, lM, lN, N, false), *_1, *_1, programs, label, 1, cache);
|
||||
|
||||
enqueue_block(queue, M - lM, lN, lK, create_slice(pA, lM, M, 0, lK, swap_A), create_slice(pB, 0, lK, 0, lN, swap_B), create_slice(pC, lM, M, 0, lN, false), *_1, *_0, programs, label, 1);
|
||||
enqueue_block(queue, M - lM, lN, K - lK, create_slice(pA, lM, M, lK, K, swap_A), create_slice(pB, lK, K, 0, lN, swap_B), create_slice(pC, lM, M, 0, lN, false), *_1, *_1, programs, label, 1);
|
||||
enqueue_block(queue, M - lM, lN, lK, create_slice(pA, lM, M, 0, lK, swap_A), create_slice(pB, 0, lK, 0, lN, swap_B), create_slice(pC, lM, M, 0, lN, false), *_1, *_0, programs, label, 1, cache);
|
||||
enqueue_block(queue, M - lM, lN, K - lK, create_slice(pA, lM, M, lK, K, swap_A), create_slice(pB, lK, K, 0, lN, swap_B), create_slice(pC, lM, M, 0, lN, false), *_1, *_1, programs, label, 1, cache);
|
||||
|
||||
enqueue_block(queue, M - lM, N - lN, lK, create_slice(pA, lM, M, 0, lK, swap_A), create_slice(pB, 0, lK, lN, N, swap_B), create_slice(pC, lM, M, lN, N, false), *_1, *_0, programs, label, 1);
|
||||
enqueue_block(queue, M - lM, N - lN, K - lK, create_slice(pA, lM, M, lK, K, swap_A), create_slice(pB, lK, K, lN, N, swap_B), create_slice(pC, lM, M, lN, N, false), *_1, *_1, programs, label, 1);
|
||||
enqueue_block(queue, M - lM, N - lN, lK, create_slice(pA, lM, M, 0, lK, swap_A), create_slice(pB, 0, lK, lN, N, swap_B), create_slice(pC, lM, M, lN, N, false), *_1, *_0, programs, label, 1, cache);
|
||||
enqueue_block(queue, M - lM, N - lN, K - lK, create_slice(pA, lM, M, lK, K, swap_A), create_slice(pB, lK, K, lN, N, swap_B), create_slice(pC, lM, M, lN, N, false), *_1, *_1, programs, label, 1, cache);
|
||||
}
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user