|
@@ -429,173 +429,7 @@ int _starpu_cpu_driver_run(struct _starpu_worker *worker)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int _starpu_cpu_copy_data_to_opencl(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_OPENCL_RAM);
|
|
|
-
|
|
|
- int ret = 1;
|
|
|
-
|
|
|
-#ifdef STARPU_USE_OPENCL
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
- /* STARPU_CPU_RAM -> STARPU_OPENCL_RAM */
|
|
|
- STARPU_ASSERT(starpu_worker_get_local_memory_node() == dst_node);
|
|
|
- if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_opencl_copy_disabled() || !(copy_methods->ram_to_opencl_async || copy_methods->any_to_any))
|
|
|
- {
|
|
|
- STARPU_ASSERT(copy_methods->ram_to_opencl || copy_methods->any_to_any);
|
|
|
- /* this is not associated to a request so it's synchronous */
|
|
|
- if (copy_methods->ram_to_opencl)
|
|
|
- copy_methods->ram_to_opencl(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, NULL);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- req->async_channel.type = STARPU_OPENCL_RAM;
|
|
|
- if (copy_methods->ram_to_opencl_async)
|
|
|
- ret = copy_methods->ram_to_opencl_async(src_interface, src_node, dst_interface, dst_node, &(req->async_channel.event.opencl_event));
|
|
|
- else
|
|
|
- {
|
|
|
- STARPU_ASSERT(copy_methods->any_to_any);
|
|
|
- ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, &req->async_channel);
|
|
|
- }
|
|
|
- }
|
|
|
-#endif
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_cpu_copy_data_to_cuda(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_CUDA_RAM);
|
|
|
-
|
|
|
- int ret = 1;
|
|
|
-
|
|
|
-#ifdef STARPU_USE_CUDA
|
|
|
- cudaError_t cures;
|
|
|
- cudaStream_t stream;
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
-
|
|
|
- /* STARPU_CPU_RAM -> CUBLAS_RAM */
|
|
|
- /* only the proper CUBLAS thread can initiate this ! */
|
|
|
-#if !defined(STARPU_HAVE_CUDA_MEMCPY_PEER)
|
|
|
- STARPU_ASSERT(starpu_worker_get_local_memory_node() == dst_node);
|
|
|
-#endif
|
|
|
- if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_cuda_copy_disabled() ||
|
|
|
- !(copy_methods->ram_to_cuda_async || copy_methods->any_to_any))
|
|
|
- {
|
|
|
- /* this is not associated to a request so it's synchronous */
|
|
|
- STARPU_ASSERT(copy_methods->ram_to_cuda || copy_methods->any_to_any);
|
|
|
- if (copy_methods->ram_to_cuda)
|
|
|
- copy_methods->ram_to_cuda(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, NULL);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- req->async_channel.type = STARPU_CUDA_RAM;
|
|
|
- cures = cudaEventCreateWithFlags(&req->async_channel.event.cuda_event, cudaEventDisableTiming);
|
|
|
- if (STARPU_UNLIKELY(cures != cudaSuccess))
|
|
|
- STARPU_CUDA_REPORT_ERROR(cures);
|
|
|
-
|
|
|
- stream = starpu_cuda_get_in_transfer_stream(dst_node);
|
|
|
- if (copy_methods->ram_to_cuda_async)
|
|
|
- ret = copy_methods->ram_to_cuda_async(src_interface, src_node, dst_interface, dst_node, stream);
|
|
|
- else
|
|
|
- {
|
|
|
- STARPU_ASSERT(copy_methods->any_to_any);
|
|
|
- ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, &req->async_channel);
|
|
|
- }
|
|
|
-
|
|
|
- cures = cudaEventRecord(req->async_channel.event.cuda_event, stream);
|
|
|
- if (STARPU_UNLIKELY(cures != cudaSuccess))
|
|
|
- STARPU_CUDA_REPORT_ERROR(cures);
|
|
|
- }
|
|
|
-#endif
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_cpu_copy_data_to_mic(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_MIC_RAM);
|
|
|
-
|
|
|
- int ret = 1;
|
|
|
-
|
|
|
-#ifdef STARPU_USE_MIC
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
- /* RAM -> MIC */
|
|
|
- if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_mic_copy_disabled() || !(copy_methods->ram_to_mic_async || copy_methods->any_to_any))
|
|
|
- {
|
|
|
- /* this is not associated to a request so it's synchronous */
|
|
|
- STARPU_ASSERT(copy_methods->ram_to_mic || copy_methods->any_to_any);
|
|
|
- if (copy_methods->ram_to_mic)
|
|
|
- copy_methods->ram_to_mic(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, NULL);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- req->async_channel.type = STARPU_MIC_RAM;
|
|
|
- if (copy_methods->ram_to_mic_async)
|
|
|
- ret = copy_methods->ram_to_mic_async(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- {
|
|
|
- STARPU_ASSERT(copy_methods->any_to_any);
|
|
|
- ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, &req->async_channel);
|
|
|
- }
|
|
|
- _starpu_mic_init_event(&(req->async_channel.event.mic_event), dst_node);
|
|
|
- }
|
|
|
-#endif
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_cpu_copy_data_to_disk(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_DISK_RAM);
|
|
|
-
|
|
|
- int ret = 0;
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
-
|
|
|
- if (req && !starpu_asynchronous_copy_disabled())
|
|
|
- {
|
|
|
- req->async_channel.type = STARPU_DISK_RAM;
|
|
|
- req->async_channel.event.disk_event.requests = NULL;
|
|
|
- req->async_channel.event.disk_event.ptr = NULL;
|
|
|
- req->async_channel.event.disk_event.handle = NULL;
|
|
|
- }
|
|
|
- if(copy_methods->any_to_any)
|
|
|
- ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, req && !starpu_asynchronous_copy_disabled() ? &req->async_channel : NULL);
|
|
|
- else
|
|
|
- {
|
|
|
- void *obj = starpu_data_handle_to_pointer(handle, dst_node);
|
|
|
- void * ptr = NULL;
|
|
|
- starpu_ssize_t size = 0;
|
|
|
- handle->ops->pack_data(handle, src_node, &ptr, &size);
|
|
|
- ret = _starpu_disk_full_write(src_node, dst_node, obj, ptr, size, req && !starpu_asynchronous_copy_disabled() ? &req->async_channel : NULL);
|
|
|
- if (ret == 0)
|
|
|
- {
|
|
|
- /* write is already finished, ptr was allocated in pack_data */
|
|
|
- _starpu_free_flags_on_node(src_node, ptr, size, 0);
|
|
|
- }
|
|
|
- else if (ret == -EAGAIN)
|
|
|
- {
|
|
|
- STARPU_ASSERT(req);
|
|
|
- req->async_channel.event.disk_event.ptr = ptr;
|
|
|
- req->async_channel.event.disk_event.node = src_node;
|
|
|
- req->async_channel.event.disk_event.size = size;
|
|
|
- }
|
|
|
- STARPU_ASSERT(ret == 0 || ret == -EAGAIN);
|
|
|
- }
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_cpu_copy_data_to_cpu(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
+int _starpu_cpu_copy_data(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
{
|
|
|
int src_kind = starpu_node_get_kind(src_node);
|
|
|
int dst_kind = starpu_node_get_kind(dst_node);
|
|
@@ -610,135 +444,22 @@ int _starpu_cpu_copy_data_to_cpu(starpu_data_handle_t handle, void *src_interfac
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-int _starpu_cpu_copy_data_to_mpi_ms(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_MPI_MS_RAM);
|
|
|
-
|
|
|
- int ret = 0;
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
-
|
|
|
- if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_mpi_ms_copy_disabled() || !(copy_methods->ram_to_mpi_ms_async || copy_methods->any_to_any))
|
|
|
- {
|
|
|
- /* this is not associated to a request so it's synchronous */
|
|
|
- STARPU_ASSERT(copy_methods->ram_to_mpi_ms || copy_methods->any_to_any);
|
|
|
- if (copy_methods->ram_to_mpi_ms)
|
|
|
- copy_methods->ram_to_mpi_ms(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, NULL);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- req->async_channel.type = STARPU_MPI_MS_RAM;
|
|
|
- if(copy_methods->ram_to_mpi_ms_async)
|
|
|
- ret = copy_methods->ram_to_mpi_ms_async(src_interface, src_node, dst_interface, dst_node, &req->async_channel);
|
|
|
- else
|
|
|
- {
|
|
|
- STARPU_ASSERT(copy_methods->any_to_any);
|
|
|
- ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, &req->async_channel);
|
|
|
- }
|
|
|
- }
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_cpu_copy_data_to_scc(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
|
|
|
-{
|
|
|
- int src_kind = starpu_node_get_kind(src_node);
|
|
|
- int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_SCC_RAM);
|
|
|
-
|
|
|
- int ret = 0;
|
|
|
- const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
|
|
|
- if (copy_methods->scc_src_to_sink)
|
|
|
- copy_methods->scc_src_to_sink(src_interface, src_node, dst_interface, dst_node);
|
|
|
- else
|
|
|
- copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, NULL);
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
int _starpu_cpu_copy_interface(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, struct _starpu_async_channel *async_channel)
|
|
|
{
|
|
|
int src_kind = starpu_node_get_kind(src_node);
|
|
|
- STARPU_ASSERT(src_kind == STARPU_CPU_RAM);
|
|
|
-
|
|
|
int dst_kind = starpu_node_get_kind(dst_node);
|
|
|
+ STARPU_ASSERT(src_kind == STARPU_CPU_RAM && dst_kind == STARPU_CPU_RAM);
|
|
|
|
|
|
- if (dst_kind == STARPU_CPU_RAM)
|
|
|
- {
|
|
|
- memcpy((void *) (dst + dst_offset), (void *) (src + src_offset), size);
|
|
|
- return 0;
|
|
|
- }
|
|
|
-#ifdef STARPU_USE_CUDA
|
|
|
- else if (dst_kind == STARPU_CUDA_RAM)
|
|
|
- {
|
|
|
- return starpu_cuda_copy_async_sync((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size,
|
|
|
- async_channel?starpu_cuda_get_in_transfer_stream(dst_node):NULL,
|
|
|
- cudaMemcpyHostToDevice);
|
|
|
- }
|
|
|
-#endif
|
|
|
-#ifdef STARPU_USE_OPENCL
|
|
|
- else if (dst_kind == STARPU_OPENCL_RAM)
|
|
|
- {
|
|
|
- return starpu_opencl_copy_async_sync(src, src_offset, src_node,
|
|
|
- dst, dst_offset, dst_node,
|
|
|
- size,
|
|
|
- &async_channel->event.opencl_event);
|
|
|
-
|
|
|
- }
|
|
|
-#endif
|
|
|
-#ifdef STARPU_USE_MIC
|
|
|
- else if (dst_kind == STARPU_MIC_RAM)
|
|
|
- {
|
|
|
- if (async_channel)
|
|
|
- return _starpu_mic_copy_ram_to_mic_async((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size);
|
|
|
- else
|
|
|
- return _starpu_mic_copy_ram_to_mic((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size);
|
|
|
+ (void) async_channel;
|
|
|
|
|
|
- }
|
|
|
-#endif
|
|
|
-#ifdef STARPU_USE_SCC
|
|
|
- else if (dst_kind == STARPU_MIC_RAM)
|
|
|
- {
|
|
|
- return _starpu_scc_copy_src_to_sink((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size);
|
|
|
- }
|
|
|
-#endif
|
|
|
-#ifdef STARPU_USE_MPI_MASTER_SLAVE
|
|
|
- else if (dst_kind == STARPU_MPI_MS_RAM)
|
|
|
- {
|
|
|
- if (async_channel)
|
|
|
- return _starpu_mpi_copy_ram_to_mpi_async((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size, async_channel);
|
|
|
- else
|
|
|
- return _starpu_mpi_copy_ram_to_mpi_sync((void*) (src + src_offset), src_node,
|
|
|
- (void*) (dst + dst_offset), dst_node,
|
|
|
- size);
|
|
|
- }
|
|
|
-#endif
|
|
|
- else if (dst_kind == STARPU_DISK_RAM)
|
|
|
- {
|
|
|
- return _starpu_disk_copy_src_to_disk((void*) (src + src_offset), src_node,
|
|
|
- (void*) dst, dst_offset, dst_node,
|
|
|
- size, async_channel);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- STARPU_ABORT();
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ memcpy((void *) (dst + dst_offset), (void *) (src + src_offset), size);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
int _starpu_cpu_direct_access_supported(unsigned node, unsigned handling_node)
|
|
|
{
|
|
|
+ (void) node;
|
|
|
+ (void) handling_node;
|
|
|
return 1;
|
|
|
}
|
|
|
|