34 #define CPUINFO_BUFFER_SIZE (1024*4)
37 ne10_result_t is_NEON_available = NE10_ERR;
39 ne10_result_t ne10_HasNEON()
41 return is_NEON_available;
44 ne10_result_t ne10_init()
46 ne10_result_t status = NE10_ERR;
48 FILE* infofile = NULL;
49 ne10_int8_t cpuinfo[CPUINFO_BUFFER_SIZE];
50 ne10_uint32_t bytes = 0;
53 memset (cpuinfo, 0, CPUINFO_BUFFER_SIZE);
54 infofile = fopen (
"/proc/cpuinfo",
"r");
58 fprintf(stderr,
"ERROR: couldn't read file \"/proc/cpuinfo\".\n");
62 bytes = fread (cpuinfo, 1,
sizeof (cpuinfo), infofile);
65 if (0 == bytes || CPUINFO_BUFFER_SIZE == bytes)
67 fprintf (stderr,
"ERROR: Couldn't read the file \"/proc/cpuinfo\". NE10_init() failed.\n");
71 while (
'\0' != cpuinfo[i])
73 cpuinfo[i] = (ne10_int8_t) tolower (cpuinfo[i]);
77 if (0 != strstr ( (
const char *)cpuinfo,
"neon"))
79 is_NEON_available = NE10_OK;
82 is_NEON_available = NE10_OK;
85 #if defined (NE10_ENABLE_MATH)
86 status = ne10_init_math (is_NEON_available);
87 if (status != NE10_OK)
89 fprintf(stderr,
"ERROR: init math failed\n");
94 #if defined (NE10_ENABLE_DSP)
95 status = ne10_init_dsp (is_NEON_available);
96 if (status != NE10_OK)
98 fprintf(stderr,
"ERROR: init dsp failed\n");
103 #if defined (NE10_ENABLE_IMGPROC)
104 status = ne10_init_imgproc (is_NEON_available);
105 if (status != NE10_OK)
107 fprintf(stderr,
"ERROR: init imgproc failed\n");
112 #if defined (NE10_ENABLE_PHYSICS)
113 status = ne10_init_physics (is_NEON_available);
114 if (status != NE10_OK)
116 fprintf(stderr,
"ERROR: init imgproc failed\n");