Skip to content

Commit 797f760

Browse files
committed
benchmark for openvx kernels(35)
1 parent d6c92f6 commit 797f760

Some content is hidden

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

44 files changed

+5983
-1
lines changed

Makefile

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
CC = gcc
2+
3+
SRC_DIR=examples_kernels
4+
BIN_DIR=bin_kernels
5+
6+
#CFLAGS += -I$(PULP_SDK_HOME)/install/include -D__OPENRISC__ -D_LITTLE_ENDIAN_ -Wno-incompatible-pointer-types
7+
LDFLAGS += -lopenvx -lopenvx-helper -lvx_debug -lopenvx-debug_k-lib -lopenvx-debug-lib -lopenvx-extras-lib -lm -Wl,--no-whole-archive
8+
9+
10+
all: $(SRC_DIR)/lut.c
11+
mkdir -p $(BIN_DIR)
12+
$(CC) -o $(BIN_DIR)/box $(SRC_DIR)/box.c $(CFLAGS) $(LDFLAGS)
13+
$(CC) -o $(BIN_DIR)/gaussian $(SRC_DIR)/gaussian.c $(CFLAGS) $(LDFLAGS)
14+
$(CC) -o $(BIN_DIR)/median $(SRC_DIR)/median.c $(CFLAGS) $(LDFLAGS)
15+
$(CC) -o $(BIN_DIR)/canny_1 $(SRC_DIR)/canny_1.c $(CFLAGS) $(LDFLAGS)
16+
$(CC) -o $(BIN_DIR)/canny_2 $(SRC_DIR)/canny_2.c $(CFLAGS) $(LDFLAGS)
17+
$(CC) -o $(BIN_DIR)/scale $(SRC_DIR)/scale.c $(CFLAGS) $(LDFLAGS)
18+
$(CC) -o $(BIN_DIR)/sobel $(SRC_DIR)/sobel.c $(CFLAGS) $(LDFLAGS)
19+
$(CC) -o $(BIN_DIR)/magnitude $(SRC_DIR)/magnitude.c $(CFLAGS) $(LDFLAGS)
20+
$(CC) -o $(BIN_DIR)/thresh $(SRC_DIR)/thresh.c $(CFLAGS) $(LDFLAGS)
21+
$(CC) -o $(BIN_DIR)/phase $(SRC_DIR)/phase.c $(CFLAGS) $(LDFLAGS)
22+
$(CC) -o $(BIN_DIR)/lut $(SRC_DIR)/lut.c $(CFLAGS) $(LDFLAGS)
23+
$(CC) -o $(BIN_DIR)/absdiff $(SRC_DIR)/absdiff.c $(CFLAGS) $(LDFLAGS)
24+
# $(CC) -o $(BIN_DIR)/absdiff_1 $(SRC_DIR)/absdiff_1.c $(CFLAGS) $(LDFLAGS)
25+
$(CC) -o $(BIN_DIR)/integral $(SRC_DIR)/integral.c $(CFLAGS) $(LDFLAGS)
26+
$(CC) -o $(BIN_DIR)/erode $(SRC_DIR)/erode.c $(CFLAGS) $(LDFLAGS)
27+
$(CC) -o $(BIN_DIR)/dilate $(SRC_DIR)/dilate.c $(CFLAGS) $(LDFLAGS)
28+
$(CC) -o $(BIN_DIR)/convdepth_up $(SRC_DIR)/convdepth_up.c $(CFLAGS) $(LDFLAGS)
29+
$(CC) -o $(BIN_DIR)/convdepth_down $(SRC_DIR)/convdepth_down.c $(CFLAGS) $(LDFLAGS)
30+
$(CC) -o $(BIN_DIR)/histogram $(SRC_DIR)/histogram.c $(CFLAGS) $(LDFLAGS)
31+
$(CC) -o $(BIN_DIR)/equal_hist $(SRC_DIR)/equal_hist.c $(CFLAGS) $(LDFLAGS)
32+
$(CC) -o $(BIN_DIR)/remap $(SRC_DIR)/remap.c $(CFLAGS) $(LDFLAGS)
33+
$(CC) -o $(BIN_DIR)/mean_std $(SRC_DIR)/mean_std.c $(CFLAGS) $(LDFLAGS)
34+
$(CC) -o $(BIN_DIR)/minmaxloc $(SRC_DIR)/minmaxloc.c $(CFLAGS) $(LDFLAGS)
35+
$(CC) -o $(BIN_DIR)/add $(SRC_DIR)/add.c $(CFLAGS) $(LDFLAGS)
36+
$(CC) -o $(BIN_DIR)/multiply $(SRC_DIR)/multiply.c $(CFLAGS) $(LDFLAGS)
37+
# $(CC) -o $(BIN_DIR)/multiply_1 $(SRC_DIR)/multiply_1.c $(CFLAGS) $(LDFLAGS)
38+
$(CC) -o $(BIN_DIR)/sub $(SRC_DIR)/sub.c $(CFLAGS) $(LDFLAGS)
39+
$(CC) -o $(BIN_DIR)/colorconvert $(SRC_DIR)/colorconvert.c $(CFLAGS) $(LDFLAGS)
40+
$(CC) -o $(BIN_DIR)/channel_extract $(SRC_DIR)/channel_extract.c $(CFLAGS) $(LDFLAGS)
41+
$(CC) -o $(BIN_DIR)/channel_combine $(SRC_DIR)/channel_combine.c $(CFLAGS) $(LDFLAGS)
42+
# $(CC) -o $(BIN_DIR)/channel_combine_1 $(SRC_DIR)/channel_combine_1.c $(CFLAGS) $(LDFLAGS)
43+
$(CC) -o $(BIN_DIR)/accu $(SRC_DIR)/accu.c $(CFLAGS) $(LDFLAGS)
44+
$(CC) -o $(BIN_DIR)/accu_weight $(SRC_DIR)/accu_weight.c $(CFLAGS) $(LDFLAGS)
45+
$(CC) -o $(BIN_DIR)/accu_square $(SRC_DIR)/accu_square.c $(CFLAGS) $(LDFLAGS)
46+
$(CC) -o $(BIN_DIR)/bitwise_and $(SRC_DIR)/bitwise_and.c $(CFLAGS) $(LDFLAGS)
47+
$(CC) -o $(BIN_DIR)/bitwise_or $(SRC_DIR)/bitwise_or.c $(CFLAGS) $(LDFLAGS)
48+
$(CC) -o $(BIN_DIR)/bitwise_xor $(SRC_DIR)/bitwise_xor.c $(CFLAGS) $(LDFLAGS)
49+
$(CC) -o $(BIN_DIR)/bitwise_not $(SRC_DIR)/bitwise_not.c $(CFLAGS) $(LDFLAGS)
50+
$(CC) -o $(BIN_DIR)/half_gaussian $(SRC_DIR)/half_gaussian.c $(CFLAGS) $(LDFLAGS)
51+
.PHONY: clean
52+
.PHONY: clean
53+
.PHONY: clean
54+
.PHONY: clean
55+
.PHONY: clean
56+
.PHONY: clean
57+
.PHONY: clean
58+
.PHONY: clean
59+
.PHONY: clean
60+
61+
clean:
62+
rm -rf $(BIN_DIR)/*

ReadMe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ After the envoriment is ready, download the files from this repo. We can use *Ma
1515

1616
`$ ./gaussian ` (or other executable files)
1717

18-
Credits: OpenVX (https://www.khronos.org/openvx/)
18+
Credits: OpenVX (https://www.khronos.org/openvx/)

ds_store.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
#**************************************
3+
# File Name: post.sh
4+
# Author: Xiaoyan Zhuo
5+
6+
# Created Time : 18 Sep 2018 23:25:08
7+
#**************************************
8+
find . -name '.DS_Store' -delete

examples_kernels/absdiff.c

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include <math.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
6+
#include <VX/vx.h>
7+
#include <VX/vx_helper.h>
8+
#include <VX/vx_lib_debug.h>
9+
#include <VX/vx_compatibility.h>
10+
#include <VX/vx_types.h>
11+
#include <assert.h>
12+
13+
static void vx_print_log(vx_reference ref)
14+
{
15+
char message[VX_MAX_LOG_MESSAGE_LEN];
16+
vx_uint32 errnum = 1;
17+
vx_status status = VX_SUCCESS;
18+
do {
19+
status = vxGetLogEntry(ref, message);
20+
if (status != VX_SUCCESS)
21+
printf("[%05u] error=%d %s", errnum++, status, message);
22+
} while (status != VX_SUCCESS);
23+
}
24+
25+
int main(int argc, char *argv[])
26+
{
27+
vx_status status = VX_SUCCESS;
28+
vx_uint32 width = 640;
29+
vx_uint32 height = 480;
30+
vx_uint32 i;
31+
// step 1: Create context
32+
vx_context context = vxCreateContext();
33+
if (context)
34+
{
35+
//vxLoadKernels(context, "openvx-c_model");
36+
vxLoadKernels(context, "openvx-debug");
37+
38+
// step 2: Images (in/output)
39+
vx_image images[] = {
40+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
41+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
42+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
43+
};
44+
45+
vx_lut lut = vxCreateLUT(context, VX_TYPE_UINT8, 256);
46+
vxuFReadImage(context, "../raw/bikegray_640x480.pgm", images[0]);
47+
vxuFReadImage(context, "../raw/lut_640x480.pgm", images[1]);
48+
49+
// step 3: Graph init
50+
vx_graph graph = vxCreateGraph(context);
51+
52+
// step 4: Graph nodes construstion
53+
if (graph)
54+
{
55+
vx_node nodes[] = {
56+
vxAbsDiffNode(graph, images[1], images[0], images[2]),
57+
};
58+
59+
for (i = 0; i < dimof(nodes); i++)
60+
{
61+
if (nodes[i] == 0)
62+
{
63+
printf("Failed to make nodes[%u]\n",i);
64+
}
65+
}
66+
67+
// step 5: GRAPH VERIFICATION
68+
status = vxVerifyGraph(graph);
69+
vx_print_log((vx_reference)graph);
70+
printf("AFTER VERIFICATION (status: %d)\n", status);
71+
if (status == VX_SUCCESS)
72+
{
73+
status = vxProcessGraph(graph);
74+
assert(status == VX_SUCCESS);
75+
}
76+
else
77+
{
78+
vx_print_log((vx_reference)graph);
79+
}
80+
81+
// step 6: GRAPH EXECUTION
82+
if (status == VX_SUCCESS)
83+
{
84+
status = vxProcessGraph(graph);
85+
// WRITE RESULT
86+
vxuFWriteImage(context, images[2], "../raw/absdiff_640x480.pgm");
87+
printf("AFTER GRAPH EXECUTION (status: %d)\n", status);
88+
}
89+
else
90+
{
91+
printf("Graph failed (%d)\n", status);
92+
for (i = 0; i < dimof(nodes); i++)
93+
{
94+
status = VX_SUCCESS;
95+
vxQueryNode(nodes[i], VX_NODE_ATTRIBUTE_STATUS, &status, sizeof(status));
96+
if (status != VX_SUCCESS)
97+
{
98+
printf("nodes[%u] failed with %d\n", i, status);
99+
}
100+
}
101+
status = VX_ERROR_NOT_SUFFICIENT;
102+
}
103+
// step 7: Release: nodes, graph, images, context
104+
for (i = 0; i < dimof(nodes); i++)
105+
{
106+
vxReleaseNode(&nodes[i]);
107+
}
108+
vxReleaseGraph(&graph);
109+
}
110+
111+
for (i = 0; i < dimof(images); i++)
112+
{
113+
vxReleaseImage(&images[i]);
114+
}
115+
vxReleaseContext(&context);
116+
}
117+
return status;
118+
}
119+

examples_kernels/absdiff_1.c

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include <math.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
6+
#include <VX/vx.h>
7+
#include <VX/vx_helper.h>
8+
#include <VX/vx_lib_debug.h>
9+
#include <VX/vx_compatibility.h>
10+
#include <VX/vx_types.h>
11+
#include <assert.h>
12+
13+
static void vx_print_log(vx_reference ref)
14+
{
15+
char message[VX_MAX_LOG_MESSAGE_LEN];
16+
vx_uint32 errnum = 1;
17+
vx_status status = VX_SUCCESS;
18+
do {
19+
status = vxGetLogEntry(ref, message);
20+
if (status != VX_SUCCESS)
21+
printf("[%05u] error=%d %s", errnum++, status, message);
22+
} while (status != VX_SUCCESS);
23+
}
24+
25+
int main(int argc, char *argv[])
26+
{
27+
vx_status status = VX_SUCCESS;
28+
vx_uint32 width = 640;
29+
vx_uint32 height = 480;
30+
vx_uint32 i;
31+
// step 1: Create context
32+
vx_context context = vxCreateContext();
33+
if (context)
34+
{
35+
//vxLoadKernels(context, "openvx-c_model");
36+
vxLoadKernels(context, "openvx-debug");
37+
38+
// step 2: Images (in/output)
39+
vx_image images[] = {
40+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
41+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
42+
vxCreateImage(context, width, height, VX_DF_IMAGE_U8),
43+
};
44+
45+
vx_lut lut = vxCreateLUT(context, VX_TYPE_UINT8, 256);
46+
vxuFReadImage(context, "../raw/bikegray_640x480.pgm", images[0]);
47+
48+
// step 3: Graph init
49+
vx_graph graph = vxCreateGraph(context);
50+
51+
// step 4: Graph nodes construstion
52+
if (graph)
53+
{
54+
vx_node nodes[] = {
55+
vxTableLookupNode(graph, images[0], lut, images[1]),
56+
vxAbsDiffNode(graph, images[1], images[0], images[2]),
57+
};
58+
59+
for (i = 0; i < dimof(nodes); i++)
60+
{
61+
if (nodes[i] == 0)
62+
{
63+
printf("Failed to make nodes[%u]\n",i);
64+
}
65+
}
66+
67+
// step 5: GRAPH VERIFICATION
68+
status = vxVerifyGraph(graph);
69+
vx_print_log((vx_reference)graph);
70+
printf("AFTER VERIFICATION (status: %d)\n", status);
71+
if (status == VX_SUCCESS)
72+
{
73+
status = vxProcessGraph(graph);
74+
assert(status == VX_SUCCESS);
75+
}
76+
else
77+
{
78+
vx_print_log((vx_reference)graph);
79+
}
80+
81+
// step 6: GRAPH EXECUTION
82+
if (status == VX_SUCCESS)
83+
{
84+
status = vxProcessGraph(graph);
85+
// WRITE RESULT
86+
vxuFWriteImage(context, images[2], "../raw/absdiff_1_640x480.pgm");
87+
printf("AFTER GRAPH EXECUTION (status: %d)\n", status);
88+
}
89+
else
90+
{
91+
printf("Graph failed (%d)\n", status);
92+
for (i = 0; i < dimof(nodes); i++)
93+
{
94+
status = VX_SUCCESS;
95+
vxQueryNode(nodes[i], VX_NODE_ATTRIBUTE_STATUS, &status, sizeof(status));
96+
if (status != VX_SUCCESS)
97+
{
98+
printf("nodes[%u] failed with %d\n", i, status);
99+
}
100+
}
101+
status = VX_ERROR_NOT_SUFFICIENT;
102+
}
103+
// step 7: Release: nodes, graph, images, context
104+
for (i = 0; i < dimof(nodes); i++)
105+
{
106+
vxReleaseNode(&nodes[i]);
107+
}
108+
vxReleaseGraph(&graph);
109+
}
110+
111+
for (i = 0; i < dimof(images); i++)
112+
{
113+
vxReleaseImage(&images[i]);
114+
}
115+
vxReleaseContext(&context);
116+
}
117+
return status;
118+
}
119+

0 commit comments

Comments
 (0)