* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
@ 2012-06-25 23:42 Alexandre Montplaisir
2012-06-26 6:03 ` Mathieu Desnoyers
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Montplaisir @ 2012-06-25 23:42 UTC (permalink / raw)
Signed-off-by: Alexandre Montplaisir <alexmonthy at voxpopuli.im>
---
.gitignore | 1 +
configure.ac | 1 +
tests/Makefile.am | 2 +-
tests/hello-mt/Makefile.am | 13 +++++
tests/hello-mt/Makefile.example.bsd | 8 +++
tests/hello-mt/Makefile.example.linux | 8 +++
tests/hello-mt/README | 11 ++++
tests/hello-mt/hello.c | 103 +++++++++++++++++++++++++++++++++
tests/hello-mt/tp.c | 18 ++++++
tests/hello-mt/ust_tests_hello.h | 67 +++++++++++++++++++++
10 files changed, 231 insertions(+), 1 deletion(-)
create mode 100644 tests/hello-mt/Makefile.am
create mode 100644 tests/hello-mt/Makefile.example.bsd
create mode 100644 tests/hello-mt/Makefile.example.linux
create mode 100644 tests/hello-mt/README
create mode 100644 tests/hello-mt/hello.c
create mode 100644 tests/hello-mt/tp.c
create mode 100644 tests/hello-mt/ust_tests_hello.h
diff --git a/.gitignore b/.gitignore
index 076cd00..c9b45f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@ tests/exit-fast/exit-fast
tests/fork/fork
tests/fork/fork2
tests/hello/hello
+tests/hello-mt/hello
tests/hello.cxx/hello
tests/hello2/hello2
tests/libustctl_function_tests/libustctl_function_tests
diff --git a/configure.ac b/configure.ac
index 294d457..0a50ed0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -305,6 +305,7 @@ AC_CONFIG_FILES([
tools/Makefile
tests/Makefile
tests/hello/Makefile
+ tests/hello-mt/Makefile
tests/hello-static-lib/Makefile
tests/hello.cxx/Makefile
tests/demo/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e79ab7c..443b407 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = . hello hello-static-lib fork ust-basic-tracing ust-multi-test demo hello.cxx
+SUBDIRS = . hello hello-mt hello-static-lib fork ust-basic-tracing ust-multi-test demo hello.cxx
#SUBDIRS = . hello2 basic basic_long simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests exit-fast
dist_noinst_SCRIPTS = test_loop runtests trace_matches
diff --git a/tests/hello-mt/Makefile.am b/tests/hello-mt/Makefile.am
new file mode 100644
index 0000000..4b7e16d
--- /dev/null
+++ b/tests/hello-mt/Makefile.am
@@ -0,0 +1,13 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
+AM_CFLAGS = -fopenmp
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
diff --git a/tests/hello-mt/Makefile.example.bsd b/tests/hello-mt/Makefile.example.bsd
new file mode 100644
index 0000000..a71f478
--- /dev/null
+++ b/tests/hello-mt/Makefile.example.bsd
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+ ${CC} -O2 -I. -o hello -lc -llttng-ust -fopenmp hello.c tp.c
+
+.PHONY: clean
+clean:
+ rm -f hello
diff --git a/tests/hello-mt/Makefile.example.linux b/tests/hello-mt/Makefile.example.linux
new file mode 100644
index 0000000..bc5e58f
--- /dev/null
+++ b/tests/hello-mt/Makefile.example.linux
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+ ${CC} -O2 -I. -Wall -o hello hello.c tp.c -ldl -llttng-ust -fopenmp
+
+.PHONY: clean
+clean:
+ rm -f hello
diff --git a/tests/hello-mt/README b/tests/hello-mt/README
new file mode 100644
index 0000000..0584dca
--- /dev/null
+++ b/tests/hello-mt/README
@@ -0,0 +1,11 @@
+This is a multi-threaded version of the "hello" test program. It uses OpenMP for
+parallelization, and as such requires at least GCC 4.2.
+
+You can pass one integer as argument when running the program, this will
+indicate how many threads to use. For example
+
+./hello 10
+
+will run the test with 10 threads. If no argument is passed, the default of
+1 thread is used, in which case the behaviour should be similar to the original
+"hello" program.
diff --git a/tests/hello-mt/hello.c b/tests/hello-mt/hello.c
new file mode 100644
index 0000000..2ff9869
--- /dev/null
+++ b/tests/hello-mt/hello.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
+ * Copyright (C) 2012 Alexandre Montplaisir <alexmonthy at voxpopuli.im>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <omp.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+#define NB_ITERATIONS 1000000
+
+void inthandler(int sig)
+{
+ printf("in SIGUSR1 handler\n");
+ tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+int init_int_handler(void)
+{
+ int result;
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ result = sigemptyset(&act.sa_mask);
+ if (result == -1) {
+ perror("sigemptyset");
+ return -1;
+ }
+
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
+
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGUSR1, &act, NULL);
+ if (result == -1) {
+ perror("sigaction");
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int nb_threads = 1;
+ bool mybool = 123; /* should print "1" */
+
+ init_int_handler();
+
+ if (argc == 2) {
+ nb_threads = atoi(argv[1]);
+ }
+
+ fprintf(stderr, "Running %d iterations with %d threads... ",
+ NB_ITERATIONS, nb_threads);
+
+ #pragma omp parallel private(i, netint) num_threads(nb_threads)
+ {
+ for (i = 0; i < NB_ITERATIONS; i++) {
+ netint = htonl(i);
+ tracepoint(ust_tests_hello, tptest, i, netint, values,
+ text, strlen(text), dbl, flt, mybool);
+ //usleep(100000);
+ }
+ }
+ fprintf(stderr, " done.\n");
+ return 0;
+}
diff --git a/tests/hello-mt/tp.c b/tests/hello-mt/tp.c
new file mode 100644
index 0000000..1806b42
--- /dev/null
+++ b/tests/hello-mt/tp.c
@@ -0,0 +1,18 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/hello-mt/ust_tests_hello.h b/tests/hello-mt/ust_tests_hello.h
new file mode 100644
index 0000000..b06dea0
--- /dev/null
+++ b/tests/hello-mt/ust_tests_hello.h
@@ -0,0 +1,67 @@
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg,
+ bool, boolarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text,
+ size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text,
+ size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ ctf_integer(bool, boolfield, boolarg)
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_tests_hello.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
--
1.7.10.4
^ permalink raw reply [flat|nested] 6+ messages in thread* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
2012-06-25 23:42 [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program Alexandre Montplaisir
@ 2012-06-26 6:03 ` Mathieu Desnoyers
2012-06-26 7:11 ` Alexandre Montplaisir
0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Desnoyers @ 2012-06-26 6:03 UTC (permalink / raw)
* Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> Signed-off-by: Alexandre Montplaisir <alexmonthy at voxpopuli.im>
> ---
> .gitignore | 1 +
> configure.ac | 1 +
> tests/Makefile.am | 2 +-
> tests/hello-mt/Makefile.am | 13 +++++
> tests/hello-mt/Makefile.example.bsd | 8 +++
> tests/hello-mt/Makefile.example.linux | 8 +++
> tests/hello-mt/README | 11 ++++
> tests/hello-mt/hello.c | 103 +++++++++++++++++++++++++++++++++
> tests/hello-mt/tp.c | 18 ++++++
> tests/hello-mt/ust_tests_hello.h | 67 +++++++++++++++++++++
> 10 files changed, 231 insertions(+), 1 deletion(-)
> create mode 100644 tests/hello-mt/Makefile.am
> create mode 100644 tests/hello-mt/Makefile.example.bsd
> create mode 100644 tests/hello-mt/Makefile.example.linux
> create mode 100644 tests/hello-mt/README
> create mode 100644 tests/hello-mt/hello.c
> create mode 100644 tests/hello-mt/tp.c
> create mode 100644 tests/hello-mt/ust_tests_hello.h
>
> diff --git a/.gitignore b/.gitignore
> index 076cd00..c9b45f1 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -39,6 +39,7 @@ tests/exit-fast/exit-fast
> tests/fork/fork
> tests/fork/fork2
> tests/hello/hello
> +tests/hello-mt/hello
> tests/hello.cxx/hello
> tests/hello2/hello2
> tests/libustctl_function_tests/libustctl_function_tests
> diff --git a/configure.ac b/configure.ac
> index 294d457..0a50ed0 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -305,6 +305,7 @@ AC_CONFIG_FILES([
> tools/Makefile
> tests/Makefile
> tests/hello/Makefile
> + tests/hello-mt/Makefile
> tests/hello-static-lib/Makefile
> tests/hello.cxx/Makefile
> tests/demo/Makefile
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index e79ab7c..443b407 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -1,4 +1,4 @@
> -SUBDIRS = . hello hello-static-lib fork ust-basic-tracing ust-multi-test demo hello.cxx
> +SUBDIRS = . hello hello-mt hello-static-lib fork ust-basic-tracing ust-multi-test demo hello.cxx
> #SUBDIRS = . hello2 basic basic_long simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests exit-fast
>
> dist_noinst_SCRIPTS = test_loop runtests trace_matches
> diff --git a/tests/hello-mt/Makefile.am b/tests/hello-mt/Makefile.am
> new file mode 100644
> index 0000000..4b7e16d
> --- /dev/null
> +++ b/tests/hello-mt/Makefile.am
> @@ -0,0 +1,13 @@
> +AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
> +AM_CFLAGS = -fopenmp
> +
> +noinst_PROGRAMS = hello
> +hello_SOURCES = hello.c tp.c ust_tests_hello.h
> +hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
> +
> +if LTTNG_UST_BUILD_WITH_LIBDL
> +hello_LDADD += -ldl
> +endif
> +if LTTNG_UST_BUILD_WITH_LIBC_DL
> +hello_LDADD += -lc
> +endif
> diff --git a/tests/hello-mt/Makefile.example.bsd b/tests/hello-mt/Makefile.example.bsd
> new file mode 100644
> index 0000000..a71f478
> --- /dev/null
> +++ b/tests/hello-mt/Makefile.example.bsd
> @@ -0,0 +1,8 @@
> +# Example makefile for build outside of the LTTng-UST tree.
> +
> +hello:
> + ${CC} -O2 -I. -o hello -lc -llttng-ust -fopenmp hello.c tp.c
> +
> +.PHONY: clean
> +clean:
> + rm -f hello
> diff --git a/tests/hello-mt/Makefile.example.linux b/tests/hello-mt/Makefile.example.linux
> new file mode 100644
> index 0000000..bc5e58f
> --- /dev/null
> +++ b/tests/hello-mt/Makefile.example.linux
> @@ -0,0 +1,8 @@
> +# Example makefile for build outside of the LTTng-UST tree.
> +
> +hello:
> + ${CC} -O2 -I. -Wall -o hello hello.c tp.c -ldl -llttng-ust -fopenmp
> +
> +.PHONY: clean
> +clean:
> + rm -f hello
> diff --git a/tests/hello-mt/README b/tests/hello-mt/README
> new file mode 100644
> index 0000000..0584dca
> --- /dev/null
> +++ b/tests/hello-mt/README
> @@ -0,0 +1,11 @@
> +This is a multi-threaded version of the "hello" test program. It uses OpenMP for
> +parallelization, and as such requires at least GCC 4.2.
Hrm. This adds a dependency on gcc 4.2. The entire project will fail to
build because of this test on other compiler, older gcc, right ? We
should have a configure.ac check that tests openmp availability. So I
won't merge this for now.
Thanks,
Mathieu
> +
> +You can pass one integer as argument when running the program, this will
> +indicate how many threads to use. For example
> +
> +./hello 10
> +
> +will run the test with 10 threads. If no argument is passed, the default of
> +1 thread is used, in which case the behaviour should be similar to the original
> +"hello" program.
> diff --git a/tests/hello-mt/hello.c b/tests/hello-mt/hello.c
> new file mode 100644
> index 0000000..2ff9869
> --- /dev/null
> +++ b/tests/hello-mt/hello.c
> @@ -0,0 +1,103 @@
> +/*
> + * Copyright (C) 2009 Pierre-Marc Fournier
> + * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> + * Copyright (C) 2012 Alexandre Montplaisir <alexmonthy at voxpopuli.im>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; version 2.1 of
> + * the License.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <sys/mman.h>
> +#include <stdarg.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <arpa/inet.h>
> +#include <stdlib.h>
> +#include <stdbool.h>
> +#include <omp.h>
> +
> +#define TRACEPOINT_DEFINE
> +#include "ust_tests_hello.h"
> +
> +#define NB_ITERATIONS 1000000
> +
> +void inthandler(int sig)
> +{
> + printf("in SIGUSR1 handler\n");
> + tracepoint(ust_tests_hello, tptest_sighandler);
> +}
> +
> +int init_int_handler(void)
> +{
> + int result;
> + struct sigaction act;
> +
> + memset(&act, 0, sizeof(act));
> + result = sigemptyset(&act.sa_mask);
> + if (result == -1) {
> + perror("sigemptyset");
> + return -1;
> + }
> +
> + act.sa_handler = inthandler;
> + act.sa_flags = SA_RESTART;
> +
> + /* Only defer ourselves. Also, try to restart interrupted
> + * syscalls to disturb the traced program as little as possible.
> + */
> + result = sigaction(SIGUSR1, &act, NULL);
> + if (result == -1) {
> + perror("sigaction");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> + int i, netint;
> + long values[] = { 1, 2, 3 };
> + char text[10] = "test";
> + double dbl = 2.0;
> + float flt = 2222.0;
> + int nb_threads = 1;
> + bool mybool = 123; /* should print "1" */
> +
> + init_int_handler();
> +
> + if (argc == 2) {
> + nb_threads = atoi(argv[1]);
> + }
> +
> + fprintf(stderr, "Running %d iterations with %d threads... ",
> + NB_ITERATIONS, nb_threads);
> +
> + #pragma omp parallel private(i, netint) num_threads(nb_threads)
> + {
> + for (i = 0; i < NB_ITERATIONS; i++) {
> + netint = htonl(i);
> + tracepoint(ust_tests_hello, tptest, i, netint, values,
> + text, strlen(text), dbl, flt, mybool);
> + //usleep(100000);
> + }
> + }
> + fprintf(stderr, " done.\n");
> + return 0;
> +}
> diff --git a/tests/hello-mt/tp.c b/tests/hello-mt/tp.c
> new file mode 100644
> index 0000000..1806b42
> --- /dev/null
> +++ b/tests/hello-mt/tp.c
> @@ -0,0 +1,18 @@
> +/*
> + * tp.c
> + *
> + * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + */
> +
> +#define TRACEPOINT_CREATE_PROBES
> +#include "ust_tests_hello.h"
> diff --git a/tests/hello-mt/ust_tests_hello.h b/tests/hello-mt/ust_tests_hello.h
> new file mode 100644
> index 0000000..b06dea0
> --- /dev/null
> +++ b/tests/hello-mt/ust_tests_hello.h
> @@ -0,0 +1,67 @@
> +#undef TRACEPOINT_PROVIDER
> +#define TRACEPOINT_PROVIDER ust_tests_hello
> +
> +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
> +#define _TRACEPOINT_UST_TESTS_HELLO_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/*
> + * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + */
> +
> +#include <lttng/tracepoint.h>
> +#include <stdbool.h>
> +
> +TRACEPOINT_EVENT(ust_tests_hello, tptest,
> + TP_ARGS(int, anint, int, netint, long *, values,
> + char *, text, size_t, textlen,
> + double, doublearg, float, floatarg,
> + bool, boolarg),
> + TP_FIELDS(
> + ctf_integer(int, intfield, anint)
> + ctf_integer_hex(int, intfield2, anint)
> + ctf_integer(long, longfield, anint)
> + ctf_integer_network(int, netintfield, netint)
> + ctf_integer_network_hex(int, netintfieldhex, netint)
> + ctf_array(long, arrfield1, values, 3)
> + ctf_array_text(char, arrfield2, text, 10)
> + ctf_sequence(char, seqfield1, text,
> + size_t, textlen)
> + ctf_sequence_text(char, seqfield2, text,
> + size_t, textlen)
> + ctf_string(stringfield, text)
> + ctf_float(float, floatfield, floatarg)
> + ctf_float(double, doublefield, doublearg)
> + ctf_integer(bool, boolfield, boolarg)
> + )
> +)
> +
> +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
> + TP_ARGS(),
> + TP_FIELDS()
> +)
> +
> +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
> +
> +#undef TRACEPOINT_INCLUDE_FILE
> +#define TRACEPOINT_INCLUDE_FILE ./ust_tests_hello.h
> +
> +/* This part must be outside ifdef protection */
> +#include <lttng/tracepoint-event.h>
> +
> +#ifdef __cplusplus
> +}
> +#endif
> --
> 1.7.10.4
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
2012-06-26 6:03 ` Mathieu Desnoyers
@ 2012-06-26 7:11 ` Alexandre Montplaisir
2012-06-26 12:02 ` Mathieu Desnoyers
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Montplaisir @ 2012-06-26 7:11 UTC (permalink / raw)
On 12-06-26 02:03 AM, Mathieu Desnoyers wrote:
> * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
>> [...]
>> diff --git a/tests/hello-mt/README b/tests/hello-mt/README
>> new file mode 100644
>> index 0000000..0584dca
>> --- /dev/null
>> +++ b/tests/hello-mt/README
>> @@ -0,0 +1,11 @@
>> +This is a multi-threaded version of the "hello" test program. It uses OpenMP for
>> +parallelization, and as such requires at least GCC 4.2.
> Hrm. This adds a dependency on gcc 4.2. The entire project will fail to
> build because of this test on other compiler, older gcc, right ? We
> should have a configure.ac check that tests openmp availability. So I
> won't merge this for now.
Staying up late, aren't we? ;)
Oh ok, I thought we said the other day that GCC 4.2 was old enough to
not be worth testing for. In any case, here's a patch to check for
OpenMP at configure time (goes on top of the previous one).
Two caveats however:
- Since the main part of the project doesn't use OpenMP, I don't think
we want to turn the "-fopenmp" CFLAG on for the whole thing. So I just
hard-coded "-fopenmp" for this test only. I don't know if any other
compiler uses some other flag to turn on the OpenMP support, but we only
support GCC anyway, don't we?
- The autoconf macro requires Autoconf 2.62. Current Debian stable has
2.67, I don't know if it's a big problem.
Good night,
Alex
>
> Thanks,
>
> Mathieu
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Only-build-the-hello-mt-test-if-OpenMP-is-available.patch
Type: text/x-patch
Size: 2182 bytes
Desc: not available
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20120626/73ad3f29/attachment.bin>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
2012-06-26 7:11 ` Alexandre Montplaisir
@ 2012-06-26 12:02 ` Mathieu Desnoyers
2012-06-26 13:45 ` Brosseau, Yannick
0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Desnoyers @ 2012-06-26 12:02 UTC (permalink / raw)
* Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> On 12-06-26 02:03 AM, Mathieu Desnoyers wrote:
> > * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> >> [...]
> >> diff --git a/tests/hello-mt/README b/tests/hello-mt/README
> >> new file mode 100644
> >> index 0000000..0584dca
> >> --- /dev/null
> >> +++ b/tests/hello-mt/README
> >> @@ -0,0 +1,11 @@
> >> +This is a multi-threaded version of the "hello" test program. It uses OpenMP for
> >> +parallelization, and as such requires at least GCC 4.2.
> > Hrm. This adds a dependency on gcc 4.2. The entire project will fail to
> > build because of this test on other compiler, older gcc, right ? We
> > should have a configure.ac check that tests openmp availability. So I
> > won't merge this for now.
>
> Staying up late, aren't we? ;)
Nah, I'm in Sweden at the moment, I was doing my morning email catchup
;)
>
> Oh ok, I thought we said the other day that GCC 4.2 was old enough to
> not be worth testing for. In any case, here's a patch to check for
> OpenMP at configure time (goes on top of the previous one).
>
> Two caveats however:
> - Since the main part of the project doesn't use OpenMP, I don't think
> we want to turn the "-fopenmp" CFLAG on for the whole thing. So I just
> hard-coded "-fopenmp" for this test only. I don't know if any other
> compiler uses some other flag to turn on the OpenMP support, but we only
> support GCC anyway, don't we?
Specific to the hello-mt directory makes sense. gcc-specific makes sense
too I guess, since we detect its availability with autoconf.
>
> - The autoconf macro requires Autoconf 2.62. Current Debian stable has
> 2.67, I don't know if it's a big problem.
Can you respin this patch after looking at:
https://bugs.launchpad.net/inkscape/+bug/984836
they check if the AC_OPENMP macro is available, and mark openmp as
unavailable if it is not. This would allow us to still only depend on
autotools 2.50.
Thanks,
Mathieu
>
>
> Good night,
> Alex
>
> >
> > Thanks,
> >
> > Mathieu
> >
> >
>
> From 496a74a33dc47b61c37b14e0fb0ad5bdeacaf03b Mon Sep 17 00:00:00 2001
> From: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
> Date: Tue, 26 Jun 2012 02:56:19 -0400
> Subject: [UST PATCH] Only build the hello-mt test if OpenMP is available
>
> Since this test is the only part in the whole tree that uses
> OpenMP, we'll simply set the CFLAG manually for this test
> rather than using it project-wide.
>
> Signed-off-by: Alexandre Montplaisir <alexmonthy at voxpopuli.im>
> ---
> README | 2 +-
> configure.ac | 10 ++++++++++
> tests/hello-mt/Makefile.am | 4 ++++
> 3 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/README b/README
> index 52aebd8..b9df1e6 100644
> --- a/README
> +++ b/README
> @@ -30,7 +30,7 @@ This source tree is based on the autotools suite from GNU to simplify
> portability. Here are some things you should have on your system in order to
> compile the git repository tree :
>
> -- GNU autotools (automake >=1.10, autoconf >=2.50, autoheader >=2.50)
> +- GNU autotools (automake >=1.10, autoconf >=2.62, autoheader >=2.62)
> (make sure your system wide "automake" points to a recent version!)
> - GNU Libtool >=2.2
> (for more information, go to http://www.gnu.org/software/autoconf/)
> diff --git a/configure.ac b/configure.ac
> index 0a50ed0..1924d0b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -271,6 +271,16 @@ AS_IF([test "x$with_sdt" = "xyes"],[
> ])
> ])
>
> +#Check for OpenMP, if available we will build the test that uses it
> +AC_OPENMP()
> +AS_IF([ test "x$ac_cv_prog_c_openmp" != "xunsupported" && test "x$ac_cv_prog_c_openmp" != "x"],[
> + openmp_available=yes
> +],[
> + openmp_available=no
> +])
> +AM_CONDITIONAL([BUILD_OPENMP_TEST], [test "x$openmp_available" = "xyes"])
> +
> +
> #currently disabled.
> #tests/hello2/Makefile
> #tests/basic/Makefile
> diff --git a/tests/hello-mt/Makefile.am b/tests/hello-mt/Makefile.am
> index 4b7e16d..98ecc6f 100644
> --- a/tests/hello-mt/Makefile.am
> +++ b/tests/hello-mt/Makefile.am
> @@ -1,3 +1,5 @@
> +if BUILD_OPENMP_TEST
> +
> AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
> AM_CFLAGS = -fopenmp
>
> @@ -11,3 +13,5 @@ endif
> if LTTNG_UST_BUILD_WITH_LIBC_DL
> hello_LDADD += -lc
> endif
> +
> +endif
> --
> 1.7.10.4
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
2012-06-26 12:02 ` Mathieu Desnoyers
@ 2012-06-26 13:45 ` Brosseau, Yannick
2012-06-26 13:52 ` Mathieu Desnoyers
0 siblings, 1 reply; 6+ messages in thread
From: Brosseau, Yannick @ 2012-06-26 13:45 UTC (permalink / raw)
On Tue, Jun 26, 2012 at 8:02 AM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
>> On 12-06-26 02:03 AM, Mathieu Desnoyers wrote:
>> > * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
>> >> [...]
>> >> diff --git a/tests/hello-mt/README b/tests/hello-mt/README
>> >> new file mode 100644
>> >> index 0000000..0584dca
>> >> --- /dev/null
>> >> +++ b/tests/hello-mt/README
I was wondering if naming the directement hello-openmp would be more
appropriate? (The test is kinda specific tot he use of openmp)
Yannick
^ permalink raw reply [flat|nested] 6+ messages in thread
* [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program
2012-06-26 13:45 ` Brosseau, Yannick
@ 2012-06-26 13:52 ` Mathieu Desnoyers
0 siblings, 0 replies; 6+ messages in thread
From: Mathieu Desnoyers @ 2012-06-26 13:52 UTC (permalink / raw)
* Brosseau, Yannick (yannick.brosseau at gmail.com) wrote:
> On Tue, Jun 26, 2012 at 8:02 AM, Mathieu Desnoyers
> <mathieu.desnoyers at efficios.com> wrote:
> > * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> >> On 12-06-26 02:03 AM, Mathieu Desnoyers wrote:
> >> > * Alexandre Montplaisir (alexmonthy at voxpopuli.im) wrote:
> >> >> [...]
> >> >> diff --git a/tests/hello-mt/README b/tests/hello-mt/README
> >> >> new file mode 100644
> >> >> index 0000000..0584dca
> >> >> --- /dev/null
> >> >> +++ b/tests/hello-mt/README
>
> I was wondering if naming the directement hello-openmp would be more
> appropriate? (The test is kinda specific tot he use of openmp)
good point, makes sense !
Alexandre, can you respin your hello-mp patch and change it to
hello-openmp ?
Thanks,
Mathieu
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-06-26 13:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25 23:42 [lttng-dev] [UST PATCH] Add a multi-thread version of the 'hello' test program Alexandre Montplaisir
2012-06-26 6:03 ` Mathieu Desnoyers
2012-06-26 7:11 ` Alexandre Montplaisir
2012-06-26 12:02 ` Mathieu Desnoyers
2012-06-26 13:45 ` Brosseau, Yannick
2012-06-26 13:52 ` Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox