Browse Source

Add memory states events

Lucas Leandro Nesi 6 years ago
parent
commit
f068631017

+ 1 - 0
AUTHORS

@@ -30,6 +30,7 @@ Benjamin Lorendeau <benjamin.lorendeau@inria.fr>
 Antoine Lucas <antoine.lucas.33@gmail.com>
 Brice Mortier <brice.mortier@etu.u-bordeaux1.fr>
 Stojce Nakov <stojce.nakov@inria.fr>
+Lucas Leandro Nesi <llnesi@inf.ufrgs.br>
 Joris Pablo <joris.pablo@orange.fr>
 Damien Pasqualinotto <dam.pasqualinotto@wanadoo.fr>
 Samuel Pitoiset <samuel.pitoiset@inria.fr>

+ 1 - 1
configure.ac

@@ -2150,7 +2150,7 @@ if test x$use_fxt = xyes; then
 		AC_DEFINE(STARPU_HAVE_POTI, [1], [Define to 1 if you have libpoti and it is meant to be used])
 		save_LIBS="$LIBS"
 		LIBS="$LIBS $POTI_LIBS"
-		AC_CHECK_FUNCS([poti_init_custom])
+		AC_CHECK_FUNCS([poti_init_custom poti_user_NewEvent])
 		LIBS="$save_LIBS"
 		FXT_CFLAGS="$FXT_CFLAGS $POTI_CFLAGS"
 		FXT_LIBS="$FXT_LIBS $POTI_LIBS"

+ 105 - 5
src/debug/traces/starpu_fxt.c

@@ -463,6 +463,7 @@ LIST_TYPE(_starpu_communication,
 	unsigned src_node;
 	unsigned dst_node;
 	const char *type;
+	unsigned long handle;
 	struct _starpu_communication *peer;
 )
 
@@ -755,6 +756,35 @@ static void memnode_pop_state(double time, const char *prefix, unsigned int memn
 #endif
 }
 
+static void memnode_event(double time, const char *prefix, unsigned int memnodeid, const char *name, unsigned long handle, unsigned long info, unsigned long size, unsigned int dest, struct starpu_fxt_options *options)
+{
+	if (!options->memory_states)
+		return;
+#ifdef STARPU_HAVE_POTI
+	char container[STARPU_POTI_STR_LEN];
+	char p_handle[STARPU_POTI_STR_LEN];
+	memmanager_container_alias(container, STARPU_POTI_STR_LEN, prefix, memnodeid);
+	snprintf(p_handle, sizeof(p_handle), "%lx", handle);
+
+#ifdef HAVE_POTI_USER_NEWEVENT
+	char p_dest[STARPU_POTI_STR_LEN];
+	char p_info[STARPU_POTI_STR_LEN];
+	char p_size[STARPU_POTI_STR_LEN];
+
+	memmanager_container_alias(p_dest, STARPU_POTI_STR_LEN, prefix, dest);
+	snprintf(p_info, sizeof(p_info), "%lu", info);
+	snprintf(p_size, sizeof(p_size), "%lu", size);
+
+	poti_user_NewEvent(_starpu_poti_MemoryEvent, time, container, name, "0", 4,
+			   p_handle, p_info, p_size, p_dest);
+#else
+	poti_NewEvent(time, container, name, p_handle);
+#endif
+#else
+	fprintf(out_paje_file, "22    %.9f    %s %smm%u  0 %lx %lu %lu %smm%u\n", time, name, prefix, memnodeid, handle, info, size, prefix, dest);
+#endif
+}
+
 static void worker_set_state(double time, const char *prefix, long unsigned int workerid, const char *name)
 {
 	if (fut_keymask == FUT_KEYMASK0)
@@ -2212,6 +2242,7 @@ static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 	unsigned size = ev->param[2];
 	unsigned comid = ev->param[3];
 	unsigned prefetch = ev->param[4];
+	unsigned long handle = ev->param[5];
 	const char *link_type = copy_link_type(prefetch);
 
 	char *prefix = options->file_prefix;
@@ -2222,6 +2253,7 @@ static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 		{
 			double time = get_event_time_stamp(ev, options);
 			memnode_push_state(time, prefix, dst, "Co");
+			memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCo", handle, comid, size, src, options);
 #ifdef STARPU_HAVE_POTI
 			char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_memnode_container[STARPU_POTI_STR_LEN];
 			char program_container[STARPU_POTI_STR_LEN];
@@ -2244,6 +2276,7 @@ static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 		com->dst_node = dst;
 		com->type = link_type;
 		com->peer = NULL;
+		com->handle = handle;
 
 		_starpu_communication_list_push_back(&communication_list, com);
 	}
@@ -2285,8 +2318,9 @@ static void handle_work_stealing(struct fxt_ev_64 *ev, struct starpu_fxt_options
 static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
 	int src = -1;
+	unsigned long handle = 0;
 	unsigned dst = ev->param[1];
-	unsigned size = ev->param[2];
+	unsigned long size = ev->param[2];
 	unsigned comid = ev->param[3];
 	unsigned prefetch = ev->param[4];
 	const char *link_type = copy_link_type(prefetch);
@@ -2320,6 +2354,7 @@ static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 				com->dst_node = itor->dst_node;
 				com->type = itor->type;
 				link_type = itor->type;
+				handle = itor->handle;
 				com->peer = itor;
 				itor->peer = com;
 
@@ -2333,17 +2368,17 @@ static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 		{
 			double time = get_event_time_stamp(ev, options);
 			memnode_pop_state(time, prefix, dst);
-			(void) src;
+			memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoE", handle, comid, size, src, options);
 #ifdef STARPU_HAVE_POTI
 			char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
 			char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
-			snprintf(paje_value, sizeof(paje_value), "%u", size);
+			snprintf(paje_value, sizeof(paje_value), "%lu", size);
 			snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
 			program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
 			memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
 			poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
 #else
-			fprintf(out_paje_file, "19	%.9f	%s	%sp	%u	%smm%u	com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
+			fprintf(out_paje_file, "19	%.9f	%s	%sp	%lu	%smm%u	com_%u\n", time, link_type, prefix, size, prefix, dst, comid);
 #endif
 		}
 	}
@@ -2351,25 +2386,33 @@ static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 
 static void handle_start_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
+	unsigned src = ev->param[0];
 	unsigned dst = ev->param[1];
 
 	char *prefix = options->file_prefix;
 
 	if (!options->no_bus)
 		if (out_paje_file)
+		{
 			memnode_push_state(get_event_time_stamp(ev, options), prefix, dst, "CoA");
+			memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoA", 0, 0, 0, src, options);
+		}
 
 }
 
 static void handle_end_driver_copy_async(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
+	unsigned src = ev->param[0];
 	unsigned dst = ev->param[1];
 
 	char *prefix = options->file_prefix;
 
 	if (!options->no_bus)
 		if (out_paje_file)
+		{
 			memnode_pop_state(get_event_time_stamp(ev, options), prefix, dst);
+			memnode_event(get_event_time_stamp(ev, options), options->file_prefix, dst, "DCoAE", 0, 0, 0, src, options);
+		}
 }
 
 /* Currently unused */
@@ -2382,6 +2425,36 @@ static void handle_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options
 		memnode_set_state(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr);
 }
 
+static void handle_memnode_event_start_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr){
+	unsigned memnode = ev->param[0];
+	unsigned size = ev->param[1];
+	unsigned long handle = ev->param[2];
+
+	memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, size, memnode, options);
+}
+
+static void handle_memnode_event_end_3(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr){
+	unsigned memnode = ev->param[0];
+	unsigned long handle = ev->param[1];
+	unsigned info = ev->param[2];
+
+	memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, info, 0, memnode, options);
+}
+
+static void handle_memnode_event_start_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr){
+	unsigned memnode = ev->param[0];
+	unsigned long handle = ev->param[1];
+
+	memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
+}
+
+static void handle_memnode_event_end_2(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr){
+	unsigned memnode = ev->param[0];
+	unsigned long handle = ev->param[1];
+
+	memnode_event(get_event_time_stamp(ev, options), options->file_prefix, memnode, eventstr, handle, 0, 0, memnode, options);
+}
+
 static void handle_push_memnode_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *options, const char *eventstr)
 {
 	unsigned memnode = ev->param[0];
@@ -3581,32 +3654,59 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 
 			case _STARPU_FUT_START_ALLOC:
 				if (!options->no_bus)
+				{
 					handle_push_memnode_event(&ev, options, "A");
+					handle_memnode_event_start_3(&ev, options, "Al");
+				}
 				break;
 			case _STARPU_FUT_START_ALLOC_REUSE:
 				if (!options->no_bus)
+				{
 					handle_push_memnode_event(&ev, options, "Ar");
+					handle_memnode_event_start_3(&ev, options, "Alr");
+				}
 				break;
 			case _STARPU_FUT_END_ALLOC:
+				if (!options->no_bus)
+				{
+					handle_pop_memnode_event(&ev, options);
+					handle_memnode_event_end_3(&ev, options, "AlE");
+				}
+				break;
 			case _STARPU_FUT_END_ALLOC_REUSE:
 				if (!options->no_bus)
+				{
 					handle_pop_memnode_event(&ev, options);
+					handle_memnode_event_end_3(&ev, options, "AlrE");
+				}
 				break;
 			case _STARPU_FUT_START_FREE:
 				if (!options->no_bus)
+				{
 					handle_push_memnode_event(&ev, options, "F");
+					handle_memnode_event_start_3(&ev, options, "Fe");
+				}
 				break;
 			case _STARPU_FUT_END_FREE:
 				if (!options->no_bus)
+				{
 					handle_pop_memnode_event(&ev, options);
+					handle_memnode_event_end_2(&ev, options, "FeE");
+				}
 				break;
 			case _STARPU_FUT_START_WRITEBACK:
 				if (!options->no_bus)
+				{
 					handle_push_memnode_event(&ev, options, "W");
+					handle_memnode_event_start_2(&ev, options, "Wb");
+				}
 				break;
 			case _STARPU_FUT_END_WRITEBACK:
 				if (!options->no_bus)
+				{
 					handle_pop_memnode_event(&ev, options);
+					handle_memnode_event_start_2(&ev, options, "WbE");
+				}
 				break;
 			case _STARPU_FUT_START_WRITEBACK_ASYNC:
 				if (!options->no_bus)
@@ -4137,7 +4237,7 @@ void _starpu_fxt_paje_file_init(struct starpu_fxt_options *options)
 		poti_init (out_paje_file);
 #endif
 #endif
-		_starpu_fxt_write_paje_header(out_paje_file);
+		_starpu_fxt_write_paje_header(out_paje_file, options);
 	}
 	else
 	{

+ 3 - 2
src/debug/traces/starpu_fxt.h

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2011-2012                                Inria
  * Copyright (C) 2012,2017,2018                           CNRS
- * Copyright (C) 2009-2012,2014-2017                      Université de Bordeaux
+ * Copyright (C) 2009-2012,2014-2018                      Université de Bordeaux
  *
  * 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
@@ -62,10 +62,11 @@ void _starpu_fxt_mpi_add_send_transfer(int src, int dst, int mpi_tag, size_t siz
 void _starpu_fxt_mpi_add_recv_transfer(int src, int dst, int mpi_tag, float date, long jobid);
 void _starpu_fxt_display_mpi_transfers(struct starpu_fxt_options *options, int *ranks, FILE *out_paje_file);
 
-void _starpu_fxt_write_paje_header(FILE *file);
+void _starpu_fxt_write_paje_header(FILE *file, struct starpu_fxt_options *options);
 
 extern int _starpu_poti_extendedSetState;
 extern int _starpu_poti_semiExtendedSetState;
+extern int _starpu_poti_MemoryEvent;
 
 /*
  * Animation

+ 55 - 3
src/debug/traces/starpu_paje.c

@@ -29,10 +29,11 @@
 #ifdef HAVE_POTI_INIT_CUSTOM
 int _starpu_poti_extendedSetState = -1;
 int _starpu_poti_semiExtendedSetState = -1;
+int _starpu_poti_MemoryEvent = -1;
 #endif
 #endif
 
-void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED)
+void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED, struct starpu_fxt_options *options)
 {
 	unsigned i;
 #ifdef STARPU_HAVE_POTI
@@ -61,6 +62,17 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED)
 						     "JobId string",
 						     "SubmitOrder string"
 						     );
+#ifdef HAVE_POTI_USER_NEWEVENT
+	if (options->memory_states)
+	{
+		_starpu_poti_MemoryEvent = poti_header_DeclareEvent (PAJE_NewEvent,
+							     4,
+							     "Handle string",
+							     "Info string",
+							     "Size string",
+							     "Dest string");
+	}
+#endif
 #else
 	poti_header(1,1);
 #endif
@@ -197,6 +209,19 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED)
 	fprintf(file, "%%	JobId	string\n");
 	fprintf(file, "%%	SubmitOrder	string\n");
 	fprintf(file, "%%EndEventDef\n");
+	if (options->memory_states)
+	{
+		fprintf(file, "%%EventDef	PajeNewEvent	22\n");
+		fprintf(file, "%%	Time	date\n");
+		fprintf(file, "%%	Type	string\n");
+		fprintf(file, "%%	Container	string\n");
+		fprintf(file, "%%	Value	string\n");
+		fprintf(file, "%%	Handle	string\n");
+		fprintf(file, "%%	Info	string\n");
+		fprintf(file, "%%	Size	string\n");
+		fprintf(file, "%%	Tid	string\n");
+		fprintf(file, "%%EndEventDef\n");
+	}
 #endif
 
 #ifdef STARPU_HAVE_POTI
@@ -216,8 +241,20 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED)
 	/* Types for the memory node */
 	poti_DefineEventType("SI", "Mm", "data state invalid");
 	poti_DefineEventType("SS", "Mm", "data state shared");
-	poti_DefineEventType("SS", "Mm", "data state owner");
+	poti_DefineEventType("SO", "Mm", "data state owner");
 	poti_DefineEventType("WU", "Mm", "data wont use");
+	poti_DefineEventType("Al", "Mm", "Allocating Start");
+	poti_DefineEventType("AlE", "Mm", "Allocating End");
+	poti_DefineEventType("Alr", "Mm", "Allocating Async Start");
+	poti_DefineEventType("AlrE", "Mm", "Allocating Async End");
+	poti_DefineEventType("Fe", "Mm", "Free Start");
+	poti_DefineEventType("FeE", "Mm", "Free End");
+	poti_DefineEventType("Wb", "Mm", "WritingBack Start");
+	poti_DefineEventType("WbE", "Mm", "WritingBack End");
+	poti_DefineEventType("DCo", "Mm", "DriverCopy Start");
+	poti_DefineEventType("DCoE", "Mm", "DriverCopy End");
+	poti_DefineEventType("DCoA", "Mm", "DriverCopyAsync Start");
+	poti_DefineEventType("DCoAE", "Mm", "DriverCopyAsync End");
 	poti_DefineVariableType("use", "Mm", "Used (MB)", "0 0 0");
 	poti_DefineVariableType("bwi_mm", "Mm", "Bandwidth In (MB/s)", "0 0 0");
 	poti_DefineVariableType("bwo_mm", "Mm", "Bandwidth Out (MB/s)", "0 0 0");
@@ -370,7 +407,22 @@ void _starpu_fxt_write_paje_header(FILE *file STARPU_ATTRIBUTE_UNUSED)
 	for (i=1; i<STARPU_NMAX_SCHED_CTXS; i++)
 		fprintf(file, "3       Ctx%u      W     \"InCtx%u\"         		\n", i, i);
 	fprintf(file, "\
-2       invalidate Mm \"data invalidation\"                            \n\
+2       SI       Mm \"data state invalid\"                            \n\
+2       SS       Mm \"data state shared\"                            \n\
+2       SO       Mm \"data state owner\"                            \n\
+2       WU       Mm \"data wont use\"                            \n\
+2       Al       Mm    \"Allocating Start\"    \n\
+2       AlE      Mm    \"Allocating End\"    \n\
+2       Alr      Mm    \"Allocating Async Start\"    \n\
+2       AlrE     Mm    \"Allocating Async End\"    \n\
+2       Fe       Mm    \"Free Start\"    \n\
+2       FeE      Mm    \"Free End\"    \n\
+2       Wb       Mm    \"WritingBack Start\"    \n\
+2       WbE      Mm    \"WritingBack End\"    \n\
+2       DCo      Mm    \"DriverCopy Start\"    \n\
+2       DCoE     Mm    \"DriverCopy End\"    \n\
+2       DCoA     Mm    \"DriverCopyAsync Start\"    \n\
+2       DCoAE    Mm    \"DriverCopyAsync End\"    \n\
 3       MS       Mm       \"Memory Node State\"                        \n\
 4       nsubmitted    Sc       \"Number of Submitted Uncompleted Tasks\"                        \n\
 4       nready    Sc       \"Number of Ready Tasks\"                        \n\

+ 2 - 2
tests/datawizard/locality.sh

@@ -3,7 +3,7 @@
 #
 # Copyright (C) 2017                                     CNRS
 # Copyright (C) 2017                                     Inria
-# Copyright (C) 2017                                     Université de Bordeaux
+# Copyright (C) 2017-2018                                     Université de Bordeaux
 #
 # 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
@@ -30,7 +30,7 @@ fi
 
 test -x $PREFIX/../../tools/starpu_fxt_tool || exit 77
 STARPU_SCHED=modular-eager STARPU_FXT_PREFIX=$PREFIX/ $PREFIX/locality
-$PREFIX/../../tools/starpu_fxt_tool -i $PREFIX/prof_file_${USER}_0
+$PREFIX/../../tools/starpu_fxt_tool -memory-states -label-deps -i $PREFIX/prof_file_${USER}_0
 
 # Check that they are approved by Grenoble :)
 

+ 2 - 2
tests/overlap/overlap.sh

@@ -2,7 +2,7 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
 # Copyright (C) 2017                                     CNRS
-# Copyright (C) 2017                                     Université de Bordeaux
+# Copyright (C) 2017-2018                                     Université de Bordeaux
 # Copyright (C) 2017                                     Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
@@ -38,7 +38,7 @@ then
 	[ -f starpu_overlap_sleep_1024_24.gp -a -f starpu_overlap_sleep_1024_24.data -a -f starpu_overlap_sleep_1024_24_avg.data ]
 
 	# Generate paje, dag, data, etc.
-	$PREFIX/../../tools/starpu_fxt_tool -i $PREFIX/prof_file_${USER}_0
+	$PREFIX/../../tools/starpu_fxt_tool -memory-states -label-deps -i $PREFIX/prof_file_${USER}_0
 
 	$PREFIX/../../tools/starpu_paje_sort paje.trace