FastSort Manual

Sorting in Parallel
FastSort Manual429834-003
6-17
Parallel Sorting From C Programs
/*-------------------------------------------------------------*/
/* Initialize SORT key definitions array. */
/*-------------------------------------------------------------*/
key_array[0] = 1; /* number of keys */
key_array[1] = 9; /* definition = binary,unsigned,ascending */
key_array[2] = 2; /* key length = 2 bytes */
key_array[3] = 0; /* key offset = 0 bytes */
/*-------------------------------------------------------------*/
/* Initialize structures to start SORTPROG with parallel option*/
/*-------------------------------------------------------------*/
for (i = 0; i <= MAXSUBSORTS; i++)
{
newprocess_parms[i].priority = 0;
newprocess_parms[i].memory = 1;
newprocess_parms[i].system = 2;
newprocess_parms[i].segment_size = 3;
memcpy(&newprocess_parms[i].swap_file[0],&tmp_swap[0],24);
memcpy(&newprocess_parms[i].program_file[0],&tmp_prog[0],24);
}
/*-------------------------------------------------------------*/
/* Set CPU numbers and scratch file names */
/*-------------------------------------------------------------*/
newprocess_parms[0].cpu = 0;
newprocess_parms[1].cpu = 1;
newprocess_parms[2].cpu = 2;
newprocess_parms[3].cpu = 3;
memcpy(&scratch_files[0].filename[0],&tmp_dist_scr[0],24);
memcpy(&scratch_files[1].filename[0],&tmp_scr1[0],24);
memcpy(&scratch_files[2].filename[0],&tmp_scr2[0],24);
memcpy(&scratch_files[3].filename[0],&tmp_scr3[0],24);
memcpy(&infile[0],&tmp_infile[0],24);
memcpy(&outfile[0],&tmp_outfile[0],24);
/*-------------------------------------------------------------*/
/* Set SCRATCH and SCRATCHON volume names. Tell SORTPROG to */
/* use specified volumes for scratch. */
/*-------------------------------------------------------------*/
scratchpool.use_scratch = 0;
scratch_pool.num_scratch_vols = 4;
memcpy(&scratch_pool.scratch_vol_names[0],
&tmp_scr_pool[0],32);
/*-------------------------------------------------------------*/
/* Call SORTBUILDPARM to initialialize SORTPROG control block. */
/*-------------------------------------------------------------*/
error = SORTBUILDPARM (&ctlblk[0]
,
,
,
,
,
,
,
,
,
,
,(short *) &scratch_pool
);
if (error) /* check for SORTBUILDPARM error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
Example 6-1. C Example of a Parallel Sort Run (page 3 of 5)