associative functions implemented on clearspeed csx600

24
Associative Functions implemented on ClearSpeed CSX600 Mike Yuan

Upload: chanda-riley

Post on 04-Jan-2016

30 views

Category:

Documents


3 download

DESCRIPTION

Associative Functions implemented on ClearSpeed CSX600. Mike Yuan. Introduction. Important for ATC applications asc.cn, asc.h, asc_asm.cn, carlot.h and carlot_n Overview - PickOne: get, next - AnyResponder: any, ascNany - MAX/MIN: max_int, min_int, max_float, min_float Three versions - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Associative Functions implemented on ClearSpeed CSX600

Associative Functions implemented on ClearSpeed CSX600

Mike Yuan

Page 2: Associative Functions implemented on ClearSpeed CSX600

Introduction Important for ATC applications asc.cn, asc.h, asc_asm.cn, carlot.h and carlot_n Overview - PickOne: get, next- AnyResponder: any, ascNany- MAX/MIN: max_int, min_int, max_float, min_float Three versions- Pure Cn (preferred): all functions in asc.cn- Assembler: max, min in asc_asm.cn- Mixed Cn and assembler: get, next, ascAny, ascNany in

asc_asm.cn

Page 3: Associative Functions implemented on ClearSpeed CSX600

Compile and run For Cn versions-bash-3.00$ cscn -o test1.csx carlot_next.cn

asc.cn-bash-3.00$ csrun test1.csx For mixed and assembler versions-bash-3.00$ cscn -o test1.csx carlot_next.cn

asc_asm.cn-bash-3.00$ csrun test1.csx

Page 4: Associative Functions implemented on ClearSpeed CSX600

Get

Signature: mono short get (poly const char mask)

Return the first PE number of the enabled PEs

Page 5: Associative Functions implemented on ClearSpeed CSX600

Get example codes//set the mask to only PE's with a 1991 model car.

if (mycarlot.year == 1991){

mask = 1;}

//get first car with the year 1991ONE = get(mask);

//set the ONE to color Mif (get_penum() == ONE){

mycarlot.color = 'M';}

Page 6: Associative Functions implemented on ClearSpeed CSX600

Get results produced Before:1990 L F 11991 R H 11992 O T 0 After:1990 L F 11991 M H 11992 O T 0

Page 7: Associative Functions implemented on ClearSpeed CSX600

Next

Signature: mono short next (poly const char mask, short ONE)

Return the PE number of the next PE in the mask

Page 8: Associative Functions implemented on ClearSpeed CSX600

Next example codes//get NEXT car with 1991 year.

ONE = next(mask,ONE);//set the second one to color Nif (get_penum() == ONE){

mycarlot.color = 'N';}//skip to the fourth carwith year 1991ONE = next(mask,ONE);ONE = next(mask,ONE);

//set the forth car with year 1991 to Zif (get_penum() == ONE){

mycarlot.color = 'Z';}

Page 9: Associative Functions implemented on ClearSpeed CSX600

Next results produced Before:1991 G D 119 91 L H 11991 Y D 1 After:1991 N D 11991 L H 11991 Z D 1

Page 10: Associative Functions implemented on ClearSpeed CSX600

any

Signature: mono char any (poly int condition);

Test the condition condition on all of the enabled PEs and returns true if any of the enabled PEs return true

Page 11: Associative Functions implemented on ClearSpeed CSX600

Example codes//set mask

if (mycarlot.year == 1991){

mask = 1;}

//turn off PE's not in maskif (mask){

//if there are any red and 1991 carsif(any(mycarlot.color == 'R')){

//all cars turn to color Tmycarlot.color = 'T';

}}

Page 12: Associative Functions implemented on ClearSpeed CSX600

any results

Before there is a:1991 R D 1 After1991 T H 11991 T D 11991 T H 1

Page 13: Associative Functions implemented on ClearSpeed CSX600

ascNany

Signature: mono char ascNany (poly int condition);

Test the condition condition on all of the enabled PEs and returns true if all of the enabled PEs return false

Page 14: Associative Functions implemented on ClearSpeed CSX600

ascNany (cont) Example codes:

if(ascNany(mycarlot.color=='NONE'))

{mycarlot.onlot = 0;

} Results1991 T H 01991 T D 01991 T H 0

Page 15: Associative Functions implemented on ClearSpeed CSX600

Max for int/float/short

Signature of max: int max_int(poly int value)

Return the maximum instance of a signed poly int value

Page 16: Associative Functions implemented on ClearSpeed CSX600

Min for int/float/short

Signature of min: int min_int(poly int value)

Return the minimum instance of a signed poly int value

Page 17: Associative Functions implemented on ClearSpeed CSX600

Max/Min (cont) Example codes

poly int index = get_penum();int max_index, min_index;

max_index = max_int(index);printf ("The maximum of PE number is: %d\n", max_index);

min_index = min_int(index);printf ("The minimum of PE number is: %d\n", min_index);

Results The maximum of PE number is: 95The minimum of PE number is: 0

Page 18: Associative Functions implemented on ClearSpeed CSX600

Timing Record cycles of operations Example codes: // min_int start_time = get_cycles_ila(); min_int_result = min_int(int_value); elapsed_time = get_cycles_ila() - start_time;

printf("min_int Result: %2d Time: %4u\n",min_int_result, elapsed_time);

Page 19: Associative Functions implemented on ClearSpeed CSX600

Timing (cont)

Results:min_int Result: 0 Time: 6377 run csreset -v and the frequency is

displayed Core clock frequency: Processor 0:

210.0 MHz, Processor 1: 210.0 MHz 6377/210M=30.367 ms

Page 20: Associative Functions implemented on ClearSpeed CSX600

Random function Generate random data in PE Randp() generates random numbers

between 0 and RAND_MAX Example codes:poly int rand_num = 0;rand_num = randp();plane.speed[i] = (scale *

(rand_num*(600.0 - 30.0)/RAND_MAX + 30));

Page 21: Associative Functions implemented on ClearSpeed CSX600

Random number (cont)

Problem: average is median: (600-30)/2=285, not 250

Use Poisson distribution or Weibu distribution to get average=250

Page 22: Associative Functions implemented on ClearSpeed CSX600

Handle timer

Do timing in host for accuracy Two semaphores sem_start, sem_end

between host and PE Host signals sem_start and records

time PE waits for it and then execute PE signals sem_end Host waits for sem_end

Page 23: Associative Functions implemented on ClearSpeed CSX600

Handle timer (cont)

Host records time How much time spent? If > 0.5s, error Else if< 0.5s, wait for rest of time

Page 24: Associative Functions implemented on ClearSpeed CSX600

Task scheduling

One .csx file A count for every 0.5s If count=8, do terrain avoidance If count=16, do conflict detection

and correlation