FastSort Manual

Sorting in Parallel
FastSort Manual429834-003
6-24
Parallel Sorting From TAL Programs
!-----------------------------------------------------------!
?PAGE "MAIN Procedure"
!-----------------------------------------------------------!
PROC main^proc MAIN;
BEGIN
INT length;
!-----------------------------------------------------------!
! Open the home terminal and call the !
! INITIALIZER to read the startup message. !
!-----------------------------------------------------------!
CALL MYTERM (home^term^name);
CALL OPEN (home^term^name, home^term^filenum);
IF <> THEN CALL DEBUG;
CALL INITIALIZER;
!-----------------------------------------------------------!
! Initialize the sort key array definitions. !
!-----------------------------------------------------------!
key^array[0] := 1; ! Number of keys
key^array[1] := 9; ! Key descriptor: binary signed, ascending
key^array[2] := 2; ! Key length: 2 bytes
key^array[3] := 0; ! Key offset: 0 bytes
!-----------------------------------------------------------!
! Start SORTPROG process with the parallel option. !
!-----------------------------------------------------------!
USE i;
FOR i := 0 TO max^subsort DO
BEGIN ! Fill default values
newprocess^parms[i].priority := -1;
newprocess^parms[i].memory := -1;
newprocess^parms[i].system := -1;
newprocess^parms[i].segment^size := -1;
newprocess^parms[i].swap^file ’:=' blank^name FOR 12;
newprocess^parms[i].program^file ':=' blank^name FOR 12;
END;
!-----------------------------------------------------------!
! Set CPU numbers and scratch file names. !
!-----------------------------------------------------------!
newprocess^parms[0].cpu := 1;
newprocess^parms[1].cpu := 3;
newprocess^parms[2].cpu := 4;
newprocess^parms[3].cpu := 6;
scratch^files[0].filename ':=' " ";
scratch^files[1].filename ':=' "$DISK01 ";
scratch^files[2].filename ':=' "$DISK01 ";
scratch^files[3].filename ':=' "$DISK01 ";
!-----------------------------------------------------------!
! Call SORTMERGESTART procedure. !
!-----------------------------------------------------------!
error := SORTMERGESTART (ctlblk,
key^array,,1,
in^file,,,,,
out^file,,,
flags,,,
scratch^files[0].filename,,
newprocess^parms[0].priority,,,,,,
max^subsort);
IF error THEN ! Check for SORTMERGESTART error.
BEGIN
length := SORTERRORSUM (ctlblk,
error^buf, error^code,
error^source,
sub^index, sub^cpu^pin);
! Process the SORTMERGESTART error.
END;
Example 6-3. TAL Example of a Parallel Sort Run (page 2 of 3)