MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / axpyCorrectnessTest

Function axpyCorrectnessTest

src/tests/correctness/corr-axpy.cpp:66–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65template <typename T>
66void
67axpyCorrectnessTest(TestParams *params)
68{
69 cl_int err;
70 T *X, *Y; //For OpenCL implementation
71 T *blasX, *blasY;// For reference implementation
72 cl_mem bufX, bufY;
73 clMath::BlasBase *base;
74 cl_event *events;
75 T alpha;
76
77 base = clMath::BlasBase::getInstance();
78
79 if ((typeid(T) == typeid(cl_double) ||
80 typeid(T) == typeid(DoubleComplex)) &&
81 !base->isDevSupportDoublePrecision()) {
82
83 std::cerr << ">> WARNING: The target device doesn't support native "
84 "double precision floating point arithmetic" <<
85 std::endl << ">> Test skipped" << std::endl;
86 SUCCEED();
87 return;
88 }
89
90 printf("number of command queues : %d\n\n", params->numCommandQueues);
91
92 events = new cl_event[params->numCommandQueues];
93 memset(events, 0, params->numCommandQueues * sizeof(cl_event));
94
95 size_t lengthX = (1 + ((params->N -1) * abs(params->incx)));
96 size_t lengthY = (1 + ((params->N -1) * abs(params->incy)));
97
98 X = new T[lengthX + params->offBX ];
99 Y = new T[lengthY + params->offCY ];
100 blasX = new T[lengthX + params->offBX ];
101 blasY = new T[lengthY + params->offCY ];
102
103 if((X == NULL) || (blasX == NULL) || (Y == NULL) || (blasY == NULL))
104 {
105 ::std::cerr << "Cannot allocate memory on host side\n" << "!!!!!!!!!!!!Test skipped.!!!!!!!!!!!!" << ::std::endl;
106 deleteBuffers<T>(X, Y, blasX, blasY);
107 delete[] events;
108 SUCCEED();
109 return;
110 }
111
112 srand(params->seed);
113
114 // Populate X and Y
115 randomVectors(params->N, (X+params->offBX), params->incx, (Y+params->offCY), params->incy);
116
117 memcpy(blasX, X, (lengthX + params->offBX) * sizeof(T));
118 memcpy(blasY, Y, (lengthY + params->offCY) * sizeof(T));
119 alpha = convertMultiplier<T>(params->alpha);
120
121 // Allocate buffers
122 bufX = base->createEnqueueBuffer(X, (lengthX + params->offBX)* sizeof(T), 0, CL_MEM_READ_ONLY);
123 bufY = base->createEnqueueBuffer(Y, (lengthY + params->offCY)* sizeof(T), 0, CL_MEM_READ_WRITE);

Callers

nothing calls this directly

Calls 7

randomVectorsFunction · 0.85
printTestParamsFunction · 0.85
createEnqueueBufferMethod · 0.80
commandQueuesMethod · 0.80
releaseMemObjectsFunction · 0.70
waitForSuccessfulFinishFunction · 0.50

Tested by

no test coverage detected