piv.c 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include <ufo/ufo.h>
  2. #include <stdio.h>
  3. #include "piv-scheduler.h"
  4. #include "piv-nodes.h"
  5. #include "piv-ufo-base.h"
  6. int main (void)
  7. {
  8. struct piv_nodes piv;
  9. struct piv_ufo_base piv_base;
  10. #if !(GLIB_CHECK_VERSION (2, 36, 0))
  11. g_type_init ();
  12. #endif
  13. piv_ufo_base_init(&piv_base);
  14. piv_nodes_init(&piv, &piv_base);
  15. if (piv_base.error)
  16. printf("Error %s\n", piv_base.error->message);
  17. /* This file include all the configurations that can be passed to the
  18. * plugins */
  19. /*********************/
  20. /* CONFIGURATION *****/
  21. /*********************/
  22. UfoTaskNode *global_reader;
  23. global_reader = ufo_plugin_manager_get_task (piv_base.manager, "reader",
  24. &piv_base.error);
  25. #include "config.h"
  26. g_object_set (G_OBJECT (piv.ringwriter), "scale", scale, NULL);
  27. g_object_set (G_OBJECT (piv.fft), "dimensions", 2, NULL);
  28. g_object_set (G_OBJECT (piv.ifft), "dimensions", 2, NULL);
  29. g_object_set (G_OBJECT (piv.ringfft), "dimensions", 2, NULL);
  30. g_object_set (G_OBJECT (piv.ringifft), "dimensions", 2, NULL);
  31. /* Give ring scale, when image is reduced by two, then scale should be 2 */
  32. g_object_set (G_OBJECT (piv.dump_ring), "scale", scale, NULL);
  33. /* Does not need user configuration */
  34. unsigned number_of_rings = (ring_end - ring_start) / ring_step + 1;
  35. g_object_set (G_OBJECT (piv.duplicater), "dup_count", number_of_rings,
  36. NULL);
  37. g_object_set (G_OBJECT (piv.concatenate_result), "ring_count", number_of_rings, NULL);
  38. g_object_set (G_OBJECT (piv.loop_ringfft), "loop", 1, NULL);
  39. g_object_set (G_OBJECT (piv.loop_ringfft), "dup_count", number_of_images, NULL);
  40. /*********************/
  41. /* GRAPH SETUP *******/
  42. /*********************/
  43. GList* piv_nodes = NULL;
  44. GList* it = piv_base.gpu_nodes;
  45. if (!it) {
  46. g_print("Main : No GPUs found\n");
  47. return 1;
  48. }
  49. g_print("Main : Connecting nodes %p\n", it->data);
  50. piv_nodes_set_gpu(&piv, it->data);
  51. piv_nodes = g_list_append(piv_nodes, &piv);
  52. piv_ufo_base_connect(&piv_base, &piv, scale, dump_ring_to_image, global_reader);
  53. // Graph expansion for usage of multiple GPUs. Uncomment lines when UFO
  54. // supports calling plug-ins on demand
  55. //for (it = it->next; it; it = it->next) {
  56. // g_print("Main : Connecting nodes %p\n", it->data);
  57. // struct piv_nodes *cpy = piv_nodes_copy(&piv);
  58. // piv_nodes = g_list_append(piv_nodes, cpy);
  59. // piv_nodes_set_gpu(cpy, it->data);
  60. // piv_ufo_base_connect(&piv_base, cpy, scale, dump_ring_to_image, global_reader);
  61. //}
  62. ufo_base_scheduler_run(piv_base.scheduler, piv_base.graph, &piv_base.error);
  63. if (piv_base.error)
  64. g_print("Error %s\n", piv_base.error->message);
  65. /*********************/
  66. /* CLEANUP ***********/
  67. /*********************/
  68. piv_ufo_base_unref(&piv_base);
  69. for (it = piv_nodes; it; it = it->next)
  70. piv_nodes_unref(it->data);
  71. g_object_unref (global_reader);
  72. return 0;
  73. }