-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (62 loc) · 1.63 KB
/
main.cpp
File metadata and controls
66 lines (62 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <iomanip>
#include "platformMalloc.h"
#include "floatMul.h"
#include "featureSupport.h"
const int cWidth = 256;
const int cHeight = cWidth;
const int cSize = cHeight * cWidth;
typedef unsigned char uchar;
bool examineTest(uchar *result, uchar *result_examine, int cSize)
{
bool flag = true;
int i = 0;
for (i = 0;i < cSize;i++)
{
if (result[i] != result_examine[i])
{
flag = false;
break;
}
}
if (flag == false)
{
std::cout << "Failed on " << i << " expected:" << result_examine[i] << " actual:" << result[i] << std::endl;
}
return flag;
}
int main()
{
if (checkFeatureSupport() == false)
{
return 1;
}
uchar* image = reinterpret_cast<uchar*>(alignedMalloc(cSize*sizeof(uchar),ALIGN));
short* gain = reinterpret_cast<short*>(alignedMalloc(cSize*sizeof(short),ALIGN));
float* gainOriginal = reinterpret_cast<float*>(alignedMalloc(cSize*sizeof(float),ALIGN));
uchar* result = reinterpret_cast<uchar*>(alignedMalloc(cSize*sizeof(uchar),ALIGN));
uchar* result_examine = reinterpret_cast<uchar*>(alignedMalloc(cSize*sizeof(uchar),ALIGN));
for (unsigned int i = 0;i < cSize;i++)
{
gainOriginal[i] = 1.0f;
image[i] = (i & 255);
}
float2half(gainOriginal, gain, cSize);
multiply(image, gain, result, cSize);
multiply_float(image, gainOriginal, result_examine, cSize);
bool examineResult = examineTest(result, result_examine, cSize);
alignedFree(result_examine);
alignedFree(result);
alignedFree(gainOriginal);
alignedFree(gain);
alignedFree(image);
if (examineResult == true)
{
std::cout << "test passed" << std::endl;
return 0;
}
else
{
return 1;
}
}