summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorSerge Cohen <serge@chocolatnoir.net>2017-01-12 13:59:21 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-01-17 09:39:45 +0100
commit7b51c5c163b84c15e0d226167c888053fa132170 (patch)
tree0a487e4032a43bd5a78b20e841031b1cc0856087 /contrib
parenta82a4551066142cb23ae8179c2bd139d818e9cc8 (diff)
downloadufo-filters-7b51c5c163b84c15e0d226167c888053fa132170.tar.gz
ufo-filters-7b51c5c163b84c15e0d226167c888053fa132170.tar.bz2
ufo-filters-7b51c5c163b84c15e0d226167c888053fa132170.tar.xz
ufo-filters-7b51c5c163b84c15e0d226167c888053fa132170.zip
Fixups and cleanup
* Making sure /contrib/ is used in singular form. * Small correction to avoid some warning during compilation (unused variables, asprintf on Linux, cl_long printf). * Correcting the type of box-size parameter of med-mad-reject-2d. * Correcting bugs in ocl-1liner (generation of 'in_X' input parameters, comma after 'out' parameter)'. * Fixing up the ‘quiet’ property of stat-monitor. * Fixing memory double-release in ocl-1liner. * Fixing semantic of the kernel source code buffer free.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/sxc/src/CMakeLists.txt16
-rw-r--r--contrib/sxc/src/kernels/ocl-1liner-skel.cl7
-rw-r--r--contrib/sxc/src/ufo-med-mad-reject-2d-task.c2
-rw-r--r--contrib/sxc/src/ufo-ocl-1liner-task.c13
-rw-r--r--contrib/sxc/src/ufo-stat-monitor-task.c15
5 files changed, 31 insertions, 22 deletions
diff --git a/contrib/sxc/src/CMakeLists.txt b/contrib/sxc/src/CMakeLists.txt
index 3560b0e..324cfeb 100644
--- a/contrib/sxc/src/CMakeLists.txt
+++ b/contrib/sxc/src/CMakeLists.txt
@@ -18,23 +18,23 @@
## Serge Cohen <serge.cohen@synchrotron-soleil.fr>
##
-set(contribs_sxc_filter_SRCS
+set(contrib_sxc_filter_SRCS
ufo-med-mad-reject-2d-task.c
ufo-med-mad-reject-task.c
ufo-ocl-1liner-task.c
ufo-stat-monitor-task.c
)
-set(contribs_sxc_aux_SRCS
+set(contrib_sxc_aux_SRCS
ufo-sxc-common.c)
-file(GLOB contribs_sxc_filter_KERNELS "kernels/*.cl")
+file(GLOB contrib_sxc_filter_KERNELS "kernels/*.cl")
include(ConfigurePaths)
include(PkgConfigVars)
include(CheckCSourceCompiles)
-configure_paths(CONTRIBS_SXC_FILTERS)
+configure_paths(CONTRIB_SXC_FILTERS)
find_package(OpenCL REQUIRED)
find_package(PkgConfig REQUIRED)
@@ -60,9 +60,9 @@ set(ufofilter_LIBS
${OpenCL_LIBRARIES})
# build static auxiliary library first
-add_library(contribs_sxc_aux STATIC ${contribs_sxc_aux_SRCS})
+add_library(contrib_sxc_aux STATIC ${contrib_sxc_aux_SRCS})
-foreach(_src ${contribs_sxc_filter_SRCS})
+foreach(_src ${contrib_sxc_filter_SRCS})
# find plugin suffix
string(REGEX REPLACE "ufo-([^ \\.]+)-task.*" "\\1" task "${_src}")
@@ -83,7 +83,7 @@ foreach(_src ${contribs_sxc_filter_SRCS})
add_library(${target} SHARED ${_src} ${${_misc}})
endif()
- target_link_libraries(${target} ${ufofilter_LIBS} ${${_aux_libs}} contribs_sxc_aux)
+ target_link_libraries(${target} ${ufofilter_LIBS} ${${_aux_libs}} contrib_sxc_aux)
list(APPEND all_targets ${target})
@@ -94,6 +94,6 @@ endforeach()
# copy kernels
-foreach(_kernel ${contribs_sxc_filter_KERNELS})
+foreach(_kernel ${contrib_sxc_filter_KERNELS})
install(FILES ${_kernel} DESTINATION ${UFO_KERNELDIR})
endforeach()
diff --git a/contrib/sxc/src/kernels/ocl-1liner-skel.cl b/contrib/sxc/src/kernels/ocl-1liner-skel.cl
index 55bfa88..182526e 100644
--- a/contrib/sxc/src/kernels/ocl-1liner-skel.cl
+++ b/contrib/sxc/src/kernels/ocl-1liner-skel.cl
@@ -40,9 +40,10 @@
__kernel void
ocl_1liner (
- %s // The inputs...
- __global float *out,
- )
+// The input(s)
+%s
+// The output
+__global float *out)
{
size_t sizeX = get_global_size(0);
size_t sizeY = get_global_size(1);
diff --git a/contrib/sxc/src/ufo-med-mad-reject-2d-task.c b/contrib/sxc/src/ufo-med-mad-reject-2d-task.c
index 14e7dc0..b893fdc 100644
--- a/contrib/sxc/src/ufo-med-mad-reject-2d-task.c
+++ b/contrib/sxc/src/ufo-med-mad-reject-2d-task.c
@@ -236,7 +236,7 @@ ufo_med_mad_reject_2d_task_class_init (UfoMedMadReject2DTaskClass *klass)
G_PARAM_READWRITE);
properties[PROP_BOX_SIZE] =
- g_param_spec_float ("box-size",
+ g_param_spec_uint ("box-size",
"Size of the box in which the median and mad are computed",
"Should be an odd number so that current pixel is the exact center of the box.",
1, 1023, 3,
diff --git a/contrib/sxc/src/ufo-ocl-1liner-task.c b/contrib/sxc/src/ufo-ocl-1liner-task.c
index e641e56..9e1c5ed 100644
--- a/contrib/sxc/src/ufo-ocl-1liner-task.c
+++ b/contrib/sxc/src/ufo-ocl-1liner-task.c
@@ -18,6 +18,10 @@
*
* Serge Cohen <serge.cohen@synchrotron-soleil.fr>
*/
+// The following define seems necessary on Linux to get stdio.h declare asprintf family of functions.
+// Should be done early enough to be sure that stdio.h is not already included withOUT _GNU_SOURCE on.
+#define _GNU_SOURCE
+#include <stdio.h> // for asprintf at least.
#ifdef __APPLE__
#include <OpenCL/cl.h>
@@ -25,7 +29,6 @@
#include <CL/cl.h>
#endif
-#include <stdio.h> // for asprintf at least.
#include "ufo-ocl-1liner-task.h"
@@ -81,7 +84,7 @@ ufo_ocl_1liner_task_setup (UfoTask *task,
char * skel_in_next = skel_in;
for ( guint i=0; i != priv->num_inputs; ++i ) {
- one_in_size = snprintf(skel_in, 1024 - (skel_in_next - skel_in), "__global float *in_%d,\n", i);
+ one_in_size = snprintf(skel_in_next, 1024 - (skel_in_next - skel_in), "__global float *in_%d,\n", i);
if ( 0 >= one_in_size )
goto exit;
skel_in_next += one_in_size;
@@ -96,12 +99,14 @@ ufo_ocl_1liner_task_setup (UfoTask *task,
kernel_src,
"ocl_1liner",
error);
- /* Done compiling sources into a kernel*/
+ /* Done compiling sources into a kernel, if existing retain it */
+ if (priv->kernel != NULL)
+ UFO_RESOURCES_CHECK_CLERR (clRetainKernel (priv->kernel));
exit:
/* Releasing resources no longer used */
g_free (kernel_skel);
- g_free (kernel_src);
+ free (kernel_src);
}
static void
diff --git a/contrib/sxc/src/ufo-stat-monitor-task.c b/contrib/sxc/src/ufo-stat-monitor-task.c
index 187549e..4ce9b2a 100644
--- a/contrib/sxc/src/ufo-stat-monitor-task.c
+++ b/contrib/sxc/src/ufo-stat-monitor-task.c
@@ -157,7 +157,7 @@ ufo_stat_monitor_task_setup (UfoTask *task,
priv->wg_size = (priv->local_scratch_size) >> 4; // Reducing the number of items in a work-group to fit local memory constraints
}
}
-#warning Still have to check that the values here are properly set.
+ // #warning Still have to check that the values here are properly set.
// In particular taking into account local memory usage per work-item and work-group to optimsed these values.
priv->im_index = 0;
@@ -196,7 +196,7 @@ ufo_stat_monitor_task_setup (UfoTask *task,
fprintf(stdout, " * Will print standard monitor message : %s\n", (priv->be_quiet) ? "no" : "yes");
fprintf(stdout, " * Will output statistics to %s\n", strcmp("-", priv->stat_fn) ? priv->stat_fn : "stdout");
fprintf(stdout, " * OpenCL Device %s fp64/double precision support (cl_khr_fp64)\n", (priv->node_has_fp64) ? "has" : "does not have");
- fprintf(stdout, " * Maximum local memory is %lluB\n", priv->max_local_mem);
+ fprintf(stdout, " * Maximum local memory is %luB\n", priv->max_local_mem);
fprintf(stdout, " * Number of compute units is %d\n", num_cu);
fprintf(stdout, " * Maximum work group size is %zu\n", max_wgs);
fprintf(stdout, " * Maximum work items (in WG) [0] is %zu\n", max_wis[0]);
@@ -325,7 +325,7 @@ ufo_stat_monitor_task_process (UfoTask *task,
// fprintf(stdout, "Reduction 1st stage :num pixels %u, num items %lu, workgroup size %lu\n", img_size, total_wi, wg_size);
ufo_profiler_call (profiler, cmd_queue, priv->kernel, 1, &total_wi, &wg_size);
-#warning Further reduction is required, CPU or GPU ...
+ // #warning Further reduction is required, CPU or GPU ...
// At this time, we need to have a second kernel to further reduce the results of the previous results that where
// produced at the rate of one per work-group.
if ( TRUE ) { // OpenCL version of this last stage of reduction
@@ -423,10 +423,10 @@ ufo_stat_monitor_task_process (UfoTask *task,
}
if (priv->n_items > 0) {
- guint32 *data;
+ // guint32 *data;
gfloat *data_f32;
- data = (guint32 *) ufo_buffer_get_host_array (inputs[0], NULL);
+ // data = (guint32 *) ufo_buffer_get_host_array (inputs[0], NULL);
data_f32 = (gfloat *) ufo_buffer_get_host_array (inputs[0], NULL);
g_print (" ");
@@ -488,6 +488,9 @@ ufo_stat_monitor_task_get_property (GObject *object,
case PROP_STAT_FN:
g_value_set_string (value, priv->stat_fn);
break;
+ case PROP_QUIET:
+ g_value_set_boolean (value, priv->be_quiet);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -554,7 +557,7 @@ ufo_stat_monitor_task_class_init (UfoStatMonitorTaskClass *klass)
g_param_spec_boolean("quiet",
"When turned to true, will not print frame monitoring information on stdout",
"Defaulting to 'false', that is mimicking the 'monitor' filter",
- TRUE,
+ FALSE,
G_PARAM_READWRITE);
properties[PROP_NUM_ITEMS] =
g_param_spec_uint ("print",