1 // 2 // Copyright (c) 2017 The Khronos Group Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 #include "testBase.h" 17 18 19 #include "harness/conversions.h" 20 #include "harness/typeWrappers.h" 21 22 typedef struct _clState 23 { 24 cl_device_id m_device; 25 cl_context m_context; 26 cl_command_queue m_queue; 27 28 cl_program m_program; 29 cl_kernel m_kernel; 30 size_t m_numThreads; 31 } clState; 32 33 clState * newClState(cl_device_id device, cl_context context, cl_command_queue queue); 34 clState * destroyClState(clState * pState); 35 36 int clStateMakeProgram(clState * pState, const char * prog, 37 const char * kernelName); 38 void clStateDestroyProgramAndKernel(clState * pState); 39 40 int runKernel(clState * pState, size_t numThreads); 41 42 typedef struct _bufferStruct 43 { 44 void * m_pIn; 45 void * m_pOut; 46 47 cl_mem m_outBuffer; 48 cl_mem m_inBuffer; 49 50 size_t m_bufSizeIn, m_bufSizeOut; 51 52 int m_bufferUploaded; 53 } bufferStruct; 54 55 56 bufferStruct * newBufferStruct(size_t inSize, size_t outSize, clState * pClState); 57 58 bufferStruct * destroyBufferStruct(bufferStruct * destroyMe, clState * pClState); 59 60 void initContents(bufferStruct * pBufferStruct, clState * pClState, 61 size_t typeSize, 62 size_t vecWidth); 63 64 int pushArgs(bufferStruct * pBufferStruct, clState * pClState); 65 int retrieveResults(bufferStruct * pBufferStruct, clState * pClState); 66 67 // vecSizeIdx indexes into g_arrVecAlignMasks, g_arrVecSizeNames 68 // and g_arrVecSizes 69 int checkCorrectness(bufferStruct * pBufferStruct, clState * pClState, 70 size_t minAlign); 71 72 int checkPackedCorrectness(bufferStruct * pBufferStruct, clState * pClState, 73 size_t totSize, size_t beforeSize); 74