FastSort Manual

Sorting in Parallel
FastSort Manual429834-003
6-18
Parallel Sorting From C Programs
/*-------------------------------------------------------------*/
/* Call SORTMERGESTART to start the SORTPROG processes. */
/*-------------------------------------------------------------*/
error = SORTMERGESTART
(&ctlblk[0],
&key_array[0],,1,
(short *) &infile[0],,,,,
(short *) &outfile[0],,,
flags,,,
(short *) &scratch_files[0].filename[0],,
(short *) &newprocess_parms[0].priority,,,,,,
MAXSUBSORTS);
if (error) /* check for SORTMERGESTART error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0],
&sub_index,&sub_cpu_pin);
error_handler;
return EXIT_FAILURE;
}
/*-------------------------------------------------------------*/
/* Return SORTPROG completion errlen and statistics. Set */
/* length in words, to return all statistics information. */
/*-------------------------------------------------------------*/
actuallen = sizeof(sortstats)/2;
error = SORTMERGESTATISTICS (&ctlblk[0], &actuallen,
(short *) &sortstats,sflag1);
if (error) /* check for SORTMERGESTATISTICS error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
/*-------------------------------------------------------------*/
/* Call function to display the statistics */
/*-------------------------------------------------------------*/
error = DisplaySortStatistics (&sortstats);
if (error)
return EXIT_FAILURE;
/*-------------------------------------------------------------*/
/* CALL SORTMERGEFINISH to stop SORTPROG after the process */
/* successfully completes the current sort and merge run(s). */
/*-------------------------------------------------------------*/
error = SORTMERGEFINISH (&ctlblk[0]);
if (error) /* check for SORTMERGEFINISH error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
FILE_CLOSE_ (home_term_filenum);
} /* End of Main logic */
Example 6-1. C Example of a Parallel Sort Run (page 4 of 5)