Skip to content

Instantly share code, notes, and snippets.

@itisravi
Created April 20, 2011 11:01
Show Gist options
  • Save itisravi/930997 to your computer and use it in GitHub Desktop.
Save itisravi/930997 to your computer and use it in GitHub Desktop.
#include <arm_neon.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#define SIZE (4*1000)
void double_elements(unsigned int *ptr, unsigned int size);
int main(void)
{
struct timeval tv1,tv2;
unsigned int i;
uint32_t input_array[SIZE];
uint32_t *ptr=input_array;
for(i=0;i<SIZE;i++)
{
input_array[i]=i+1;
#ifdef DEBUG
printf("Input:%d\n",input_array[i]);
#endif
}
gettimeofday(&tv1,NULL);
double_elements(input_array,SIZE);
gettimeofday(&tv2,NULL);
printf("\n");
#ifdef DEBUG
for(i=0;i<SIZE;i++)
printf("Output:%d\n",input_array[i]);
#endif
printf("Time for compute : %d microseconds\n", tv2.tv_usec - tv1.tv_usec +1000000 * (tv2.tv_sec - tv1.tv_sec));
return 0;
}
void double_elements(unsigned int *ptr, unsigned int size)
{
unsigned int i;
uint32x4_t Q0,Q1;
for( i=0;i<(size/4);i++)
{
Q0=vld1q_u32(ptr);
Q1=vshlq_n_u32(Q0,(const int)1);//Q1=vaddq_u32(Q0,Q0);
vst1q_u32(ptr,Q1);
ptr+=4;
}
return;
}
@itisravi
Copy link
Author

arm-v7a8-linux-gnueabi-gcc -mfpu=neon neon.c -o neon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment