16 int compar(
const void *v_lhs,
const void *v_rhs)
18 int row_lhs = ((
int *)v_lhs)[
ROW];
19 int row_rhs = ((
int *)v_rhs)[
ROW];
20 int col_lhs = ((
int *)v_lhs)[
COL];
21 int col_rhs = ((
int *)v_rhs)[
COL];
23 if( row_lhs==row_rhs ) {
24 if( col_lhs==col_rhs )
26 else if( col_lhs<col_rhs )
30 }
else if( row_lhs<row_rhs ) {
37 int main(
int argc,
char **argv)
40 struct stat file_info;
41 char *current, *next, *buffer;
42 int status, i, fd, nbytes;
47 fd = open(
"494_bus_full.mtx", O_RDONLY);
48 assert( fd>=0 &&
"couldn't open matrix" );
49 status = fstat( fd, &file_info );
50 assert( status==0 &&
"couldn't get filesize of matrix" );
51 buffer = malloc(file_info.st_size+1);
52 buffer[file_info.st_size]=(char)0;
55 status =
read(fd, buffer, file_info.st_size-nbytes);
56 assert(status>=0 &&
"Couldn't read from matrix file");
58 }
while( nbytes<file_info.st_size );
63 next = strchr(current,
'\n');
66 for(i=0; i<
NNZ; i++) {
67 next = strchr(current,
'\n');
70 status = sscanf(current,
"%d %d %lf", &coords[i][
ROW], &coords[i][
COL], &data.
val[i]);
71 assert(status==3 &&
"Parse error in matrix file");
79 data.
cols[i] = coords[i][
COL]-1;
93 fd = open(
"input.data", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
94 assert( fd>0 &&
"Couldn't open input data file" );
static uint64_t prng_rand(struct prng_rand_t *state)
void qsort(void *base, size_t nel, size_t width, int(*cmp)(const void *, const void *))
int32_t rowDelimiters[N+1]
void data_to_input(int fd, void *vdata)
int main(int argc, char **argv)
int compar(const void *v_lhs, const void *v_rhs)
static void prng_srand(uint64_t seed, struct prng_rand_t *state)
short int read(short int *data)