|
|
@@ -1,6 +1,6 @@
|
|
|
/* StarPU --- Runtime system for heterogeneous multicore architectures.
|
|
|
*
|
|
|
- * Copyright (C) 2012, 2013, 2015 CNRS
|
|
|
+ * Copyright (C) 2012, 2013, 2015, 2016 CNRS
|
|
|
*
|
|
|
* StarPU is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
@@ -36,7 +36,7 @@ struct starpu_codelet foo_display =
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
int rank, nodes;
|
|
|
- int ret=0;
|
|
|
+ int ret;
|
|
|
int compare=0;
|
|
|
|
|
|
ret = starpu_init(NULL);
|
|
|
@@ -46,59 +46,65 @@ int main(int argc, char **argv)
|
|
|
starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
|
|
|
starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes);
|
|
|
|
|
|
- if (nodes < 2)
|
|
|
+ if (nodes < 2 || (starpu_cpu_worker_get_count() == 0))
|
|
|
{
|
|
|
- fprintf(stderr, "This program needs at least 2 nodes (%d available)\n", nodes);
|
|
|
- ret = 77;
|
|
|
+ if (rank == 0)
|
|
|
+ {
|
|
|
+ if (nodes < 2)
|
|
|
+ fprintf(stderr, "We need at least 2 processes.\n");
|
|
|
+ else
|
|
|
+ fprintf(stderr, "We need at least 1 CPU.\n");
|
|
|
+ }
|
|
|
+ starpu_mpi_shutdown();
|
|
|
+ starpu_shutdown();
|
|
|
+ return 77;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- starpu_data_handle_t handle;
|
|
|
- starpu_data_handle_t handle2;
|
|
|
-
|
|
|
- double real[2] = {4.0, 2.0};
|
|
|
- double imaginary[2] = {7.0, 9.0};
|
|
|
|
|
|
- double real2[2] = {14.0, 12.0};
|
|
|
- double imaginary2[2] = {17.0, 19.0};
|
|
|
+ starpu_data_handle_t handle;
|
|
|
+ starpu_data_handle_t handle2;
|
|
|
|
|
|
- if (rank == 1)
|
|
|
- {
|
|
|
- real[0] = 0.0;
|
|
|
- real[1] = 0.0;
|
|
|
- imaginary[0] = 0.0;
|
|
|
- imaginary[1] = 0.0;
|
|
|
- }
|
|
|
+ double real[2] = {4.0, 2.0};
|
|
|
+ double imaginary[2] = {7.0, 9.0};
|
|
|
|
|
|
- starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
|
|
|
- starpu_complex_data_register(&handle2, -1, real2, imaginary2, 2);
|
|
|
+ double real2[2] = {14.0, 12.0};
|
|
|
+ double imaginary2[2] = {17.0, 19.0};
|
|
|
|
|
|
- if (rank == 0)
|
|
|
- {
|
|
|
- int *compare_ptr = &compare;
|
|
|
+ if (rank == 1)
|
|
|
+ {
|
|
|
+ real[0] = 0.0;
|
|
|
+ real[1] = 0.0;
|
|
|
+ imaginary[0] = 0.0;
|
|
|
+ imaginary[1] = 0.0;
|
|
|
+ }
|
|
|
|
|
|
- starpu_task_insert(&cl_display, STARPU_VALUE, "node0 initial value", strlen("node0 initial value")+1, STARPU_R, handle, 0);
|
|
|
- starpu_mpi_isend_detached(handle, 1, 10, MPI_COMM_WORLD, NULL, NULL);
|
|
|
- starpu_mpi_irecv_detached(handle2, 1, 20, MPI_COMM_WORLD, NULL, NULL);
|
|
|
+ starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
|
|
|
+ starpu_complex_data_register(&handle2, -1, real2, imaginary2, 2);
|
|
|
|
|
|
- starpu_task_insert(&cl_display, STARPU_VALUE, "node0 received value", strlen("node0 received value")+1, STARPU_R, handle2, 0);
|
|
|
- starpu_task_insert(&cl_compare, STARPU_R, handle, STARPU_R, handle2, STARPU_VALUE, &compare_ptr, sizeof(compare_ptr), 0);
|
|
|
- }
|
|
|
- else if (rank == 1)
|
|
|
- {
|
|
|
- starpu_mpi_irecv_detached(handle, 0, 10, MPI_COMM_WORLD, NULL, NULL);
|
|
|
- starpu_task_insert(&cl_display, STARPU_VALUE, "node1 received value", strlen("node1 received value")+1, STARPU_R, handle, 0);
|
|
|
- starpu_mpi_isend_detached(handle, 0, 20, MPI_COMM_WORLD, NULL, NULL);
|
|
|
- }
|
|
|
+ if (rank == 0)
|
|
|
+ {
|
|
|
+ int *compare_ptr = &compare;
|
|
|
|
|
|
- starpu_task_wait_for_all();
|
|
|
+ starpu_task_insert(&cl_display, STARPU_VALUE, "node0 initial value", strlen("node0 initial value")+1, STARPU_R, handle, 0);
|
|
|
+ starpu_mpi_isend_detached(handle, 1, 10, MPI_COMM_WORLD, NULL, NULL);
|
|
|
+ starpu_mpi_irecv_detached(handle2, 1, 20, MPI_COMM_WORLD, NULL, NULL);
|
|
|
|
|
|
- starpu_data_unregister(handle);
|
|
|
- starpu_data_unregister(handle2);
|
|
|
+ starpu_task_insert(&cl_display, STARPU_VALUE, "node0 received value", strlen("node0 received value")+1, STARPU_R, handle2, 0);
|
|
|
+ starpu_task_insert(&cl_compare, STARPU_R, handle, STARPU_R, handle2, STARPU_VALUE, &compare_ptr, sizeof(compare_ptr), 0);
|
|
|
}
|
|
|
+ else if (rank == 1)
|
|
|
+ {
|
|
|
+ starpu_mpi_irecv_detached(handle, 0, 10, MPI_COMM_WORLD, NULL, NULL);
|
|
|
+ starpu_task_insert(&cl_display, STARPU_VALUE, "node1 received value", strlen("node1 received value")+1, STARPU_R, handle, 0);
|
|
|
+ starpu_mpi_isend_detached(handle, 0, 20, MPI_COMM_WORLD, NULL, NULL);
|
|
|
+ }
|
|
|
+
|
|
|
+ starpu_task_wait_for_all();
|
|
|
+
|
|
|
+ starpu_data_unregister(handle);
|
|
|
+ starpu_data_unregister(handle2);
|
|
|
|
|
|
starpu_mpi_shutdown();
|
|
|
starpu_shutdown();
|
|
|
|
|
|
- if (rank == 0) return !compare; else return ret;
|
|
|
+ if (rank == 0) return !compare; else return 0;
|
|
|
}
|