首页 > 代码库 > FIR on Hadoop using hadoop-streaming

FIR on Hadoop using hadoop-streaming

Prepare Hadoop Streaming

Hadoop streaming allows you to create and run Map/Reduce jobs with any executable or script as the mapper and/or the reducer.

1.Download Hadoop Streaming fit for your hadoop version

For hadoop2.4.0, you can visit the following website and download the jar file:

http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-streaming/2.4.0

Than put the jar file to the $HADOOP_HOME folder.

 

2.Hadoop-streaming test in my cluster:

bin/hadoop jar hadoop-streaming-2.4.0.jar -input /in -output /out2 -mapper /bin/cat

-reducer /usr/bin/wc

 

3.Other map reduce demo here:

Python:

http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/

C++:

http://blog.sina.com.cn/s/blog_62a9902f01018rzj.html

 

FIR hardware:

1.fir.h

#ifndef _FIR_H_#define _FIR_H_#include "ap_cint.h"#define N	58#define SAMPLES N+10 // just few more samples then number of tapstypedef short	coef_t;typedef short	data_t;typedef int38	acc_t;#endif

2.fir_coef.dat

-378,-73,27,170,298,352,302,168,14,-80,-64,53,186,216,40,-356,-867,-1283,-1366,-954,-51,1132,2227,2829,2647,1633,25,-1712,-3042,29229,-3042,-1712,25,1633,2647,2829,2227,1132,-51,-954,-1366,-1283,-867,-356,40,216,186,53,-64,-80,14,168,302,352,298,170,27,-73,-378

3.fir.c

#include "fir.h"void fir (  data_t *y,  data_t x  ) {  const coef_t c[N+1]={ #include "fir_coef.dat"    };    static data_t shift_reg[N];  acc_t acc;  int i;    acc=(acc_t)shift_reg[N-1]*(acc_t)c[N];  loop: for (i=N-1;i!=0;i--) {    acc+=(acc_t)shift_reg[i-1]*(acc_t)c[i];    shift_reg[i]=shift_reg[i-1];  }  acc+=(acc_t)x*(acc_t)c[0];  shift_reg[0]=x;  *y = acc>>15;}

4.fir_test.c

#include <stdio.h>#include <math.h>#include "fir.h"void fir (  data_t *y,  data_t x  );int main () {  FILE   *fp;  data_t signal, output;  fp=fopen("fir_impulse.dat","w");  int i;  for (i=0;i<SAMPLES;i++) {	  if(i==0)		  signal = 0x8000;	  else		  signal = 0;	  fir(&output,signal);   	  printf("%i %d %d\n",i,(int)signal,(int)output);//   	  fprintf(fp,"%i %d %d\n",i,signal,output);  }  fclose(fp);  return 0;}

Here is the project in Vivado HLS:

image

Here is the Directive View:

image

In vivado Project Settings:

image

bd:

image

done

 

driver: