|
@@ -123,26 +123,26 @@ _starpu_disk_free(unsigned node, void *obj, size_t size)
|
|
|
|
|
|
/* src_node == disk node and dst_node == STARPU_MAIN_RAM */
|
|
|
int
|
|
|
-_starpu_disk_read(unsigned src_node, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, void *obj, void *buf, off_t offset, size_t size, void * async_channel)
|
|
|
+_starpu_disk_read(unsigned src_node, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, void *obj, void *buf, off_t offset, size_t size, struct _starpu_async_channel * channel)
|
|
|
{
|
|
|
int pos = get_location_with_node(src_node);
|
|
|
- int values = -1;
|
|
|
|
|
|
- if (async_channel != NULL)
|
|
|
+ if (channel != NULL)
|
|
|
{
|
|
|
- struct _starpu_async_channel * channel = (struct _starpu_async_channel *) async_channel;
|
|
|
- channel->type = STARPU_DISK_RAM;
|
|
|
- channel->event.disk_event.memory_node = src_node;
|
|
|
-
|
|
|
- if (disk_register_list[pos]->functions->async_read != NULL)
|
|
|
+ if (disk_register_list[pos]->functions->async_read == NULL)
|
|
|
+ channel = NULL;
|
|
|
+ else
|
|
|
{
|
|
|
+ channel->type = STARPU_DISK_RAM;
|
|
|
+ channel->event.memory_node = src_node;
|
|
|
+
|
|
|
_STARPU_TRACE_START_DRIVER_COPY_ASYNC(src_node, dst_node);
|
|
|
- values = disk_register_list[pos]->functions->async_read(disk_register_list[pos]->base, obj, buf, offset, size, async_channel);
|
|
|
+ channel->event.disk_event = disk_register_list[pos]->functions->async_read(disk_register_list[pos]->base, obj, buf, offset, size);
|
|
|
_STARPU_TRACE_END_DRIVER_COPY_ASYNC(src_node, dst_node);
|
|
|
}
|
|
|
}
|
|
|
/* asynchronous request failed or synchronous request is asked */
|
|
|
- if (async_channel == NULL || values < 0)
|
|
|
+ if (channel == NULL || !channel->event.disk_event)
|
|
|
{
|
|
|
disk_register_list[pos]->functions->read(disk_register_list[pos]->base, obj, buf, offset, size);
|
|
|
return 0;
|
|
@@ -150,40 +150,28 @@ _starpu_disk_read(unsigned src_node, unsigned dst_node STARPU_ATTRIBUTE_UNUSED,
|
|
|
return -EAGAIN;
|
|
|
}
|
|
|
|
|
|
-int _starpu_disk_full_read(unsigned src_node, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, void * obj, void ** ptr, size_t * size)
|
|
|
-{
|
|
|
- int pos = get_location_with_node(src_node);
|
|
|
- return disk_register_list[pos]->functions->full_read(src_node, disk_register_list[pos]->base, obj, ptr, size);
|
|
|
-}
|
|
|
-
|
|
|
-int _starpu_disk_full_write(unsigned src_node STARPU_ATTRIBUTE_UNUSED, unsigned dst_node, void * obj, void * ptr, size_t size)
|
|
|
-{
|
|
|
- int pos = get_location_with_node(dst_node);
|
|
|
- return disk_register_list[pos]->functions->full_write(dst_node, disk_register_list[pos]->base, obj, ptr, size);
|
|
|
-}
|
|
|
-
|
|
|
/* src_node == STARPU_MAIN_RAM and dst_node == disk node */
|
|
|
int
|
|
|
-_starpu_disk_write(unsigned src_node STARPU_ATTRIBUTE_UNUSED, unsigned dst_node, void *obj, void *buf, off_t offset, size_t size, void * async_channel)
|
|
|
+_starpu_disk_write(unsigned src_node STARPU_ATTRIBUTE_UNUSED, unsigned dst_node, void *obj, void *buf, off_t offset, size_t size, struct _starpu_async_channel * channel)
|
|
|
{
|
|
|
int pos = get_location_with_node(dst_node);
|
|
|
- int values = -1;
|
|
|
|
|
|
- if (async_channel != NULL)
|
|
|
+ if (channel != NULL)
|
|
|
{
|
|
|
- struct _starpu_async_channel * channel = (struct _starpu_async_channel *) async_channel;
|
|
|
- channel->type = STARPU_DISK_RAM;
|
|
|
- channel->event.disk_event.memory_node = dst_node;
|
|
|
-
|
|
|
- if (disk_register_list[pos]->functions->async_read != NULL)
|
|
|
+ if (disk_register_list[pos]->functions->async_write == NULL)
|
|
|
+ channel = NULL;
|
|
|
+ else
|
|
|
{
|
|
|
- _STARPU_TRACE_START_DRIVER_COPY_ASYNC(src_node, dst_node);
|
|
|
- values = disk_register_list[pos]->functions->async_write(disk_register_list[pos]->base, obj, buf, offset, size, async_channel);
|
|
|
+ channel->type = STARPU_DISK_RAM;
|
|
|
+ channel->event.memory_node = dst_node;
|
|
|
+
|
|
|
+ _STARPU_TRACE_START_DRIVER_COPY_ASYNC(src_node, dst_node);
|
|
|
+ channel->event.disk_event = disk_register_list[pos]->functions->async_write(disk_register_list[pos]->base, obj, buf, offset, size);
|
|
|
_STARPU_TRACE_END_DRIVER_COPY_ASYNC(src_node, dst_node);
|
|
|
}
|
|
|
}
|
|
|
/* asynchronous request failed or synchronous request is asked */
|
|
|
- if (async_channel == NULL || values < 0)
|
|
|
+ if (channel == NULL || !channel->event.disk_event)
|
|
|
{
|
|
|
disk_register_list[pos]->functions->write(disk_register_list[pos]->base, obj, buf, offset, size);
|
|
|
return 0;
|
|
@@ -193,14 +181,28 @@ _starpu_disk_write(unsigned src_node STARPU_ATTRIBUTE_UNUSED, unsigned dst_node,
|
|
|
}
|
|
|
|
|
|
int
|
|
|
-_starpu_disk_copy(unsigned node_src, void* obj_src, off_t offset_src, unsigned node_dst, void* obj_dst, off_t offset_dst, size_t size, void * async_channel)
|
|
|
+_starpu_disk_copy(unsigned node_src, void* obj_src, off_t offset_src, unsigned node_dst, void* obj_dst, off_t offset_dst, size_t size, struct _starpu_async_channel* channel)
|
|
|
{
|
|
|
int pos_src = get_location_with_node(node_src);
|
|
|
int pos_dst = get_location_with_node(node_dst);
|
|
|
/* both nodes have same copy function */
|
|
|
- return disk_register_list[pos_src]->functions->copy(disk_register_list[pos_src]->base, obj_src, offset_src,
|
|
|
+ channel->event.disk_event = disk_register_list[pos_src]->functions->copy(disk_register_list[pos_src]->base, obj_src, offset_src,
|
|
|
disk_register_list[pos_dst]->base, obj_dst, offset_dst,
|
|
|
- size, async_channel);
|
|
|
+ size);
|
|
|
+ STARPU_ASSERT(channel->event.disk_event);
|
|
|
+ return -EAGAIN;
|
|
|
+}
|
|
|
+
|
|
|
+int _starpu_disk_full_read(unsigned src_node, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, void * obj, void ** ptr, size_t * size)
|
|
|
+{
|
|
|
+ int pos = get_location_with_node(src_node);
|
|
|
+ return disk_register_list[pos]->functions->full_read(src_node, disk_register_list[pos]->base, obj, ptr, size);
|
|
|
+}
|
|
|
+
|
|
|
+int _starpu_disk_full_write(unsigned src_node STARPU_ATTRIBUTE_UNUSED, unsigned dst_node, void * obj, void * ptr, size_t size)
|
|
|
+{
|
|
|
+ int pos = get_location_with_node(dst_node);
|
|
|
+ return disk_register_list[pos]->functions->full_write(dst_node, disk_register_list[pos]->base, obj, ptr, size);
|
|
|
}
|
|
|
|
|
|
void *
|
|
@@ -219,21 +221,23 @@ starpu_disk_close(unsigned node, void *obj, size_t size)
|
|
|
|
|
|
void starpu_disk_wait_request(struct _starpu_async_channel *async_channel)
|
|
|
{
|
|
|
- int position = get_location_with_node(async_channel->event.disk_event.memory_node);
|
|
|
- disk_register_list[position]->functions->wait_request((void *) async_channel);
|
|
|
+ int position = get_location_with_node(async_channel->event.memory_node);
|
|
|
+ disk_register_list[position]->functions->wait_request(async_channel->event.disk_event);
|
|
|
}
|
|
|
|
|
|
int starpu_disk_test_request(struct _starpu_async_channel *async_channel)
|
|
|
{
|
|
|
- int position = get_location_with_node(async_channel->event.disk_event.memory_node);
|
|
|
- if (disk_register_list[position]->functions->test_request != NULL &&
|
|
|
- disk_register_list[position]->functions->async_write != NULL &&
|
|
|
- disk_register_list[position]->functions->async_read != NULL)
|
|
|
- return disk_register_list[position]->functions->test_request((void *) async_channel);
|
|
|
- /* one of these functions is not defined => sync mode*/
|
|
|
- return 1;
|
|
|
+ int position = get_location_with_node(async_channel->event.memory_node);
|
|
|
+ return disk_register_list[position]->functions->test_request(async_channel->event.disk_event);
|
|
|
}
|
|
|
|
|
|
+void starpu_disk_free_request(struct _starpu_async_channel *async_channel)
|
|
|
+{
|
|
|
+ int position = get_location_with_node(async_channel->event.memory_node);
|
|
|
+ if (async_channel->event.disk_event)
|
|
|
+ disk_register_list[position]->functions->free_request(async_channel->event.disk_event);
|
|
|
+}
|
|
|
+
|
|
|
static void
|
|
|
add_disk_in_list(unsigned node, struct starpu_disk_ops * func, void * base)
|
|
|
{
|
|
@@ -271,6 +275,9 @@ add_disk_in_list(unsigned node, struct starpu_disk_ops * func, void * base)
|
|
|
static int
|
|
|
get_location_with_node(unsigned node)
|
|
|
{
|
|
|
+#ifdef STARPU_DEVEL
|
|
|
+#warning optimize with a MAXNODE array
|
|
|
+#endif
|
|
|
int i;
|
|
|
for(i = 0; i <= disk_number; ++i)
|
|
|
if (disk_register_list[i]->node == node)
|