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;
50 fd = open(
"494_bus_full.mtx", O_RDONLY);
51 assert( fd>=0 &&
"couldn't open matrix" );
52 status = fstat( fd, &file_info );
53 assert( status==0 &&
"couldn't get filesize of matrix" );
54 buffer = malloc(file_info.st_size+1);
55 buffer[file_info.st_size]=(char)0;
58 status =
read(fd, buffer, file_info.st_size-nbytes);
59 assert(status>=0 &&
"Couldn't read from matrix file");
61 }
while( nbytes<file_info.st_size );
66 next = strchr(current,
'\n');
69 for(i=0; i<
NNZ; i++) {
70 next = strchr(current,
'\n');
73 status = sscanf(current,
"%d %d %lf", &coords[i][
ROW], &coords[i][
COL], &vals[i]);
74 assert(status==3 &&
"Parse error in matrix file");
81 memset(row_fill, 0,
N*
sizeof(
int));
82 memset(data.
cols, 0,
N*
L*
sizeof(
int));
84 for(i=0; i<
NNZ; i++) {
85 row = coords[
i][
ROW]-1;
86 index =
L*row + row_fill[
row];
98 fd = open(
"input.data", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
99 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 *))
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)