disk_unistd.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013 Corentin Salingue
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <fcntl.h>
  17. #include <unistd.h>
  18. #include <stdlib.h>
  19. #include <sys/stat.h>
  20. #include <sys/time.h>
  21. #include <stdint.h>
  22. #include <starpu.h>
  23. #include <core/disk.h>
  24. #include <core/perfmodel/perfmodel.h>
  25. #include <core/disk_ops/unistd/disk_unistd_global.h>
  26. /* ------------------- use UNISTD to write on disk ------------------- */
  27. /* allocation memory on disk */
  28. static void *
  29. starpu_unistd_alloc (void *base, size_t size)
  30. {
  31. struct starpu_unistd_global_obj * obj = malloc(sizeof(struct starpu_unistd_global_obj));
  32. STARPU_ASSERT(obj != NULL);
  33. /* only flags change between unistd and unistd_o_direct */
  34. obj->flags = O_RDWR;
  35. return starpu_unistd_global_alloc (obj, base, size);
  36. }
  37. /* open an existing memory on disk */
  38. static void *
  39. starpu_unistd_open (void *base, void *pos, size_t size)
  40. {
  41. struct starpu_unistd_global_obj * obj = malloc(sizeof(struct starpu_unistd_global_obj));
  42. STARPU_ASSERT(obj != NULL);
  43. /* only flags change between unistd and unistd_o_direct */
  44. obj->flags = O_RDWR;
  45. return starpu_unistd_global_open (obj, base, pos, size);
  46. }
  47. struct starpu_disk_ops starpu_disk_unistd_ops = {
  48. .alloc = starpu_unistd_alloc,
  49. .free = starpu_unistd_global_free,
  50. .open = starpu_unistd_open,
  51. .close = starpu_unistd_global_close,
  52. .read = starpu_unistd_global_read,
  53. .write = starpu_unistd_global_write,
  54. .plug = starpu_unistd_global_plug,
  55. .unplug = starpu_unistd_global_unplug,
  56. .copy = NULL,
  57. .bandwidth = get_unistd_global_bandwidth_between_disk_and_main_ram
  58. };