Вы находитесь на странице: 1из 88

.. , .. , ..

MPP-
-
..

2-,

2010

004.4(076.5)
32.973-187
12
.., .., .. : - / . .. . . 2-, .
. .: , 2010. 88 .

MPP-,
TMS320C40 .
4- ,
.
. ,
, 5-12, 512, 9-121, 122, 123, 124, 125, 126 5-12, 512 ,
, , . , .
. . , . ..

ISBN 978-5-7262-0944-9


, 2010


.............................................................................................................4
.....................................................................................................................6
1.

..................................................................................8
1.1. TMS320C4x............................................................8
1.2. TIM SMT302 ..................................................................12
1.3. SMT 320 .......................................................................13

2.

....................16
2.1.
TMS320C4015...........................................................................................16
2.2. ................................................................................ 20
2.3. ..................................................................................... 25
2.4. .....................31
2.5. ....................................................32
2.6.
.....................................................35

3.

............................................................38
3.1. 1.
TMS320C40 ( ) ...................................................... 38
3.1.1. ............................................................38
3.1.2. ................................................................................. 39
3.1.3. 1...................................42
3.2. 2.
............................................................................. 53
3.2.1. ...................53
3.2.2. ...............................................................57
3.2.3. Veclib .......................................................58
3.2.4. 2 ..........................59
3.2.5. 2...................................................63
3.2.6. 2....................................64

............................................................................................. 78
1. :

Veclib ........................................................80
2. .................82


MPP-,
TMS320C40 ( ).
Massively Parallel Processing. .

4- ,

,
. , (
), .
-
()
.. .
.. .

12 2000 .
,
, , [1]. - ,
9 9, , .
, , , 4


2, .
1 (. 3.1) .. .. . . 2.4,
2.5, 2.6. ,
. 3.2.6.
, -
, 2 (. 3.2), .. .


..
SMT 320
TMS320C40.

12 .. . 3.2.6.



( , , , ,

.) , ,
.
.
-
, , ,
.

, , .
, (P.C. Treleaven),
(. .1).
.1

,
,



( )



()

() ().
6



. 80-
(., , [1 4]),
,
- (
Inmos, Transtech, Parsytech .), ( , 3L) MPP-
(massively parallel processing), [1, 2, 4, 5].
, :
16- 32- RISC- ;
- ;
(),
, .
80-
MPP (
),
- .
1011 1015
Mflops. MPP- , ,
,
().
RISC-,
90- , TMS320C40 Texas Instruments,
[1].
MPP-
, , ,
( ),
/.
7

1.
1.1. TMS320C4x
TMS320C40 (. 1.1) Texas Instruments , MPP- (massively parallel processing).
330 Mops 60 Mflops 380 /.

- ().
()
120 / (6 20 / ).

, .
(DMA Coprocessor) CPU .
CPU (240 Mops)
, DMA- 90 Mops -.
CPU TMS320C40
:
/
32- 40-
;
/ 32- 40- ;
32- ;
( );
CPU 32 .
8

. 1.1. TMS320C40

TMS320C40
. TMS320C40
32- : , DMA-. , .
TMS320C40 SRAM (1K x 32-bits )
(). . TMS320C40
128x32-bit -,
, .
() 32 . , -
() .
. , 12 , ,
. , , , , , .
32- 40-
. ,
. 32- . .
[5, 6] TMS320C40
:
P(TMS320C40) RISC = Ip2032,40 [, M(), PDMA, 6Link 20MB/s]
= {p32(), Fp40 (), p32 (*), Fp40 (*), 32Rg32}
M() = {Cashc 128x32, 2SRAM 1Kx32, ROM}
10

TMS320C40 , . 32- . TMS320C40 . 32- . . 1.2


. :
(Local bus) (Global bus) , (), .

. 1.2. TMS320C40:
Comm-ports ; Global bus ;
Local bus ; JTAG ; Interrupt and Control
; Clocks and Resets

,

TMS320C4x.
TIM, , , TMS320C4x,
DRAM, .
TIM- IBM PC ISA PCI
HOST-. 4 TIM.
,
. ,
/ HOST-,
11

. HOST- .
- HOST- ,
. HOST-
, , , ,
HOST- .
1.2. TIM SMT302
, TIM SMT302 (Typical Interchange
Module SMT 320
(Stand Module Transputer)). TIM- . 1.3.

. 1.3. TIM SMT302:


Global Connector ; Primary Connector ;
Secondary Connector ; High Speed Links
( )
12

TIM SMT302 :
TMS320C40 (50 60 M) ;
8 Me EDRAM;
20 /
() 1 ;
;
;
32 ;
JTAG- .
1.3. SMT 320

,
( PCI-)
, HOST, HOST. . 1.4 SMT 320.
SMT302 :
TIM;
PCI HOST-, 3
TIM (root),
10 /;
0 HOST-,
50 /.
TIM 2 5 (. 1.5). .
,
50 . 16 /.
Windows 98 , /
HOST-, - SMT 320.

13

. 1.4. SMT 320

. 1.5. SMT 320

2.

,
,
, .
, .
.
(thread). (thread)
.
.

.
.
2.1.
TMS320C40
()
, .
()
[2].
.
.
, , ,
, . 16

.
,
, .
,
.

( )
( , ).

.
. :
1)
;
2)
.
. :
() ;
.
-, .
,
.
,
17

.
.

,
. .
. . , , . - . - - . -,
.
,
, , . .
1.
(, , .) ,
.
,
, . ,
.
2. ,
, Occam .

() ,
. ,
. .
18

3. ,
(, Ada).
,
. ,
.

, .
: ,
, , .
,

.
, , , .
,
, .
1. ( ) :
SEND < > < - >
WAIT < > FROM < - >,
< > , ; <> - ; <
- > - .
- ,
SEND, -
WAIT. . , , ..
,
SEND/WAIT,
-,
19

WAIT/SEND. , .
2. , , . Ada.
. .

, ()
,
.
.

.
. ,
.
,
. Occam, 3L .
2.2.
: Occam,
, , , Ada . .
.
.

.
20

3L (Lattice Logic Limited) [7], , Occam, .


-3L.

-3L - ,
.
, HOST , (
ROOT) HOST- -
(). .
.

, .

() ,
(, , MS-DOS, )
.
-3L ANSI. -3L ( 3L-) ANSI-C :
31 ;


;
VOID,
, ;
21

.

ANSI-C,
. 3L- : (run-time) (standalone). , (HOST).
,
, .
. ,
/ OS. , main- ,
,
, , .
,
, .

:
/ ,
;
-
;
;
;
;
;
;
;
MS-DOS;
THREAD;
;
;
22

;
;
THREAD;
.
, #include.
3L- main()-.
:
typedef int CHAN;
main(argc,argv,envp,in,inlen,out,outlen)
int argc,inlen,outlen; char * argv [], *
envp []; CHAN * in [], * out [];
argc ; argv
,
main()-; envp NULL; in, out /; inlen, outlen
in out .
main()- , . , , argc = 1,
argv[1] = NULL, ..
.
3L-C ,
.
. 2.3.
CONFIG FCONFIG, .
3L-C Occam.
, 23

-,
. , . ,
.
. , , .
3L-C . , . , .
() . , , .
, main()-,
.
(*).
.
,
. .
, ..
.
,
,
,
. ;
.

. , ,
24

. .
3L-C . server.

exit().
.
,
,
CHAN, (, , ) .
CHAN ( ) / SEMA ( ).
3L


,
, .
2.3.
3L-C , .
,
.
, :
statement = processor statement wire
statement

25

task statement connect statement place


statement bind
statement
. ,
- (processor, wire,
task) , !

.
PROCESSOR
processor statement =
"PROCESSOR", new identifier, { processor attribute };
processor attrlbute = "TYPE",
"=", processor type;
processor type =
"PC";
PROCESSOR
. , ,
, HOST-,
( IBM PC).
host . ,
:
processor host
,
.
TYPE ,
. , ,
IBM PC, :

26

processor host processor


root_processor processor
other_IBM_PC type=PC
host- type=PC,
.
, .
( WIRE) ,
, :
link specifier =
processor identifier, "[",constant,"]";
, 3 ,
extra, t[3].
WIRE
:
wire statement =
"WIRE", new identifier, link specifier, link specifier;
WIRE , . .
, , yellow_wire, 2 proc_one 3 proc_two,
;
wire yellow_wire proc_one[2] proc_two[3]
wire yellow_wire proc_two[3] proc_one[2]

27

TASK
:
task statement =
"TASK", new identifier, {task attribute };
task attribute = "INS", "=",constant I
"OUT","=", constant I "FILE", "=", task file
specifier "OPT", "=", opt area I "URGENT" I
memory area, "=",memory amount;
opt area =
memory area | "CODE";
memory area =
"STACK" I "HEAP" I "STATIC" I "DATA" ;
memory amount = constant I "?"; task file
specifier = identifier f string constant;
TASK ,
, .
, . .
INS. ,
. ,
ins=0.
OUTS. , .
,
outs=0.
FILE. ,
, , .

28

. , ,
.
data
.
128 . , ,
1.6 1.6.
"?".
.
.
single-vector data. ,
static, stack, heap . Stack heap , .
:
task . . . data=50. . .
double-vector ,
stack heap.
, ,
,
. , , .
:
task . . . stack=1k heap=10k
. ,
DATA, stack heap.

29

, DATA = ?. , single-vector .
OPT. , , , ,
.
URGENT. , , thread URGENT (). : not urgent.
CONNECT
CONNECT .
connect statement =
"CONNECT", new identifier, output port specifier,
input port specifier;
output port specifier =
port specifier;
input port specifier =
port specifier;
, 0 server 0 filter :
connect ? serverl[0] filter[0];
connect ? filter[0] server[0]
. ( ) () CONNECT,
WIRE .

PLACE
PLACE ,
. :

30

"PLACE", task identifier, processor identifier;


processor identifier =
identifier;
task Identifier =
identifier;
:
place user_task root
place server host
2.4.
h1, h2, h3, h4. h1 Root-, h2 , h3
, h4 .
. .


command /c c40c h1 h2 h3 h4
command/c c40ctask h1
command/c c40cstask h2
command/c c40cstask h3
command/c c40cstask h4
config h.cfg h.app
tis h.app
h.cfg
!Hardware configuration ! total of 4
processors found processor ROOT
type=TMS320C40 processor P1
type=TMS320C40
31

wire ? P1[5] ROOT[2] processor


P2 type=TMS320C40
wire ? P2[5] P1[2] processor P3
type=TMS320C40
wire ? P3[2] ROOT[5]
wire ? P3[5] P2[2]
! Software configuration
!task h1
!task h2
task h1 ins=2 outs=2
task h2 ins=2 outs=2
task h3 ins=2 outs=2
task h4 ins=2 outs=2
place h1 ROOT
place h2 P1 place
h3 P2 place h4 P3
connect ? h1[0] h2[0]
connect ? h2[0] h1[0]
connect ? h2[1] h3[0]
connect ? h3[0] h2[1]
connect ? h3[1] h4[0]
connect ? h4[0] h3[1]
connect ? h4[1] h1[1]
connect ? h1[1] h4[1]
2.5.
.
TMS320C40, , . 2.1. 32

.
(ROOT) , PCI PC.

PC
. 2.1. 1



- . . , , .
, . , .

tms.exe, (, , , ). , .
. ,
, .
API- Visual C++ 5.0. 33

Windows 95/98/NT.
Linux shell-.
,
.
, .
( ). h.cfg. scanf
infile,
.
scanf, printf . .
.
h1.c, , , h2.c, h3.c, h4.c.
, (ANSI) , .
.

, , .
.
.

/ .
34

:
all < >
.
result.
. .
, result .

. .
, .. printf fprintf(stderr, ).
2.6.


.

()
.
.
,
HOST-.

.
1. ,
. .
, . 35


. . h.cfg. scanf infile,
.
(scanf, printf) . .
.
h1.c, , , h2.c, h3.c, h4.c.
2. (
)
all < >.

. .
3. result.
. result. .
.

.
, .. printf fprintf(stderr, ).
4. , .
. , ,
, .
36

5.
: . ,
.
. ,
, . ,
. , printf , ,
,
. -
, . ,
fprintf(stderr, ), .

37

3. *
3.1. 1.
TMS320C40 ( )
: TMS320C40
/ , ,
TMS320C40.
3.1.1.
1. .
2.
.
. . ROOT infile,
ROOT.
3. .
4.
. .
5. .
6. .
7. .
*


.
38

3.1.2.
, , . :
!Hardware configuration
!
.
! total of 4 processors found
processor ROOT type=TMS320C40
processor P1 type=TMS320C40
wire ? P1[5] ROOT[2]
processor P2 type=TMS320C40
wire ? P2[5] P1[2]
processor P3 type=TMS320C40
wire ? P3[2] ROOT[5]
wire ? P3[5] P2[2]
! Software configuration
! . .
! .
task h1 ins=3 outs=0 data=50k
task h2 ins=0 outs=1 data=50k
task h3 ins=0 outs=1 data=50k
task h4 ins=0 outs=1 data=50k
! .
place h1 ROOT
place h2 P1
place h3 P2
place h4 P3
! .
connect ? h2[0] h1[0]
connect ? h3[0] h1[1]
connect ? h4[0] h1[2]
39


. , .
. :
h1.c
#include <stdio.h> #include <chan.h>
main(argc,argv,envp,in_ports,ins,out_ports,outs)
int argc,ins,outs;
char *argv[], *envp[];
CHAN *in_ports[], *out_ports[];
{
int a,i;
printf("Root begins\n");
for (i=0;i<3;i++){
chan_in_word(&a,in_ports[i]);
printf("a=%d\n",a);
} printf("Root
ends\n"); }
h2.c
#include <stdio.h> #include <chan.h>
main(argc,argv,envp,in_ports,ins,out_ports,outs)
int argc,ins,outs;
char *argv[], *envp[];
CHAN *in_ports[], *out_ports[];
{
int a;
a=2;
chan_out_word(a,out_ports[0]);
}
h3.c
#include <stdio.h>

40

#include <chan.h>
main(argc,argv,envp,in_ports,ins,out_ports,outs)
int argc,ins,outs;
char *argv[], *envp[];
CHAN *in_ports[], *out_ports[];
{
int a;
a=3;
chan_out_word(a,out_ports[0]);
}
h4.c
#include <stdio.h>
#include <chan.h>
main(argc,argv,envp,in_ports,ins,out_ports,outs)
int argc,ins,outs;
char *argv[], *envp[];
CHAN *in_ports[], *out_ports[];
{
int a;
a=4;
chan_out_word(a,out_ports[0]);
}
,
chan.h. .
CHAN . .
: chan_in_word(int *, CHAN *)
; chan_out_word(int, CHAN *)
. , , , . . , 41

in_ports[0] out_ports[0] (f ):
chan_in_word((int *)f, in_ports[0]);
chan_out_word(*(int *)&f, out_ports[0]);
3.1.3. 1
1
1. A B
N N.
2. N, A, B.
3. = A B.
2
1. A B N.
2. N, A, B.
3. C = A B.
3
1. A B
N N.
2. N, A, B.
3. C = A + B.
4
1. B X0 N,
A N N.
2. N, A, B, X0.
3. X = A X + B .

42

5
1. B X0 N,
A N N.
2. N, A, B, X0.
3. .
4. X = A X + B .
6
1. A, B, E .
2. F(X) , [A, B] F(X) = 0 .
3. A, B, E.
4. F(X) = 0 .
7
1. A, B, E .
2. F(X) , [A, B] F(X) = 0 .
3. A, B, E.
4. F(X) = 0
.
8
1. : X , N .
2. N, X.
3. S = X + X 2/2! X 3/3! + + (1)N X (N + 1)/N!.

43

9
1. A, B .
2. F(X) , [A, B].
3. A, B, .
4. F(X)
[A, B] .
10
1. A, B .
2. Y = F(X), Y = (X) , Y = F(X) Y = (X) = 0
[A, B] .
3. A, B, .
4.
Y = F(X), Y = (X).
11
1. : X , A
N + 1.
2. N, A.
3.
A[N] XN + A[N 1] X (N 1) + + A[0].
12
1. Y = exp(X), Y, X
N.
2. N, X, E.
3. Y c , Y
.

44

13
1. N N,
.
2. N, , .
3. = .
14
1. N N.
2. N, .
3. |||| .
15
1. N N.
2. N, .
3. = , .
16
1. N, N N.
2. N, , .
3. = .
17
1. , N.
2. N, , , .
3.

( Ai Bi Ci ) .

i =1

45

18
1. x e.
2. sin x .
3. n , e (e ).
19
1. x e.
2. cos x .
3. n , e (e ).
20
1. x e.
2. ln x
.
3. n , e (e ).
21
1. x e.
2. exp x .
3. n , e (e ).

46

22
1. x e.
2. tg x
.
3. n , e (e ).
23
1. x e.
2. x
.
3. n , e (e ).
24
1. A B
N N.
2. N, A, B.
3. C = A A + B.
25
1. A N N.
2. N, A.
3. ||||.
26
1. A N N.
2. N, A.
3. Aij .
ij

47

27
1. N N.
2. N, .
3. min Aij .
i

28
1. N N.
2. N, .
n 1

3. min ( Aij +1 Aij ) .


i

j =1

29
1. N N.
2. N, .
3.

Aij2 .
ij

30
1. , N N.
2. N, , .

3. Aij min{Bij } .
ij

ij
31
1. , N N.
2. N, , .

3. min ( Aij Bij ) .


i j

48

32
1. , N N.
2. N, , .
3. Cij , Cij = Aij + Bij A2ji B 2ji .
33
1. , N N.
2. N, , .
3. Cij , Aij min{Bii } max{ Aii } + Bij .
i

34
1. , N N.
2. N, , .

3. Cij , Cij = Aij Bij max{ Aij } .


j

35
1. , N N.
2. N, , .
3. F = D*,

Dij = min{ Aij } , Eij = max{Bij } .


i
j

36
1. N N.
2. N, .
3. Cij = Aij min{ Aij } .
ij

49

37
1. , N N.
2. N, , .
3. Cij = Aij !/ Bij ! .
38
1. N N.
2. N, , .
3. Cij = Aij( N i ) / Bij( N j ) .
39
1. N N.
2. N, , .
B

3. Cij = Aij ij / Bij ij .


40

1. N N.
2. N, , .
3. Cij = Aij ! + B ji ! .
41
1. N N.
2. N, , .
B

3. Cij = Aij ji .

50

42
1. n Xi n , X i j .
2. N, Xi (i = 1, , n).
3. Xi.
43
1. n Xi n-
.
2. n, Xi (i = 1, , n).
3. .
44
1. X Y n- .
2. n, X Y.
3. X Y.
45
1. A
N N.
2. N, A.
3. A.
46
1. A N N.
2. N, A.
3. A 0
.

51

47
1. A N N.
2. N, A.
3. A 0
.
48
1. A N N.
2. N, A.
3. A1.
49
1. A N M.
2. N, A, M.
3. A .
50
1. A N N.
2. N, A.
3. A
.

52

3.2. 2.

: TMS320C40, MPP- TMS320C40.
3.2.1.

, [10].
, ( ), , , f (
, ).
f (f = 0) (f = 1) .
, , S p f,
:
1
S
.
f + (1 f ) / p
, 9/10 ,
1/10 - , ,
.
,
, ,
. , , = 4, f = 0.
53


.

()
().
1. ,
,
,
, . [10], ,
:
R(p) = p(s)/p(1),
R ; p(s) , s ( ) , s = 1, 2, , n, n
( ) ; p(1) ,
( ). [10].
, , / ,
.
, ()
(speedup), . [11]:
S(p) = t(1)/t(p),
S ; t(p)
,
( ), = 1, 2, ..., ,
( )
; t(1)
54

, ( ).
2.
,
.
[5]
.
:
t = r1 ( N + n1/2 ) ,

t , (/) N; r (
), Mflops ( ); 1/2 , .. , .
[5], , : r ,
,
.

, 0, ( ), ,
. ,


. , .
55

. 3.1 .

n1/2
. 3.1.

,
n1/2, ..
,
t = 0, r
,
.

, , / !
,
MPP-, ,

. , , -, 56

(
, ) , -,
. , , n1/2.
3.2.2.


(. 3.2 3.5).
Root

TMS1

TMS2

TMS3

HOST
. 3.2. 1.

TMS1
HOST

Root

TMS2

. 3.3. 2.

TMS1
HOST

Root

TMS2
TMS3

. 3.4. 3.
57

TMS1
HOST

Root

TMS3
TMS2

. 3.5. 4. -

3.2.3. Veclib

Sinectonalysis Inc.
- Veclib,
TMS320C40 .
, , :
( , ,
, );
;
(, , ,
, , , ..);
,
, ;
DSP (Digital Signal Processing) (- , );
(-, );
;
, .

:
<dspvec.h>

58

. 2 Veclib
, ,
.
3.2.4. 2
1. , MPP- , CHAN, (, ,
) .
, <chan.h> [3]:
chan_in_word() ;
chan_out_word() ;
chan_in_message() ;
chan_out_message() .
.
. , h1 h2 0-
(out_ports[0]) 0 h2 (in_ports[0]).
2. 1 , . .
:
;
p ;
p ;
.

, 59

. , , ,
- .


!
3. 2
,
, (, ). ,
.
, , , , , , , , .
, Mflops. , .
,
.
, , r, , .

60

0,5

1,5

2,5

3,5

. 3.7.

15000

10000

5000

-4

10

20

30

40

50

60

70

80

-2
0

2
6
4
8
10
,

12

14

. 3.8.

4. ,
,
1 . , . ? , ..
, . ,
,
, 30 .
. 3.6 3.7
, .
,
, , , .
5. . 1 , Veclib.
3.2.5. 2
1.
.
2.
.
3. Root-. .
4. ( ) .
5. .
() .
6. .
7. .
.
63

8. ,
1 2 (. . 3.2.1) .
9. . 7. .
Gnumeric Linux Exel Windows.
10.
,
.
3.2.6. 2
1

:
Xi = (Yi + Xi)/( + 1),
Xi () , i = 0, 1, 2, , n 1; Yi
() , i = 0, 1, 2, , n 1.
n = 100000. . [0, +1]. n
.
2

vlinaveragesf:
Xi = (Yi + Xi)/( + 1),
Xi () , i = 0, 1, 2, , n 1; Yi
() , i = 0, 1, 2, , n 1.
n = 100000. . [0, +1]. n
.
64

3

:
N

M = Xi ,
i =1

Xi () ,
i = 1, 2, , N.
Xi :
,
;
, , .
: !

N = 100000. N
.
:
vprodsf.
4

:
N

i =1

i =1

M = X i / N , D = X i / ( N 1) ,

Xi () ,
i = 1, 2, , N.
Xi :
, , ;
,
.
65

N = 100000. N
.
5
.
: F(x) = x.
: [0, 3].
6
vtrapzf (. . 2).
: F(x) = x.
: [0, 3].
7
.
: F(x) = x.
: [0, 3].
8
vsimpsonf (. . 2).
: F(x) = x.
: [0, 3].

66

9
.
: F(x) = sin(x).
: [0, ].
10
vtrapzf (. . 2).
: F(x) = sin(x).
: [0, ].
11
.
: F(x) = sin(x).
: [0, ].
12
vsimpsonf (. . 2).
: F(x) = sin(x).
: [0, ].
13
.
: F(x) = tan(x).
: [0, 3/8].
67

14
vtrapzf (. . 2).
: F(x) = tan(x).
: [0, 3/8].
15
.
: F(x) = tan(x).
: [0, 3/8].
16
vsimpsonf (. . 2).
: F(x) = tan(x).
: [0, 3/8].
.
() :
y (k ) = b0 x(k ) + b1 x(k 1) + ... + bm x(k m)
a1 y ( k 1) a2 y ( k 2) ... an y (k n) .
x(k) ; y(k)
; ai bj . m n .

, ai = 0 ,
. , .
68

17

:
Yi = ((Xi-k/2+j) aj)/(n + 1),
j; Xi , i = 0, 1, 2, , n; Yi
, i [k/2, (n k/2)]; aj , j = 0, 1,
2, , k.
Xi sin(x)
[0, 2], n = 100000, k = 10.
. n k,
.

18
:
Xi = [0,35875 0,48829 cos(i2/n) + 0,14128 cos(i4/n)
0,01168 cos(i6/n)]Yi,
i [0, n 1], ; Yi , i = 0, 1, 2, , n 1; Xi , i = 0, 1, 2, , n 1. n = 100000. n
.
19

(-) :
y (T ) =

M 1

N 1

j =1

i =0

a j y (T jT ) + bi x(T iT ) ,
69

i , i = 0, 1, 2, , n; yi
, i [k/2, (n k/2)]; aj , j = 0, 1, 2, , k.
a j
bi n = max[ M , N ] ( ), M N {2, 3, 4, 5}.
xi , ,
sin(x) [0, 2].
,
[0,1; 0,1], (.
. 2). , ,
n = 100000.
. n k,
.

20
, BMP. , 256- BMP-
800600 ( ). :
1 a b
fi , j = hk ,l fi 2+ k , j 2+l , i = 0, m 1 , j = 0, n 1 ,
ab k =1 l =1
f / ; m x n
; h ; a, b ,
a = b = 3.
. ,
.
, [10; +10], (. . 2). 70

,
[0; 255].
BMP-

.
21
,
BMP-,
.
, 256-
BMP- 800600 ( ). :
1 a b
fi , j = hk ,l fi 2+ k , j 2+l , i = 0, m 1 , j = 0, n 1 ,
ab k =1 l =1
f / ; m x n
; h ; a, b ,
a = b = 3.
, , ,
, , .

.
,
.
BMP-

.

71

22
BMP- RGB-.
, 256- BMP-
800600 ( ). RGB- .

RGB-
, .
BMP- .
23
BMP- .

, BMP- 800600 (
) . -, RGB- :
Y = X exp(1/),
X ; Y ; -.
[1, 3], .
BMP-
.
:
;
.
72

24
:
F(x) = (X1 + 10X2)2 + 5(X3 X4)2 + (X2 X3)4 + 10(X1 X4)4,
. .
(. . 2).
25
F(x) = sin(x). : [0, ].
. xi
h = 0,001.
.
F(xi) sin(xi) [0, 2],
, [0,2, 0,2],
(. . 2).
.
.

26

. , ,
:
N

T j = X ij Si

j = 1, , M,

i =0

X MxN; S
N; T
M. X S
. 73

M N 1000 15000.
.
mvmulf. . 2.
27
:
C = A B,
A MxK;
B KxN; C
MxN. M, N 5000 15000.
.
28
, vmul3f, :
C = A B,
A MxK;
B KxN; C
MxN. M, N 5000 15000.
.
29
1. A
NxN.
2. N, A.
3. A.
N 1000 15000.
.
74

30
1. A NxN.
2. N, A.
3. A
.
N 1000 15000.
.
31
1. A NxN.
2. N, A.
3. A
.
N 1000 15000.
.
32
1. A NxN.
2. N, A.
3. A-1.
N 1000 15000.
.
33
1. A MxN.
2. A, N, M.
3. A .
N M 1000 15000.
.
75

34
1. A NxN.
2. N, A.
3. A
.
N M 1000 15000.
.
35
1. .
2. i- j- ( ).
36
1. .
2.
( ).
37
1. .
2.
( ).
38
1. .
2. ( ).
76

39
1. .
2. .
35-39.
1. .
2. .
3.
[15, 16].

77

1. .., .. .. -. / . .. [ ]. .:
, 2008. ISBN 978-5-7262-0944-9.
2. .., .. .
.: -, 2002.
3. .. , : . . .: . , 2003.
4. . . .:
, 1981.
5. . /
. .; . . . .: , 1993.

6. Levin V.K. Some questions on Development and Applications


Transputers Systems in the USSR: British-Soviet Symposium on Transputers Systems. Moscow, 26 28/06/90.
7. .., .. : . .
.: , 1991.
8. .., .. :
// . 1991. 4. . 43 50.
9. / .. .. .. .. ,
.. // . . . , ., 2000. . 72 73.
10. ., . . ,
: . . .: , 1986.
78

11. .. // -99. . . . 13 .
. 7. .: , 1999. . 99 100.
12. Parallel . User Guide. Texas Instruments TMS320C40. 3L Ltd.
13. Optimized DSP/Vector Library for TMS320C40/C30/.
Reference Manual. Sinoctonalysis Inc., 1995.
14. Configuration Guide for Sundance SMT320, SMT 320 User
Guide.
15. . . .
.: , 1978.
16. .. . .: , 1968.

79

1
:

Veclib

h1. h1 Root-. :
#include <stdio.h>
#include <chan.h>
#include <string.h>
#include <dspvec.h>
#include <timer.h>
#include <math.h>
/* 1 Veclib */
/* [0.0 ;3.0], - */
main(argc,argv,envp,in_ports,ins,out_ports,outs)
int argc,ins,outs;
char *argv[], *envp[];
CHAN *in_ports[], *out_ports[];
{
int i,ii,t1,t2;
double y[13000],x[13000];
int n;
float eps=0.001,integr,intlast;
double x0=0.0,xk=3.0;
double s,delta,step;
step=-0.50607;
s=-0.045;
s=fabs(s);
step=fabs(step);
80

printf("S= %f step= %f\n",s,step);


printf("Simpson1 begins\n");
t1=timer_now();
for(ii=0;ii<10;ii++)
{
n=500;
intlast=12345.;
do
{
integr=0.0;
n=n*2;
step=(xk-x0)/(n-1);
x[0]=x0;
for(i=1;i<n;i++)
{
x[i]=x[i-1]+step;
y[i]=sin(x[i]);
}
/* vsin2sf(n,y,x,1,1);
*/
vsimpsonsf(n,step,y,x,1,1);
integr=y[n];
delta=intlast-integr;
intlast=integr;
printf("
delta=%f\n",delta);
} while (fabs(delta)>eps);
}
t2=timer_now();
printf("TIME1*10= %d \n",(t2-t1));
printf("integr_summa=%f\n",integr);
}

81

abs

sin

double sin(double x)

int abs(int arg)

()

<math.h>

<stdlib.h>

.2.1

The Parallel Run Time Library Optimized DSP/Vector Library for TMS320C40/C30
, ,
. . , link, .
, , . , , : ,
, . include <.h >. . .2.1 .

cos

tan

exp

fabs

fmod

fprintf

log

log10

timer_n
ow()

10

11

,

,



x/y

int timer_now()

double log10(double x)

double fmod(double x,
double y)

double log(double x)

double fabs(double arg)

double exp(double x)

double tan(double x)

double cos(double x)

()

, .. 1000

<timer.h>

<math.h>

<math.h>

<stdio.h>

<math.h>

<math.h>

<math.h>

<math.h>

<math.h>

1 . .2.1

vsin2sf

vcos2sf

vtan2sf

12

13

14

void vsin2sf(int n, float*x,


float*y, intdx, intdy)

void vsin2sf(int n, float*x,


float*y, intdx, intdy)

void vsin2sf(int n, float*x,


float*y, intdx, intdy)

()
n / ;
x ;
y ;
dx, dy ,
1
n / ;
x ;
y ;
dx, dy ,
1
n / ;
x ;
y ;
dx, dy ,
1

<dspvec.h>
x, y
!

<dspvec.h>
x, y
!

<dspvec.h>
x, y
!

2 . .2.1

vsimpsonf

vtrapzf

vlinaveragesf

16

17

15

vlinaveragesf(n,alpha,x,y,dx,dy)
int n,dx,dy
float *x,*y
float alpha

vtrapzf(n,step,y,x,1,1)
n-int
step,x,y-float

vsimpsonsf(n,step,y,x,1,1)
n-int
step,x,y-float

()
n
;
step ;
y ;
x ;
x y,
= 1
n
;
step ;
y ;
x ;
x y,
= 1
n ;
alpha ;
x ;
y ;
dx x;
dy y

<dspvec.h>

<dspvec.h>

3 . .2.1

rand

srand

vprodsf

vmul3f

mvmulf

19

20

21

22

18

int r,c;
float *m,*t,*s

void vprodsf(n,x.dx)
float vprodsf(n,x.dx)
int n,dx;
float *x
void vmul3f(n, z, x, y)
int n;
float *z;
float *x;
float *y;
void mvmulf(r,c,m,t,s)

void arand(unsigned int seed)

int rand(void)

()

n ;
z ;
x ;

r ;
c ;
m ;
t ;
s

n ;
x ;
dx x



RAND_MAX,
<stdlib.h> 2 31 1
,
seed,

<dspvec.h>

<dspvec.h>

<dspvec.h>

<stdlib.h>

<stdlib.h>

. .2.1

.. , .. , ..


MPP-
-
..

2-,

..
- ..
03.03.2010. 6084 1/16
.. 5,5. .-.. 5,5. 300 .
. 011-1. 94
.
.
115409, , ., 31