mm_to_bcsr.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010,2011,2015,2017 CNRS
  4. * Copyright (C) 2008,2009,2011,2018 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <string.h>
  18. #include <stdint.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include "mmio.h"
  22. /* convert a matrix stored in a file with the matrix market format into the
  23. * BCSR format */
  24. typedef struct tmp_block
  25. {
  26. /* we have a linked list of blocks */
  27. struct tmp_block *next;
  28. /* column i, row j*/
  29. unsigned i, j;
  30. float *val;
  31. } tmp_block_t;
  32. typedef struct
  33. {
  34. unsigned r,c;
  35. unsigned nnz_blocks;
  36. unsigned nrows_blocks;
  37. float *val;
  38. uint32_t *colind;
  39. uint32_t *rowptr;
  40. } bcsr_t;
  41. /* directly read input from a file */
  42. bcsr_t *mm_file_to_bcsr(char *filename, unsigned c, unsigned r);
  43. /* read the matrix as a set of valuated coordinates */
  44. bcsr_t *mm_to_bcsr(unsigned nz, unsigned *I_, unsigned *J, float *val, unsigned c, unsigned r);