[Piglit] [PATCH 1/2] cl: make use of subtest for clGetKernelArgInfo

2016-11-27 Thread Serge Martin
also fix wording and remove a comment
---
 tests/cl/api/get-kernel-arg-info.c | 49 ++
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/tests/cl/api/get-kernel-arg-info.c 
b/tests/cl/api/get-kernel-arg-info.c
index 7b34724..7b336e4 100644
--- a/tests/cl/api/get-kernel-arg-info.c
+++ b/tests/cl/api/get-kernel-arg-info.c
@@ -53,6 +53,12 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
+static void
+set_failure(enum piglit_result *result, const char* sub_name)
+{
+   piglit_merge_result(result, PIGLIT_FAIL);
+   piglit_report_subtest_result(PIGLIT_FAIL, "%s", sub_name);
+}
 
 enum piglit_result
 piglit_cl_test(const int argc,
@@ -88,7 +94,8 @@ piglit_cl_test(const int argc,
 
/*** Normal usage ***/
for(i = 0; i < num_kernel_arg_infos; ++i) {
-   printf("%s\n", piglit_cl_get_enum_name(kernel_arg_infos[i]));
+   const char* enum_name = 
piglit_cl_get_enum_name(kernel_arg_infos[i]);
+   printf("%s\n", enum_name);
 
param_value_size = 0;
ret_value_size = 0;
@@ -102,16 +109,15 @@ piglit_cl_test(const int argc,
if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
fprintf(stderr,
"Failed (error code: %s): Get size of %s.\n",
-   piglit_cl_get_error_name(errNo),
-   piglit_cl_get_enum_name(kernel_arg_infos[i]));
-   piglit_merge_result(, PIGLIT_FAIL);
+   piglit_cl_get_error_name(errNo), enum_name);
+   set_failure(, enum_name);
continue;
}
 
if (param_value_size > BUFFER_SIZE) {
fprintf(stderr,
-   "Failed: BUFFER_SIZE is too low\n");
-   piglit_merge_result(, PIGLIT_FAIL);
+   "Failed: BUFFER_SIZE is too small\n");
+   set_failure(, enum_name);
continue;
}
 
@@ -124,16 +130,15 @@ piglit_cl_test(const int argc,
if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
fprintf(stderr,
"Failed (error code: %s): Get value of %s.\n",
-   piglit_cl_get_error_name(errNo),
-   piglit_cl_get_enum_name(kernel_arg_infos[i]));
-   piglit_merge_result(, PIGLIT_FAIL);
+   piglit_cl_get_error_name(errNo), enum_name);
+   set_failure(, enum_name);
continue;
}
 
if (param_value_size != ret_value_size) {
fprintf(stderr,
"Failed: the returned size doesn't matches the 
queried one\n");
-   piglit_merge_result(, PIGLIT_FAIL);
+   set_failure(, enum_name);
continue;
}
 
@@ -160,13 +165,17 @@ piglit_cl_test(const int argc,
fprintf(stderr,
"Failed: the returned size doesn't matches. 
Expected %lu, got %lu\n",
expected_size, ret_value_size);
-   piglit_merge_result(, PIGLIT_FAIL);
+   set_failure(, enum_name);
+   continue;
}
 
-   //TODO: test returned values
+   //TODO: test returned values
+
+   piglit_report_subtest_result(PIGLIT_PASS, "%s", enum_name);
}
 
/*** Errors ***/
+   enum piglit_result input_check_result = PIGLIT_PASS;
 
/*
* CL_INVALID_ARG_INDEX if arg_indx is not a valid argument index.
@@ -181,7 +190,7 @@ piglit_cl_test(const int argc,
fprintf(stderr,
"Failed (error code: %s): Trigger CL_INVALID_ARG_INDEX 
if arg_indx is not a valid argument index.\n",
piglit_cl_get_error_name(errNo));
-   piglit_merge_result(, PIGLIT_FAIL);
+   piglit_merge_result(_check_result, PIGLIT_FAIL);
}
 
/*
@@ -200,7 +209,7 @@ piglit_cl_test(const int argc,
fprintf(stderr,
"Failed (error code: %s): Trigger CL_INVALID_VALUE if 
param_name is not one of the supported values.\n",
piglit_cl_get_error_name(errNo));
-   piglit_merge_result(, PIGLIT_FAIL);
+   piglit_merge_result(_check_result, PIGLIT_FAIL);
}
 
errNo = clGetKernelArgInfo(kernel,
@@ -213,16 +222,13 @@ piglit_cl_test(const int argc,
fprintf(stderr,
"Failed (error code: %s): Trigger CL_INVALID_VALUE if 
size in bytes specified by param_value is less than size of return type and 
param_value is not a NULL 

[Piglit] [PATCH 2/2] cl: add value cheking to clGetKernelArgInfo test

2016-11-27 Thread Serge Martin
---
 tests/cl/api/get-kernel-arg-info.c | 312 +++--
 1 file changed, 231 insertions(+), 81 deletions(-)

diff --git a/tests/cl/api/get-kernel-arg-info.c 
b/tests/cl/api/get-kernel-arg-info.c
index 7b336e4..59877f2 100644
--- a/tests/cl/api/get-kernel-arg-info.c
+++ b/tests/cl/api/get-kernel-arg-info.c
@@ -48,16 +48,176 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
config.run_per_platform = true;
config.create_context = true;
 
-   config.program_source = "kernel void dummy_kernel(int param_1) {}";
+   config.program_source =
+   "typedef struct struct_arg {\n"
+   "   int   m1;\n"
+   "   float m3;\n"
+   "} struct_arg_t;\n"
+   "\n"
+   "kernel void dummy_kernel(global int* g_int_p, \
+ local int* l_int_p,  \
+ constant int* c_int_p,   \
+ float float_num, \
+ sampler_t sampler,   \
+ read_only image2d_t i2d, \
+ const int3 vec3, \
+ struct_arg_t s_arg   \
+ ) { g_int_p[0] = s_arg.m1; }";
config.build_options = "-cl-kernel-arg-info";
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
-static void
-set_failure(enum piglit_result *result, const char* sub_name)
+#define NUMARGS 8
+#define BUFFER_SIZE 16
+
+static bool
+check_size(cl_uint arg_indx, cl_kernel_arg_info param_name,
+   size_t value_size)
+{
+   static size_t sizes[NUMARGS][2] = {
+   /* type, name */
+   {4 + 1, 7 + 1},
+   {4 + 1, 7 + 1},
+   {4 + 1, 7 + 1},
+   {5 + 1, 9 + 1},
+   {9 + 1, 7 + 1},
+   {9 + 1, 3 + 1},
+   {4 + 1, 4 + 1},
+   {12 + 1, 5 + 1},
+   };
+
+   size_t expected_size = 0;
+   size_t type_name_size = 0;
+   size_t arg_name_size = 0;
+
+   type_name_size = sizes[arg_indx][0];
+   arg_name_size = sizes[arg_indx][1];
+
+#define CASE(_enum_, _type_, _n_) \
+case _enum_: \
+   expected_size = sizeof(_type_) * ( _n_ ); \
+   break;
+
+   switch (param_name) {
+   CASE(CL_KERNEL_ARG_ADDRESS_QUALIFIER,
+cl_kernel_arg_address_qualifier, 1)
+   CASE(CL_KERNEL_ARG_ACCESS_QUALIFIER,
+cl_kernel_arg_access_qualifier, 1)
+   CASE(CL_KERNEL_ARG_TYPE_NAME, char, type_name_size)
+   CASE(CL_KERNEL_ARG_TYPE_QUALIFIER,
+cl_kernel_arg_type_qualifier, 1)
+   CASE(CL_KERNEL_ARG_NAME, char, arg_name_size)
+   }
+
+#undef CASE
+
+   if (value_size != expected_size) {
+   fprintf(stderr,
+   "Failed: arg #%d the returned size doesn't matches. 
Expected %lu, got %lu\n",
+   arg_indx, expected_size, value_size);
+   return false;
+   }
+
+   return true;
+}
+
+static bool
+check_value(cl_uint arg_indx, cl_kernel_arg_info param_name,
+char* value)
 {
-   piglit_merge_result(result, PIGLIT_FAIL);
-   piglit_report_subtest_result(PIGLIT_FAIL, "%s", sub_name);
+   static cl_kernel_arg_address_qualifier add_qual[NUMARGS] = {
+   CL_KERNEL_ARG_ADDRESS_GLOBAL,
+   CL_KERNEL_ARG_ADDRESS_LOCAL,
+   CL_KERNEL_ARG_ADDRESS_CONSTANT,
+   CL_KERNEL_ARG_ADDRESS_PRIVATE,
+   CL_KERNEL_ARG_ADDRESS_PRIVATE,
+   CL_KERNEL_ARG_ADDRESS_GLOBAL,
+   CL_KERNEL_ARG_ADDRESS_PRIVATE,
+   CL_KERNEL_ARG_ADDRESS_PRIVATE
+   };
+
+   static cl_kernel_arg_address_qualifier acc_qual[NUMARGS] = {
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_READ_ONLY,
+   CL_KERNEL_ARG_ACCESS_NONE,
+   CL_KERNEL_ARG_ACCESS_NONE
+   };
+
+   static char* typ_name[NUMARGS] = {
+   "int*",
+   "int*",
+   "int*",
+   "float",
+   "sampler_t",
+   "image2d_t",
+   "int3",
+   "struct_arg_t",
+   };
+
+   static cl_kernel_arg_type_qualifier typ_qual[NUMARGS] = {
+   CL_KERNEL_ARG_TYPE_NONE,
+   CL_KERNEL_ARG_TYPE_NONE,
+   CL_KERNEL_ARG_TYPE_CONST,
+   CL_KERNEL_ARG_TYPE_NONE,
+   CL_KERNEL_ARG_TYPE_NONE,
+   CL_KERNEL_ARG_TYPE_NONE,
+   CL_KERNEL_ARG_TYPE_CONST,
+   CL_KERNEL_ARG_TYPE_NONE
+   };
+
+   static char* arg_name[NUMARGS] = {

Re: [Piglit] [PATCH] cl: add clGetExtensionFunctionAddressForPlatform

2016-11-10 Thread Serge Martin
On Sunday 06 November 2016 13:58:31 Jan Vesely wrote:
> On Sun, 2016-11-06 at 14:43 +0100, Serge Martin wrote:
> > ---
> > 
> >  tests/cl.py|   2 +
> >  tests/cl/api/CMakeLists.cl.txt |   1 +
> >  .../get-extension-function-address-for-platform.c  | 124
> >  + 3 files changed, 127 insertions(+)
> >  create mode 100644
> >  tests/cl/api/get-extension-function-address-for-platform.c> 
> > diff --git a/tests/cl.py b/tests/cl.py
> > index 73fba0d..5aa76b6 100644
> > --- a/tests/cl.py
> > +++ b/tests/cl.py
> > 
> > @@ -34,6 +34,8 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
> >  # Platform
> >  g(['cl-api-get-platform-ids'], 'clGetPlatformIDs')
> >  g(['cl-api-get-platform-info'], 'clGetPlatformInfo')
> > 
> > +g(['cl-api-get-extension-function-address-for-platform'],
> > +'clGetExtensionFunctionAddressForPlatform')
> > 
> >  # Device
> >  g(['cl-api-get-device-ids'], 'clGetDeviceIDs')
> > 
> > diff --git a/tests/cl/api/CMakeLists.cl.txt
> > b/tests/cl/api/CMakeLists.cl.txt index c0b6540..9cfe9fb 100644
> > --- a/tests/cl/api/CMakeLists.cl.txt
> > +++ b/tests/cl/api/CMakeLists.cl.txt
> > @@ -7,6 +7,7 @@ piglit_cl_add_api_test (create-context create-context.c)
> > 
> >  piglit_cl_add_api_test (create-context-from-type
> >  create-context-from-type.c) piglit_cl_add_api_test (get-context-info
> >  get-context-info.c)
> >  piglit_cl_add_api_test (retain_release-context retain_release-context.c)
> > 
> > +piglit_cl_add_api_test (get-extension-function-address-for-platform
> > get-extension-function-address-for-platform.c)> 
> >  # Command queues
> >  piglit_cl_add_api_test (create-command-queue create-command-queue.c)
> > 
> > diff --git a/tests/cl/api/get-extension-function-address-for-platform.c
> > b/tests/cl/api/get-extension-function-address-for-platform.c new file
> > mode 100644
> > index 000..4a429ef
> > --- /dev/null
> > +++ b/tests/cl/api/get-extension-function-address-for-platform.c
> > @@ -0,0 +1,124 @@
> > +/*
> > + * Copyright © 2016 Serge Martin <edb+pig...@sigluy.net>
> > + *
> > + * 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 (including the
> > next + * paragraph) shall be included in all copies or substantial
> > portions of the + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND
> > NONINFRINGEMENT.  IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS
> > BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN
> > ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN
> > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE
> > SOFTWARE.
> > + */
> > +
> > +/**
> > + * @file get-extension-function-address-for-platform.c
> > + *
> > + * Test API function:
> > + *
> > + *   void *
> > + *   clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
> > + *const char *funcname)
> > + */
> > +
> > +#include "piglit-framework-cl-api.h"
> > +
> > +
> > +PIGLIT_CL_API_TEST_CONFIG_BEGIN
> > +
> > +   config.name = "clGetExtensionFunctionAddressForPlatform";
> > +   config.version_min = 12;
> > +
> > +   config.run_per_platform = true;
> > +
> > +PIGLIT_CL_API_TEST_CONFIG_END
> > +
> > +
> > +enum piglit_result
> > +piglit_cl_test(const int argc,
> > +   const char **argv,
> > +   const struct piglit_cl_api_test_config* config,
> > +   const struct piglit_cl_api_test_env* env)
> > +{
> > +#if defined(CL_VERSION_1_2)
> > +   enum piglit_result result = PIGLIT_PASS;
> > +
> > +   size_t 

Re: [Piglit] [PATCH] cl: Use HAVE_RT to determine linking with rt.

2016-11-06 Thread Serge Martin
On Friday 04 November 2016 22:57:25 Vinson Lee wrote:
> Fix build error on Mac OS X.
> 
> Linking C executable ../../../../../bin/cl-custom-use-sub-buffer-in-kernel
> ld: library not found for -lrt
> 
> Fixes: e34b54672cbb ("cl: Fix build on systems where clock_gettime is only
> avaiable in librt") Signed-off-by: Vinson Lee <v...@freedesktop.org>
> ---
>  tests/cl/CMakeLists.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/cl/CMakeLists.txt b/tests/cl/CMakeLists.txt
> index 9512fbd..6cdc1b8 100644
> --- a/tests/cl/CMakeLists.txt
> +++ b/tests/cl/CMakeLists.txt
> @@ -8,7 +8,7 @@ link_libraries (
>   ${OPENCL_opencl_LIBRARY}
>  )
> 
> -if(PIGLIT_HAS_POSIX_CLOCK_MONOTONIC)
> +if(HAVE_RT)

Looks like it's HAVE_LIBRT.
And I think the test should be if(PIGLIT_HAS_POSIX_CLOCK_MONOTONIC AND 
HAVE_LIBRT) like in tests/util/CMakeLists.txt

With that changed
Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

>   link_libraries(rt)
>  endif()

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] cl: add clGetExtensionFunctionAddressForPlatform

2016-11-06 Thread Serge Martin
---
 tests/cl.py|   2 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 .../get-extension-function-address-for-platform.c  | 124 +
 3 files changed, 127 insertions(+)
 create mode 100644 tests/cl/api/get-extension-function-address-for-platform.c

diff --git a/tests/cl.py b/tests/cl.py
index 73fba0d..5aa76b6 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -34,6 +34,8 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 # Platform
 g(['cl-api-get-platform-ids'], 'clGetPlatformIDs')
 g(['cl-api-get-platform-info'], 'clGetPlatformInfo')
+g(['cl-api-get-extension-function-address-for-platform'],
+'clGetExtensionFunctionAddressForPlatform')
 
 # Device
 g(['cl-api-get-device-ids'], 'clGetDeviceIDs')
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index c0b6540..9cfe9fb 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -7,6 +7,7 @@ piglit_cl_add_api_test (create-context create-context.c)
 piglit_cl_add_api_test (create-context-from-type create-context-from-type.c)
 piglit_cl_add_api_test (get-context-info get-context-info.c)
 piglit_cl_add_api_test (retain_release-context retain_release-context.c)
+piglit_cl_add_api_test (get-extension-function-address-for-platform 
get-extension-function-address-for-platform.c)
 
 # Command queues
 piglit_cl_add_api_test (create-command-queue create-command-queue.c)
diff --git a/tests/cl/api/get-extension-function-address-for-platform.c 
b/tests/cl/api/get-extension-function-address-for-platform.c
new file mode 100644
index 000..4a429ef
--- /dev/null
+++ b/tests/cl/api/get-extension-function-address-for-platform.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright © 2016 Serge Martin <edb+pig...@sigluy.net>
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file get-extension-function-address-for-platform.c
+ *
+ * Test API function:
+ *
+ *   void *
+ *   clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
+ *const char *funcname)
+ */
+
+#include "piglit-framework-cl-api.h"
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = "clGetExtensionFunctionAddressForPlatform";
+   config.version_min = 12;
+
+   config.run_per_platform = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined(CL_VERSION_1_2)
+   enum piglit_result result = PIGLIT_PASS;
+
+   size_t pos;
+   size_t last_pos;
+   void *ptr;
+   char *exts_list = piglit_cl_get_platform_info(env->platform_id,
+ CL_PLATFORM_EXTENSIONS);
+
+   if(!exts_list) {
+   fprintf(stderr, "clGetPlatformInfo error.\n");
+   return PIGLIT_FAIL;
+   }
+
+   printf("extensions list: %s\n", exts_list);
+
+   /*** Normal usage ***/
+
+   last_pos = 0;
+   pos = strcspn(exts_list + last_pos, " ");
+   while (pos) {
+   char *extension = NULL;
+   char *function_name = NULL;
+   ptr = NULL;
+
+   if (strncmp(exts_list + last_pos, "cl_khr_icd", pos) == 0) {
+   extension = "cl_khr_icd";
+   function_name = "clIcdGetPlatformIDsKHR";
+   }
+
+   if (function_name) {
+   printf("%s: %s\n", extension, function_name);
+   ptr = 
clGetExtensionFunctionAddressForPlatform(env->platform_id,
+   

Re: [Piglit] [PATCH v6] cl: Add a test for the predefined macros

2016-10-17 Thread Serge Martin

Le 2016-10-17 16:20, Jan Vesely a écrit :

On Sat, 2016-10-15 at 14:43 +0200, Niels Ole Salscheider wrote:

v6: Fix OpenCL C version test if test is compiled against OpenCL 1.0
v5: Use sscanf, fix CL_DEVICE_OPENCL_C_VERSION include guard, fix 
logic

v4: Test against env->version instead of opencl_version and never
report PIGLIT_SKIP for the values of IMAGE_SUPPORT and 
ENDIAN_LITTLE

v3: Fix alignment and typos
v2: Check the values of the defines and add more checks

Signed-off-by: Niels Ole Salscheider 
Reviewed-by: Jan Vesely 
---
 tests/cl.py  |   1 +
 tests/cl/program/CMakeLists.cl.txt   |   1 +
 tests/cl/program/predefined-macros.c | 463 
+++

 3 files changed, 465 insertions(+)
 create mode 100644 tests/cl/program/predefined-macros.c

diff --git a/tests/cl.py b/tests/cl.py
index 353ab05..73fba0d 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -96,6 +96,7 @@ with profile.group_manager(PiglitCLTest, 'program') 
as g:

 g(['cl-program-max-work-item-sizes'],
   'Run kernel with max work item sizes')
 g(['cl-program-bitcoin-phatk'], 'Bitcoin: phatk kernel')
+g(['cl-program-predefined-macros'], 'Check predefined 
preprocessor macros')


 with profile.group_manager(PiglitCLTest, 'interop') as g:
 g(['cl-interop-egl_khr_cl_event2'], 'EGL_KHR_cl_event2')
diff --git a/tests/cl/program/CMakeLists.cl.txt 
b/tests/cl/program/CMakeLists.cl.txt

index 82dc675..c8d7307 100644
--- a/tests/cl/program/CMakeLists.cl.txt
+++ b/tests/cl/program/CMakeLists.cl.txt
@@ -1,3 +1,4 @@
 piglit_cl_add_program_test (tester program-tester.c)
 piglit_cl_add_program_test (max-work-item-sizes 
max-work-item-sizes.c)

 piglit_cl_add_program_test (bitcoin-phatk bitcoin-phatk.c)
+piglit_cl_add_program_test (predefined-macros predefined-macros.c)
diff --git a/tests/cl/program/predefined-macros.c 
b/tests/cl/program/predefined-macros.c

new file mode 100644
index 000..f94812c
--- /dev/null
+++ b/tests/cl/program/predefined-macros.c
@@ -0,0 +1,463 @@
+/*
+ * Copyright © 2016 Niels Ole Salscheider 


+ *
+ * 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 (including 
the next
+ * paragraph) shall be included in all copies or substantial portions 
of the

+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT 
SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 
OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
OTHER

+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "piglit-framework-cl-program.h"
+
+char *program_source =
+"kernel void test(global int* file_defined, global int* line_defined, 
\n"
+" global int* opencl_version_defined, global int* 
opencl_version, \n"
+" global int* opencl_c_version_defined, global int* 
opencl_c_version, \n"
+" global int* cl_version_defined, global int* 
cl_version, \n"
+" global int* endian_little_defined, global int* 
endian_little, \n"
+" global int* image_support_defined, global int* 
image_support) \n"

+"{ \n"
+"#ifdef __FILE__ \n"
+" *file_defined = 1; \n"
+"#else \n"
+" *file_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __LINE__ \n"
+" *line_defined = 1; \n"
+"#else \n"
+" *line_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __OPENCL_VERSION__ \n"
+" *opencl_version_defined = 1; \n"
+" *opencl_version = __OPENCL_VERSION__; \n"
+"#else \n"
+" *opencl_version_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __OPENCL_C_VERSION__ \n"
+" *opencl_c_version_defined = 1; \n"
+" *opencl_c_version = __OPENCL_C_VERSION__; \n"
+"#else \n"
+" *opencl_c_version_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_0 \n"
+" cl_version_defined[0] = 1; \n"
+" cl_version[0] = CL_VERSION_1_0; \n"
+"#else \n"
+" cl_version_defined[0] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_1 \n"
+" cl_version_defined[1] = 1; \n"
+" cl_version[1] = CL_VERSION_1_1; \n"
+"#else \n"
+" cl_version_defined[1] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_2 \n"
+" cl_version_defined[2] = 1; \n"
+" cl_version[2] = CL_VERSION_1_2; \n"
+"#else \n"
+" cl_version_defined[2] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef 

Re: [Piglit] [PATCH v3] cl: Add a test for the predefined macros

2016-10-03 Thread Serge Martin
On Sunday 02 October 2016 12:53:03 Niels Ole Salscheider wrote:
> Signed-off-by: Niels Ole Salscheider 
> ---
>  tests/cl.py  |   1 +
>  tests/cl/program/CMakeLists.cl.txt   |   1 +
>  tests/cl/program/predefined-macros.c | 465
> +++ 3 files changed, 467 insertions(+)
>  create mode 100644 tests/cl/program/predefined-macros.c
> 
> diff --git a/tests/cl.py b/tests/cl.py
> index 353ab05..73fba0d 100644
> --- a/tests/cl.py
> +++ b/tests/cl.py
> @@ -96,6 +96,7 @@ with profile.group_manager(PiglitCLTest, 'program') as g:
>  g(['cl-program-max-work-item-sizes'],
>'Run kernel with max work item sizes')
>  g(['cl-program-bitcoin-phatk'], 'Bitcoin: phatk kernel')
> +g(['cl-program-predefined-macros'], 'Check predefined preprocessor
> macros')
> 
>  with profile.group_manager(PiglitCLTest, 'interop') as g:
>  g(['cl-interop-egl_khr_cl_event2'], 'EGL_KHR_cl_event2')
> diff --git a/tests/cl/program/CMakeLists.cl.txt
> b/tests/cl/program/CMakeLists.cl.txt index 82dc675..c8d7307 100644
> --- a/tests/cl/program/CMakeLists.cl.txt
> +++ b/tests/cl/program/CMakeLists.cl.txt
> @@ -1,3 +1,4 @@
>  piglit_cl_add_program_test (tester program-tester.c)
>  piglit_cl_add_program_test (max-work-item-sizes max-work-item-sizes.c)
>  piglit_cl_add_program_test (bitcoin-phatk bitcoin-phatk.c)
> +piglit_cl_add_program_test (predefined-macros predefined-macros.c)
> diff --git a/tests/cl/program/predefined-macros.c
> b/tests/cl/program/predefined-macros.c new file mode 100644
> index 000..9b5150b
> --- /dev/null
> +++ b/tests/cl/program/predefined-macros.c
> @@ -0,0 +1,465 @@
> +/*
> + * Copyright © 2016 Niels Ole Salscheider 
> + *
> + * 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 (including the
> next + * paragraph) shall be included in all copies or substantial portions
> of the + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
> IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "piglit-framework-cl-program.h"
> +
> +char *program_source =
> +"kernel void test(global int* file_defined, global int* line_defined, \n"
> +" global int* opencl_version_defined, global int*
> opencl_version, \n" +" global int*
> opencl_c_version_defined, global int* opencl_c_version, \n" +" 
>global int* cl_version_defined, global int* cl_version, \n" +"  
>   global int* endian_little_defined, global int* endian_little, \n" +" 
>global int* image_support_defined, global int*
> image_support) \n" +"{ \n"
> +"#ifdef __FILE__ \n"
> +"*file_defined = 1; \n"
> +"#else \n"
> +"*file_defined = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef __LINE__ \n"
> +"*line_defined = 1; \n"
> +"#else \n"
> +"*line_defined = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef __OPENCL_VERSION__ \n"
> +"*opencl_version_defined = 1; \n"
> +"*opencl_version = __OPENCL_VERSION__; \n"
> +"#else \n"
> +"*opencl_version_defined = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef __OPENCL_C_VERSION__ \n"
> +"*opencl_c_version_defined = 1; \n"
> +"*opencl_c_version = __OPENCL_C_VERSION__; \n"
> +"#else \n"
> +"*opencl_c_version_defined = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef CL_VERSION_1_0 \n"
> +"cl_version_defined[0] = 1; \n"
> +"cl_version[0] = CL_VERSION_1_0; \n"
> +"#else \n"
> +"cl_version_defined[0] = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef CL_VERSION_1_1 \n"
> +"cl_version_defined[1] = 1; \n"
> +"cl_version[1] = CL_VERSION_1_1; \n"
> +"#else \n"
> +"cl_version_defined[1] = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef CL_VERSION_1_2 \n"
> +"cl_version_defined[2] = 1; \n"
> +"cl_version[2] = CL_VERSION_1_2; \n"
> +"#else \n"
> +"cl_version_defined[2] = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef CL_VERSION_2_0 \n"
> +"cl_version_defined[3] = 1; \n"
> +"cl_version[3] = CL_VERSION_2_0; \n"
> +"#else \n"
> +"cl_version_defined[3] = 0; \n"
> +"#endif \n"
> +"\n"
> +"#ifdef __ENDIAN_LITTLE__ 

Re: [Piglit] [PATCH v2] cl: Add a test for the predefined macros

2016-09-29 Thread Serge Martin

On 2016-09-18 16:47, Niels Ole Salscheider wrote:

Signed-off-by: Niels Ole Salscheider 
---
 tests/cl/program/CMakeLists.cl.txt   |   1 +
 tests/cl/program/predefined-macros.c | 408 
+++

 2 files changed, 409 insertions(+)
 create mode 100644 tests/cl/program/predefined-macros.c

diff --git a/tests/cl/program/CMakeLists.cl.txt
b/tests/cl/program/CMakeLists.cl.txt
index 82dc675..c8d7307 100644
--- a/tests/cl/program/CMakeLists.cl.txt
+++ b/tests/cl/program/CMakeLists.cl.txt
@@ -1,3 +1,4 @@
 piglit_cl_add_program_test (tester program-tester.c)
 piglit_cl_add_program_test (max-work-item-sizes max-work-item-sizes.c)
 piglit_cl_add_program_test (bitcoin-phatk bitcoin-phatk.c)
+piglit_cl_add_program_test (predefined-macros predefined-macros.c)
diff --git a/tests/cl/program/predefined-macros.c
b/tests/cl/program/predefined-macros.c
new file mode 100644
index 000..ff2b75f
--- /dev/null
+++ b/tests/cl/program/predefined-macros.c
@@ -0,0 +1,408 @@
+/*
+ * Copyright © 2016 Niels Ole Salscheider 


+ *
+ * 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 (including 
the next
+ * paragraph) shall be included in all copies or substantial portions 
of the

+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT 
SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 
OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING

+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+


Hello

Tanks for the v2.

There is a mix of alignement made with tab and space in the whole file
Pleas use one tab ident per level and align with the same number
of tab + spaces if the instruction need multiples lines.

Others comment below.


+#include "piglit-framework-cl-program.h"
+
+char *program_source =
+"kernel void test(global int* file_defined, global int* line_defined, 
\n"
+"		  global int* opencl_version_defined, global int* opencl_version, 
\n"
+"		  global int* opencl_c_version_defined, global int* 
opencl_c_version, \n"

+"   global int* cl_version_defined, global int* cl_version, \n"
+"   global int* endian_little_defined, global int* endian_little, \n"
+"   global int* image_support_defined, global int* image_support) \n"
+"{ \n"
+"#ifdef __FILE__ \n"
+" *file_defined = 1; \n"
+"#else \n"
+" *file_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __LINE__ \n"
+" *line_defined = 1; \n"
+"#else \n"
+" *line_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __OPENCL_VERSION__ \n"
+" *opencl_version_defined = 1; \n"
+" *opencl_version = __OPENCL_VERSION__; \n"
+"#else \n"
+" *opencl_version_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __OPENCL_C_VERSION__ \n"
+" *opencl_c_version_defined = 1; \n"
+" *opencl_c_version = __OPENCL_C_VERSION__; \n"
+"#else \n"
+" *opencl_c_version_defined = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_0 \n"
+" cl_version_defined[0] = 1; \n"
+" cl_version[0] = CL_VERSION_1_0; \n"
+"#else \n"
+" cl_version_defined[0] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_1 \n"
+" cl_version_defined[1] = 1; \n"
+" cl_version[1] = CL_VERSION_1_1; \n"
+"#else \n"
+" cl_version_defined[1] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_1_2 \n"
+" cl_version_defined[2] = 1; \n"
+" cl_version[2] = CL_VERSION_1_2; \n"
+"#else \n"
+" cl_version_defined[2] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef CL_VERSION_2_0 \n"
+" cl_version_defined[3] = 1; \n"
+" cl_version[3] = CL_VERSION_2_0; \n"
+"#else \n"
+" cl_version_defined[3] = 0; \n"
+"#endif \n"
+"\n"
+"#ifdef __ENDIAN_LITTLE__ \n"
+" *endian_little_defined = 1; \n"
+" *endian_little = __ENDIAN_LITTLE__; \n"
+"#else \n"
+" *endian_little_defined = 0; \n"
+"#endif \n"
+"#ifdef __IMAGE_SUPPORT__ \n"
+" *image_support_defined = 1; \n"
+" *image_support = __IMAGE_SUPPORT_; \n"


__IMAGE_SUPPORT__


+"#else \n"
+" *image_support_defined = 0; \n"
+"#endif \n"
+"}";
+
+PIGLIT_CL_PROGRAM_TEST_CONFIG_BEGIN
+
+   config.name = "Check if all required macros are defined";


I would have call it "Preprocessor Macros." but i's up to you.


+   config.clc_version_min = 10;
+   config.run_per_device = true;
+
+   config.program_source = program_source;
+   config.kernel_name = "test";
+

Re: [Piglit] [PATCH] cl: Add a test for the predefined macros

2016-09-10 Thread Serge Martin
On Saturday 10 September 2016 11:46:32 Niels Ole Salscheider wrote:
> Signed-off-by: Niels Ole Salscheider 
> ---
>  tests/cl/program/build/cl-defines.cl | 22 ++
>  1 file changed, 22 insertions(+)
>  create mode 100644 tests/cl/program/build/cl-defines.cl
> 
> diff --git a/tests/cl/program/build/cl-defines.cl
> b/tests/cl/program/build/cl-defines.cl new file mode 100644
> index 000..696e9f0
> --- /dev/null
> +++ b/tests/cl/program/build/cl-defines.cl
> @@ -0,0 +1,22 @@
> +/*!
> +[config]
> +name: OpenCL predefined macros
> +clc_version_min: 10
> +!*/
> +
> +#ifndef __FILE__
> +#error "__FILE__ not defined"
> +#endif
> +
> +#ifndef __LINE__
> +#error "__LINE__ not defined"
> +#endif
> +
> +#ifndef __OPENCL_VERSION__
> +#error "__OPENCL_VERSION__ not defined"
> +#endif
> +
> +#ifndef __ENDIAN_LITTLE__
> +#error "__ENDIAN_LITTLE__ not defined"

This should be undefined if the GPU is big endian an triggering an error would 
be wrong

> +#endif

There is also __OPENCL_C_VERSION__, __kernel_exec that should be check, this 
way.
However, if we go for something different, we could for example run a kernel  
that fills an array and then have the value check by a C program.
This way, you could also check __IMAGE_SUPPORT__, __ENDIAN_LITTLE__, 
CL_VERSION_1_0 (and so on), __OPENCL_VERSION__, __IMAGE_SUPPORT__, 
__FAST_RELAXED_MATH__ based on what is reported by the opencl lib.

Serge

> +

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl: Initialize errNo on invalid image type.

2016-08-29 Thread Serge Martin
On Friday 01 July 2016 21:18:15 Vinson Lee wrote:
> Fixes sometimes-uninitialized warning.
> 
> piglit-util-cl.c:1052:13: warning: variable 'errNo' is used uninitialized
> whenever 'if' condition is false [-Wsometimes-uninitialized] } else if
> (desc->image_type == CL_MEM_OBJECT_IMAGE3D) {
>^
> piglit-util-cl.c:1062:28: note: uninitialized use occurs here
> if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
>   ^
> piglit-util-cl.c:1052:9: note: remove the 'if' if its condition is always
> true } else if (desc->image_type == CL_MEM_OBJECT_IMAGE3D) {
>^~~
> piglit-util-cl.c:1040:14: note: initialize the variable 'errNo' to silence
> this warning cl_int errNo;
> ^
>  = 0
> 
> Fixes: 910cd6c222930 ("cl: add image and sampler utility functions")
> Signed-off-by: Vinson Lee 
> ---
>  tests/util/piglit-util-cl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c
> index 7e7d9850be5c..b5b7fce550f6 100644
> --- a/tests/util/piglit-util-cl.c
> +++ b/tests/util/piglit-util-cl.c
> @@ -1055,6 +1055,7 @@ piglit_cl_create_image(piglit_cl_context context,
> cl_mem_flags flags, desc->image_depth, 0, 0,
>   NULL, );
>   } else {
> + errNo = CL_INVALID_MEM_OBJECT;

This not an error returned by clCreateImage*D. If your ok with that I would 
prefer to push it with CL_INVALID_OPERATION.

>   fprintf(stderr,
>   "Invalid image mem object type: %s\n",
>   piglit_cl_get_enum_name(desc->image_type));

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 1/2] cl: Add global atomic_cmpxchg tests

2016-06-20 Thread Serge Martin
On Monday 13 June 2016 11:23:49 Jan Vesely wrote:
> Passes on CUDA, beignet, clover on kaveri, and intel CPU.
> 
> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>

As spotted by git, there is an extra line added to the file atomic_cmpxchg-
global-return.cl. The other test don't have empty line at the end.
Otherwise the serie is 

Reviewed-by : Serge Martin <edb+pig...@sigluy.net>

> ---
>  .../builtin/atomic/atomic_cmpxchg-global-return.cl | 74
> ++ .../builtin/atomic/atomic_cmpxchg-global.cl|
> 69  2 files changed, 143 insertions(+)
>  create mode 100644
> tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global-return.cl
> create mode 100644
> tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global.cl
> 
> diff --git
> a/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global-return.cl
> b/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global-return.cl
> new file mode 100644
> index 000..2cc1031
> --- /dev/null
> +++
> b/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global-return.cl
> @@ -0,0 +1,74 @@
> +/*!
> +[config]
> +name: atomic_cmpxchg global return
> +clc_version_min: 11
> +
> +[test]
> +name: simple int
> +kernel_name: simple_int
> +dimensions: 1
> +global_size: 1 0 0
> +arg_out: 0 buffer int[2]  5 -4
> +arg_in:  0 buffer int[2] -4 -4
> +arg_in:  1 buffer int[2] -4  3
> +arg_in:  2 buffer int[2]  5  5
> +arg_out: 3 buffer int[2] -4 -4
> +
> +[test]
> +name: simple uint
> +kernel_name: simple_uint
> +dimensions: 1
> +global_size: 1 0 0
> +arg_out: 0 buffer uint[2] 5 4
> +arg_in:  0 buffer uint[2] 4 4
> +arg_in:  1 buffer uint[2] 4 3
> +arg_in:  2 buffer uint[2] 5 5
> +arg_out: 3 buffer uint[2] 4 4
> +
> +[test]
> +name: threads int
> +kernel_name: threads_int
> +dimensions: 1
> +global_size: 8 0 0
> +local_size:  8 0 0
> +arg_out: 0 buffer int[1] 8
> +arg_in:  0 buffer int[1] 0
> +arg_out: 1 buffer int[8] 0 1 2 3 4 5 6 7
> +
> +[test]
> +name: threads uint
> +kernel_name: threads_uint
> +dimensions: 1
> +global_size: 8 0 0
> +local_size:  8 0 0
> +arg_out: 0 buffer uint[1] 8
> +arg_in:  0 buffer uint[1] 0
> +arg_out: 1 buffer uint[8] 0 1 2 3 4 5 6 7
> +
> +!*/
> +
> +#define SIMPLE_TEST(TYPE) \
> +kernel void simple_##TYPE(global TYPE *initial, global TYPE *compare,
> global TYPE *value, global TYPE *old) { \ +   old[0] =
> atomic_cmpxchg(initial, compare[0], value[0]); \
> + old[1] = atomic_cmpxchg(initial+1, compare[1], value[1]); \
> +}
> +
> +#define THREADS_TEST(TYPE) \
> +kernel void threads_##TYPE(global TYPE *out, global TYPE *old) { \
> + int i; \
> + barrier(CLK_GLOBAL_MEM_FENCE); \
> + TYPE id = get_global_id(0); \
> + for(i = 0; i < get_global_size(0); i++){ \
> + TYPE old_val = atomic_cmpxchg(out, id, id+1); \
> + if (old_val == id) /* success */ \
> + old[id] = old_val; \
> + barrier(CLK_GLOBAL_MEM_FENCE); \
> + } \
> +}
> +
> +SIMPLE_TEST(int)
> +SIMPLE_TEST(uint)
> +
> +THREADS_TEST(int)
> +THREADS_TEST(uint)
> +
> diff --git
> a/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global.cl
> b/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global.cl new file
> mode 100644
> index 000..05cf401
> --- /dev/null
> +++ b/tests/cl/program/execute/builtin/atomic/atomic_cmpxchg-global.cl
> @@ -0,0 +1,69 @@
> +/*!
> +[config]
> +name: atomic_cmpxchg global
> +clc_version_min: 11
> +
> +[test]
> +name: simple int
> +kernel_name: simple_int
> +dimensions: 1
> +global_size: 1 0 0
> +arg_out: 0 buffer int[2]  5 -4
> +arg_in:  0 buffer int[2] -4 -4
> +arg_in:  1 buffer int[2] -4  3
> +arg_in:  2 buffer int[2]  5  5
> +
> +[test]
> +name: simple uint
> +kernel_name: simple_uint
> +dimensions: 1
> +global_size: 1 0 0
> +arg_out: 0 buffer uint[2] 5 4
> +arg_in:  0 buffer uint[2] 4 4
> +arg_in:  1 buffer uint[2] 4 3
> +arg_in:  2 buffer uint[2] 5 5
> +
> +[test]
> +name: threads int
> +kernel_name: threads_int
> +dimensions: 1
> +global_size: 8 0 0
> +local_size:  8 0 0
> +arg_out: 0 buffer int[1] 8
> +arg_in:  0 buffer int[1] 0
> +
> +[test]
> +name: threads uint
> +kernel_name: threads_uint
> +dimensions: 1
> +global_size: 8 0 0
> +local_size:  8 0 0
> +arg_out: 0 buffer uint[1] 8
> +arg_in:  0 buffer uint[1] 0
> +
> +!*/
> +
> +#define SIMPLE_TEST(TYPE) \
> +kernel void simple_##TYPE(global TYPE *initial, global TYPE *compare,
> global TYPE *value) { \ + atomic_cmpxchg(initial, compare[0], value[0]); \
> + atomic_cmpxchg(initial+1, comp

Re: [Piglit] [PATCH v3 2/2] util: Suppress OpenCL deprecation warnings

2016-05-17 Thread Serge Martin
On Tuesday 17 May 2016 13:10:52 Dylan Baker wrote:
> Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
> 
> v3 - Use OpenCL deprecation macros (EdB)
> 
>  tests/util/piglit-util-cl-enum.h | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/util/piglit-util-cl-enum.h
> b/tests/util/piglit-util-cl-enum.h index 51336ce..e08d3c3 100644
> --- a/tests/util/piglit-util-cl-enum.h
> +++ b/tests/util/piglit-util-cl-enum.h
> @@ -25,6 +25,11 @@
>  #ifndef PIGLIT_UTIL_CL_ENUM_H
>  #define PIGLIT_UTIL_CL_ENUM_H
> 
> +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
> +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
> +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
> +#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
> +
>  #ifdef __APPLE__
>  #include 
>  #else

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v3 1/2] tests/cl: Fix pointer warning

2016-05-17 Thread Serge Martin
On Tuesday 17 May 2016 13:10:51 Dylan Baker wrote:
> clCreatProgramWithBinary expects a "const unsigned char **", but the code
> passes an "unsighed char **". This is a particular kind of messiness
> that is hard to fix, so just cast when passing into
> clCreateProgramWithBinary.
> 
> Thanks to idr and Matt for help getting this right.
> 
> Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/api/create-program-with-binary.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/cl/api/create-program-with-binary.c
> b/tests/cl/api/create-program-with-binary.c index 4873b76..2a7894e 100644
> --- a/tests/cl/api/create-program-with-binary.c
> +++ b/tests/cl/api/create-program-with-binary.c
> @@ -119,7 +119,8 @@ static cl_program create_binary_program(const
> piglit_cl_context ctx)
> 
>   binary_program = clCreateProgramWithBinary (cl_ctx, ctx->num_devices,
> ctx->device_ids,
> -   sizes, binaries,
> +   sizes,
> +   (const unsigned char **) 
> binaries,
> NULL,
> );

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 2/2] cl: add global offset test

2016-05-17 Thread Serge Martin
On Sunday 15 May 2016 17:39:25 Jan Vesely wrote:
> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>

As spotted by git am, there is some trailing spaces add the end of the array 
of the two 2D test.
With that removed :

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/program/execute/global-offset.cl | 85
> +++ 1 file changed, 85 insertions(+)
>  create mode 100644 tests/cl/program/execute/global-offset.cl
> 
> diff --git a/tests/cl/program/execute/global-offset.cl
> b/tests/cl/program/execute/global-offset.cl new file mode 100644
> index 000..ab373cf
> --- /dev/null
> +++ b/tests/cl/program/execute/global-offset.cl
> @@ -0,0 +1,85 @@
> +/*!
> +[config]
> +name: get_offset
> +clc_version_min: 10
> +
> +kernel_name: fill
> +
> +[test]
> +name: 1D, global_size 4 0 0, global_offset 9 0 0
> +dimensions: 1
> +global_size: 4 0 0
> +local_size: 4 0 0
> +global_offset: 9 0 0
> +arg_out: 0 buffer int[8] 9 9 10 9 11 9 12 9
> +
> +[test]
> +name: 1D, global_size 4 0 0, global_offset 9 8 0
> +dimensions: 1
> +global_size: 4 0 0
> +local_size: 4 0 0
> +global_offset: 9 8 0
> +arg_out: 0 buffer int[8] 9 9 10 9 11 9 12 9
> +
> +[test]
> +name: 1D, global_size 4 0 0, global_offset 9 8 7
> +dimensions: 1
> +global_size: 4 0 0
> +local_size: 4 0 0
> +global_offset: 9 8 7
> +arg_out: 0 buffer int[8] 9 9 10 9 11 9 12 9
> +
> +[test]
> +name: 2D, global_size 4 4 0, global_offset 9 8 0
> +dimensions: 2
> +global_size: 4 4 0
> +local_size: 4 4 0
> +global_offset: 9 8 0
> +arg_out: 0 buffer int[32]  809 809  810 809  811 809  812 809 \
> +   909 809  910 809  911 809  912 809 \
> +  1009 809 1010 809 1011 809 1012 809 \
> +  1109 809 1110 809  809 1112 809
> +
> +[test]
> +name: 2D, global_size 4 4 0, global_offset 9 8 7
> +dimensions: 2
> +global_size: 4 4 0
> +local_size: 4 4 0
> +global_offset: 9 8 7
> +arg_out: 0 buffer int[32]  809 809  810 809  811 809  812 809 \
> +   909 809  910 809  911 809  912 809 \
> +  1009 809 1010 809 1011 809 1012 809 \
> +  1109 809 1110 809  809 1112 809
> +
> +[test]
> +name: 3D, global_size 4 4 4, global_offset 9 8 7
> +dimensions: 3
> +global_size: 4 4 4
> +local_size: 4 4 4
> +global_offset: 9 8 7
> +arg_out: 0 buffer int[128]  70809 70809  70810 70809  70811 70809  70812
> 70809 \ +70909 70809  70910 70809  70911 70809 
> 70912 70809 \ +71009 70809  71010 70809  71011
> 70809  71012 70809 \ +71109 70809  71110 70809 
> 7 70809  71112 70809 \ +80809 70809  80810
> 70809  80811 70809  80812 70809 \ +80909 70809 
> 80910 70809  80911 70809  80912 70809 \ +81009
> 70809  81010 70809  81011 70809  81012 70809 \ +   
> 81109 70809  81110 70809  8 70809  81112 70809 \ + 
>   90809 70809  90810 70809  90811 70809  90812 70809 \ +   
> 90909 70809  90910 70809  90911 70809  90912 70809 \ + 
>   91009 70809  91010 70809  91011 70809  91012 70809 \ +   
> 91109 70809  91110 70809  9 70809  91112 70809
> \ +   100809 70809 100810 70809 100811 70809 100812
> 70809 \ +   100909 70809 100910 70809 100911 70809
> 100912 70809 \ +   101009 70809 101010 70809 101011
> 70809 101012 70809 \ +   101109 70809 101110 70809
> 10 70809 101112 70809 +
> +!*/
> +
> +kernel void fill(global int* out) {
> + unsigned int pos = get_local_id(0) + 4 * get_local_id(1) + 16 *
> get_local_id(2); +unsigned int id = get_global_id(0) +
> 100*get_global_id(1) + 1*get_global_id(2); +  unsigned int offset =
> get_global_offset(0) + 100 * get_global_offset(1) + 1 *
> get_global_offset(2); +   out[2*pos] = id;
> + out[2*pos+1] = offset;
> +}

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 1/2] cl: add support for global offset

2016-05-17 Thread Serge Martin
On Sunday 15 May 2016 17:39:24 Jan Vesely wrote:
> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>

Review-by: Serge Martin <edb+pig...@sigluy.net>
> ---
>  tests/cl/api/create-program-with-binary.c|  2 +-
>  tests/cl/custom/buffer-flags.c   |  2 +-
>  tests/cl/custom/flush-after-enqueue-kernel.c |  2 +-
>  tests/cl/custom/r600-create-release-buffer-bug.c | 12 -
>  tests/cl/custom/run-simple-kernel.c  |  2 +-
>  tests/cl/custom/use-sub-buffer-in-kernel.c   |  4 +--
>  tests/cl/program/bitcoin-phatk.c |  2 +-
>  tests/cl/program/max-work-item-sizes.c   |  1 +
>  tests/cl/program/program-tester.c| 33
>  tests/util/piglit-util-cl.c  |
>  7 +++--
>  tests/util/piglit-util-cl.h  |  4 +++
>  11 files changed, 56 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/cl/api/create-program-with-binary.c
> b/tests/cl/api/create-program-with-binary.c index 4873b76..4238331 100644
> --- a/tests/cl/api/create-program-with-binary.c
> +++ b/tests/cl/api/create-program-with-binary.c
> @@ -183,7 +183,7 @@ piglit_cl_test(const int argc,
>   size_t global_work_size = 1;
>   size_t local_work_size = 1;
>   cl_command_queue queue = ctx->command_queues[i];
> - if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1,
> + if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, NULL,
>   _work_size, _work_size)) {
>   fprintf(stderr, "Failed to execute binary kernel.");
>   piglit_merge_result(, PIGLIT_FAIL);
> diff --git a/tests/cl/custom/buffer-flags.c b/tests/cl/custom/buffer-flags.c
> index 6bf988f..115fb92 100644
> --- a/tests/cl/custom/buffer-flags.c
> +++ b/tests/cl/custom/buffer-flags.c
> @@ -130,7 +130,7 @@ buffer_test(piglit_cl_context *ctx,
> 
>   printf("Running the kernel...\n");
>   if (!piglit_cl_enqueue_ND_range_kernel(context->command_queues[0],
> - kernel, 1, , )) {
> + kernel, 1, NULL, , )) {
>   ret = PIGLIT_FAIL;
>   goto cleanup;
>   }
> diff --git a/tests/cl/custom/flush-after-enqueue-kernel.c
> b/tests/cl/custom/flush-after-enqueue-kernel.c index 00a0516..8d3fc8c
> 100644
> --- a/tests/cl/custom/flush-after-enqueue-kernel.c
> +++ b/tests/cl/custom/flush-after-enqueue-kernel.c
> @@ -92,7 +92,7 @@ piglit_cl_test(const int argc,
>   }
> 
>   if (!piglit_cl_enqueue_ND_range_kernel(context->command_queues[0],
> - kernel, 3, global_size, local_size)) {
> + kernel, 3, NULL, global_size, 
> local_size)) {
>   return PIGLIT_FAIL;
>   }
> 
> diff --git a/tests/cl/custom/r600-create-release-buffer-bug.c
> b/tests/cl/custom/r600-create-release-buffer-bug.c index 7c3a214..535e57d
> 100644
> --- a/tests/cl/custom/r600-create-release-buffer-bug.c
> +++ b/tests/cl/custom/r600-create-release-buffer-bug.c
> @@ -74,8 +74,8 @@ piglit_cl_test(const int argc,
>   return PIGLIT_FAIL;
>   }
> 
> - if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, _size,
> - _size)) {
> + if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, NULL,
> +_size, _size)) {
>   return PIGLIT_FAIL;
>   }
> 
> @@ -84,8 +84,8 @@ piglit_cl_test(const int argc,
>   return PIGLIT_FAIL;
>   }
> 
> - if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, _size,
> - _size)) {
> + if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, NULL,
> +_size, _size)) {
>   return PIGLIT_FAIL;
>   }
> 
> @@ -98,8 +98,8 @@ piglit_cl_test(const int argc,
>   return PIGLIT_FAIL;
>   }
> 
> - if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, _size,
> - _size)) {
> + if (!piglit_cl_enqueue_ND_range_kernel(queue, kernel, 1, NULL,
> +_size, _size)) {
>   return PIGLIT_FAIL;
>   }
> 
> diff --git a/tests/cl/custom/run-simple-kernel.c
> b/tests/cl/custom/run-simple-kernel.c index 48d7725..db529d2 100644
> --- a/tests/cl/custom/run-simple-kernel.c
> +++ b/tests/cl/custom/run-simple-kernel.c
> @@ -61,7 +61,7 @@ piglit_cl_test(const int argc,
>  

Re: [Piglit] [PATCH v2] cl: Fix cl_khr_fp64 checks

2016-05-06 Thread Serge Martin
On Thursday 28 April 2016 22:22:06 Jan Vesely wrote:
> v2: fix sizeof test
> 
> Signed-off-by: Jan Vesely <jano.ves...@gmail.com>
> ---
>  tests/cl/program/build/scalar-data-types.cl | 5 +++--
>  tests/cl/program/execute/sizeof.cl  | 4 +++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/cl/program/build/scalar-data-types.cl
> b/tests/cl/program/build/scalar-data-types.cl index 00693f5..09fd15f 100755
> --- a/tests/cl/program/build/scalar-data-types.cl
> +++ b/tests/cl/program/build/scalar-data-types.cl
> @@ -21,8 +21,9 @@ kernel void test(global int* out) {
>   uintptr_t uit;
>   //half h; // Can be only used as a pointer to a buffer
> 
> -// Needs cl_khr_fp64 or OpenCL C 1.2
> -#if __OPENCL_C_VERSION__ >= 120
> +// Needs cl_khr_fp64
> +#ifdef cl_khr_fp64
> +#pragma OPENCL EXTENSION cl_khr_fp64 : require

pragma OPENCL EXTENSION cl_khr_fp64 : enable

>   double d;
>   double* d1;
>  #endif
> diff --git a/tests/cl/program/execute/sizeof.cl
> b/tests/cl/program/execute/sizeof.cl index 744a59c..aa78590 100644
> --- a/tests/cl/program/execute/sizeof.cl
> +++ b/tests/cl/program/execute/sizeof.cl
> @@ -100,7 +100,9 @@ kernel void so(global int* out) {
> 
>   out[i++] = sizeof(half);
> 
> -#if __OPENCL_C_VERSION__ >= 120
> +// Needs cl_khr_fp64
> +#ifdef cl_khr_fp64
> +#pragma OPENCL EXTENSION cl_khr_fp64 : require

enable

with that fixed : 
Reviewed-by Serge Martin <edb+pig...@sigluy.net>

 - Serge

>   out[i++] = sizeof(double);
>   out[i++] = sizeof(double2);
>   out[i++] = sizeof(double3);

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] cl: add image support checking functions

2016-05-06 Thread Serge Martin
---
 tests/util/piglit-util-cl.c | 28 
 tests/util/piglit-util-cl.h | 18 ++
 2 files changed, 46 insertions(+)

diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c
index efa289c..51d6808 100644
--- a/tests/util/piglit-util-cl.c
+++ b/tests/util/piglit-util-cl.c
@@ -1004,6 +1004,34 @@ piglit_cl_read_whole_buffer(cl_command_queue 
command_queue, cl_mem buffer,
return success;
 }
 
+bool
+piglit_cl_get_context_image_support(const piglit_cl_context context)
+{
+   bool ret = false;
+
+   unsigned i;
+   for(i = 0; i < context->num_devices; i++)
+   ret |= 
piglit_cl_get_device_image_support(context->device_ids[i]);
+
+   return ret;
+}
+
+bool
+piglit_cl_get_device_image_support(cl_device_id device)
+{
+   bool ret = false;
+
+   cl_bool *image_support =
+   piglit_cl_get_device_info(device, CL_DEVICE_IMAGE_SUPPORT);
+
+   if (image_support)
+   ret = *image_support;
+
+   free(image_support);
+
+   return ret;
+}
+
 cl_mem
 piglit_cl_create_image(piglit_cl_context context, cl_mem_flags flags,
const cl_image_format *format,
diff --git a/tests/util/piglit-util-cl.h b/tests/util/piglit-util-cl.h
index 0330740..e4730cc 100644
--- a/tests/util/piglit-util-cl.h
+++ b/tests/util/piglit-util-cl.h
@@ -545,6 +545,24 @@ typedef struct {
 } piglit_image_desc;
 #endif
 
+/**
+ * \brief Get context image support.
+ *
+ * @param context  Context on which to create image.
+ * @return True if there is one device with image support.
+ */
+bool
+piglit_cl_get_context_image_support(const piglit_cl_context context);
+
+/**
+ * \brief Get device image support.
+ *
+ * @param device   Context on which to create image.
+ * @return True if there the device has image support.
+ */
+bool
+piglit_cl_get_device_image_support(cl_device_id device);
+
 
 /**
  * \brief Create an image.
-- 
2.5.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] cl: check for image support using util/ functions

2016-05-06 Thread Serge Martin
---
 tests/cl/api/create-image.c   | 19 +--
 tests/cl/api/create-sampler.c | 18 +-
 tests/cl/api/enqueue-fill-image.c | 10 +-
 tests/cl/api/get-image-info.c | 19 +--
 tests/cl/api/set-kernel-arg.c | 18 +-
 5 files changed, 5 insertions(+), 79 deletions(-)

diff --git a/tests/cl/api/create-image.c b/tests/cl/api/create-image.c
index 1ee5f71..29e552c 100644
--- a/tests/cl/api/create-image.c
+++ b/tests/cl/api/create-image.c
@@ -38,23 +38,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
-   unsigned i;
-   for(i = 0; i < ctx->num_devices; i++) {
-   int *image_support =
-   piglit_cl_get_device_info(ctx->device_ids[i],
-   CL_DEVICE_IMAGE_SUPPORT);
-   if (*image_support) {
-   free(image_support);
-   return true;
-   }
-
-   free(image_support);
-   }
-   return false;
-}
-
 static void
 no_image_check_invalid(
cl_int errcode_ret,
@@ -107,7 +90,7 @@ piglit_cl_test(const int argc,
const struct piglit_cl_api_test_config* config,
const struct piglit_cl_api_test_env* env)
 {
-   if (!context_has_image_support(env->context)) {
+   if (!piglit_cl_get_context_image_support(env->context)) {
return no_image_tests(env);
} else {
return PIGLIT_PASS;
diff --git a/tests/cl/api/create-sampler.c b/tests/cl/api/create-sampler.c
index dcdef05..d51fe47 100644
--- a/tests/cl/api/create-sampler.c
+++ b/tests/cl/api/create-sampler.c
@@ -36,22 +36,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
-   unsigned i;
-   for(i = 0; i < ctx->num_devices; i++) {
-   int *image_support =
-   piglit_cl_get_device_info(ctx->device_ids[i],
-   CL_DEVICE_IMAGE_SUPPORT);
-   if (*image_support) {
-   free(image_support);
-   return true;
-   }
-   free(image_support);
-   }
-   return false;
-}
-
 static enum piglit_result
 no_image_tests(const struct piglit_cl_api_test_env* env)
 {
@@ -80,7 +64,7 @@ piglit_cl_test(const int argc,
const struct piglit_cl_api_test_config* config,
const struct piglit_cl_api_test_env* env)
 {
-   if (!context_has_image_support(env->context)) {
+   if (!piglit_cl_get_context_image_support(env->context)) {
return no_image_tests(env);
} else {
return PIGLIT_PASS;
diff --git a/tests/cl/api/enqueue-fill-image.c 
b/tests/cl/api/enqueue-fill-image.c
index 2839b67..4de5dca 100644
--- a/tests/cl/api/enqueue-fill-image.c
+++ b/tests/cl/api/enqueue-fill-image.c
@@ -104,19 +104,11 @@ piglit_cl_test(const int argc,
cl_command_queue queue = env->context->command_queues[0];
int i;
 
-   cl_bool *image_support =
-   piglit_cl_get_device_info(env->context->device_ids[0],
- CL_DEVICE_IMAGE_SUPPORT);
-
-   if (!*image_support) {
+   if (!piglit_cl_get_device_image_support(env->context->device_ids[0])) {
fprintf(stderr, "No image support\n");
-   free(image_support);
return PIGLIT_SKIP;
}
 
-   free(image_support);
-   image_support = NULL;
-
img_format.image_channel_order = CL_RGBA;
img_format.image_channel_data_type = CL_UNSIGNED_INT8;
img_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
diff --git a/tests/cl/api/get-image-info.c b/tests/cl/api/get-image-info.c
index a8b5bec..d4dc842 100644
--- a/tests/cl/api/get-image-info.c
+++ b/tests/cl/api/get-image-info.c
@@ -46,23 +46,6 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
-static bool context_has_image_support(const piglit_cl_context ctx)
-{
-   int ret = 0;
-   unsigned i;
-   for(i = 0; i < ctx->num_devices; i++) {
-   int *image_support =
-   piglit_cl_get_device_info(ctx->device_ids[i],
-   CL_DEVICE_IMAGE_SUPPORT);
-   if (image_support)
-   ret |= *image_support;
-
-   free(image_support);
-   }
-   return ret;
-}
-
-
 enum piglit_result
 piglit_cl_test(const int argc,
const char** argv,
@@ -79,7 +62,7 @@ piglit_cl_test(const int argc,
.image_channel_data_type = CL_FLOAT,
};
 
-   if (!context_has_image_support(env->context)) {
+   if (!piglit_cl_get_context_image_support(env->context)) {
fprintf(stderr, "No device with image 

Re: [Piglit] [PATCH] cl: Initialize result variable.

2016-04-29 Thread Serge Martin
On Thursday 28 April 2016 22:02:20 Jan Vesely wrote:
> Fixes Unknown status "Unknown result" python exception.
> 
> Signed-off-by: Jan Vesely <jano.ves...@gmail.com>

Reviewed-by Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/api/set-kernel-arg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
> index fb77059..0d476e3 100644
> --- a/tests/cl/api/set-kernel-arg.c
> +++ b/tests/cl/api/set-kernel-arg.c
> @@ -200,7 +200,7 @@ piglit_cl_test(const int argc,
>"Set kernel argument for buffer which is NULL");
> 
>   /*** Errors ***/
> - enum piglit_result input_check_result;
> + enum piglit_result input_check_result = PIGLIT_PASS;
>   /*
>* CL_INVALID_KERNEL if kernel is not a valid kernel object.
>*/

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH RESEND] cl: Fix image support when built on CL<1.2

2016-04-24 Thread Serge Martin
On Monday 04 April 2016 08:55:48 Jan Vesely wrote:
> On Mon, 2016-03-28 at 21:17 -0400, Jan Vesely wrote:
> > Provide our own image_desc structure since it's too tangled to
> > remove.
> > Tests that require OCL 1.2 result in WARN:
> > Piglit was compiled with lower OpenCL version (1.1) than version_min:
> > 12.
> > OCL 1.1 image tests pass on Intel CPU OCL when compiled in 1.1
> > environment.
> 
> gentle ping.

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> 
> > Signed-off-by: Jan Vesely <jano.ves...@gmail.com>
> > ---
> > 
> > Looks like the first one did not make it to the ML.
> > 
> >  tests/cl/program/program-tester.c |  2 +-
> >  tests/util/piglit-util-cl.c   | 34 -
> > -
> >  tests/util/piglit-util-cl.h   | 20 +++-
> >  3 files changed, 40 insertions(+), 16 deletions(-)
> > 
> > diff --git a/tests/cl/program/program-tester.c
> > b/tests/cl/program/program-tester.c
> > index 3e0ed43..0a3b011 100644
> > --- a/tests/cl/program/program-tester.c
> > +++ b/tests/cl/program/program-tester.c
> > @@ -345,7 +345,7 @@ struct test_arg {
> > uint64_t ulp;
> >  
> > /* image data */
> > -   cl_image_desc   image_desc;
> > +   piglit_image_desc   image_desc;
> > cl_image_format image_format;
> >  
> > /* sampler data */
> > diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-
> > cl.c
> > index 9bf45a2..efa289c 100644
> > --- a/tests/util/piglit-util-cl.c
> > +++ b/tests/util/piglit-util-cl.c
> > @@ -1006,14 +1006,18 @@ piglit_cl_read_whole_buffer(cl_command_queue
> > command_queue, cl_mem buffer,
> >  
> >  cl_mem
> >  piglit_cl_create_image(piglit_cl_context context, cl_mem_flags
> > flags,
> > -   const cl_image_format *format, const
> > cl_image_desc *desc)
> > +   const cl_image_format *format,
> > +   const piglit_image_desc *desc)
> >  {
> > cl_int errNo;
> > cl_mem image = NULL;
> >  
> > +#ifdef CL_VERSION_1_2
> > if (piglit_cl_get_platform_version(context->platform_id) >=
> > 12) {
> > image = clCreateImage(context->cl_ctx, flags,
> > format, desc, NULL, );
> > -   } else if (desc->image_type == CL_MEM_OBJECT_IMAGE2D) {
> > +   } else
> > +#endif
> > +   if (desc->image_type == CL_MEM_OBJECT_IMAGE2D) {
> > image = clCreateImage2D(context->cl_ctx, flags,
> > format,
> > desc->image_width, desc-
> > 
> > >image_height, 0,
> > 
> > NULL, );
> > @@ -1068,36 +1072,38 @@ piglit_get_image_region(cl_mem image, size_t
> > *region)
> > free(p);
> >  
> > switch (*type) {
> > +#ifdef CL_VERSION_1_2
> > +   case CL_MEM_OBJECT_IMAGE1D_ARRAY:
> > +   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > +   region[1] = *p;
> > +   free(p);
> > +   region[2] = 1;
> > +   break;
> > case CL_MEM_OBJECT_IMAGE1D:
> > case CL_MEM_OBJECT_IMAGE1D_BUFFER:
> > region[1] = 1;
> > region[2] = 1;
> > break;
> > -   case CL_MEM_OBJECT_IMAGE2D:
> > -   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > -   region[1] = *p;
> > -   free(p);
> > -   region[2] = 1;
> > -   break;
> > -   case CL_MEM_OBJECT_IMAGE3D:
> > +   case CL_MEM_OBJECT_IMAGE2D_ARRAY:
> > p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > region[1] = *p;
> > free(p);
> > -   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_DEPTH);
> > +   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > region[2] = *p;
> > free(p);
> > break;
> > -   case CL_MEM_OBJECT_IMAGE1D_ARRAY:
> > -   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > +#endif
> > +   case CL_MEM_OBJECT_IMAGE2D:
> > +   p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > 

Re: [Piglit] [PATCH v2 1/1] cl: Split setKernelArg into subtests

2016-03-14 Thread Serge Martin
On Wednesday 09 March 2016 10:59:44 Jan Vesely wrote:
> v2: coalesce input checks into one subtest
> 
> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/api/set-kernel-arg.c | 55
> --- 1 file changed, 31
> insertions(+), 24 deletions(-)
> 
> diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
> index 471fea1..fb77059 100644
> --- a/tests/cl/api/set-kernel-arg.c
> +++ b/tests/cl/api/set-kernel-arg.c
> @@ -75,7 +75,7 @@ get_device_image_support(cl_device_id device)
>   return true;
>  }
> 
> -static bool
> +static void
>  test (cl_kernel kernel,
>cl_uint arg_index,
>size_t arg_size,
> @@ -85,16 +85,17 @@ test (cl_kernel kernel,
>const char* test_str)
>  {
>   cl_int errNo;
> -
> + enum piglit_result res = PIGLIT_PASS;
> +
>   errNo = clSetKernelArg(kernel, arg_index, arg_size, arg_value);
>   if(!piglit_cl_check_error(errNo, expected_error)) {
>   fprintf(stderr, "Failed (error code: %s): %s.\n",
>   piglit_cl_get_error_name(errNo), test_str);
> + res = PIGLIT_FAIL;
>   piglit_merge_result(result, PIGLIT_FAIL);
> - return false;
>   }
> -
> - return true;
> + if (expected_error == CL_SUCCESS)
> + piglit_report_subtest_result(res, "%s", test_str);
>  }
> 
>  enum piglit_result
> @@ -110,10 +111,11 @@ piglit_cl_test(const int argc,
>   } struct_arg_t;
> 
>   enum piglit_result result = PIGLIT_PASS;
> + const char * test_str = NULL;
> 
>   cl_int errNo;
>   cl_kernel kernel;
> -
> +
>   cl_mem buffer;
>   cl_float float_num = 1.1;
>   cl_int int_num = 1;
> @@ -171,10 +173,12 @@ piglit_cl_test(const int argc,
>CL_SUCCESS, ,
>"Set kernel argument for array");
> 
> + test_str = "Set kernel argument for sampler";
>   if (image_support) {
>   test(kernel, 3, sizeof(cl_sampler), ,
> -  CL_SUCCESS, ,
> -  "Set kernel argument for sampler");
> +  CL_SUCCESS, , test_str);
> + } else {
> + piglit_report_subtest_result(PIGLIT_SKIP, "%s", test_str);
>   }
> 
>   test(kernel, 4, sizeof(cl_int3), ,
> @@ -196,19 +200,19 @@ piglit_cl_test(const int argc,
>"Set kernel argument for buffer which is NULL");
> 
>   /*** Errors ***/
> -
> + enum piglit_result input_check_result;
>   /*
>* CL_INVALID_KERNEL if kernel is not a valid kernel object.
>*/
>   test(NULL, 1, sizeof(cl_float), _num,
> -  CL_INVALID_KERNEL, ,
> +  CL_INVALID_KERNEL, _check_result,
>"Trigger CL_INVALID_KERNEL if kernel is not a valid kernel 
> object");
> 
>   /*
>* CL_INVALID_ARG_INDEX if arg_index is not a valid argument index.
>*/
>   test(kernel, 11, sizeof(cl_float), _num,
> -  CL_INVALID_ARG_INDEX, ,
> +  CL_INVALID_ARG_INDEX, _check_result,
>"Trigger CL_INVALID_ARG_INDEX if arg_index is not a valid argument
> index");
> 
>   /*
> @@ -222,38 +226,39 @@ piglit_cl_test(const int argc,
>* Version : 1.2
>*/
>   test(kernel, 1, sizeof(cl_float), NULL,
> -  CL_INVALID_ARG_VALUE, ,
> +  CL_INVALID_ARG_VALUE, _check_result,
>"Trigger CL_INVALID_ARG_VALUE if arg_value specified is NULL for an
> argument that is not declared with the __local qualifier"); test(kernel, 2,
> sizeof(cl_int), _num,
> -  CL_INVALID_ARG_VALUE, ,
> +  CL_INVALID_ARG_VALUE, _check_result,
>"Trigger CL_INVALID_ARG_VALUE if arg_value specified is not NULL 
> for
> an argument that is declared with the __local qualifier");
> 
>   /*
>* CL_INVALID_MEM_OBJECT for an argument declared to be a memory object
> when * the specified arg_value is not a valid memory object.
>*/
> + test_str = "Trigger CL_INVALID_MEM_OBJECT for an argument declared to 
> be a
> memory object when the specified arg_value is not a valid memory object.";
> errNo = clSetKernelArg(kernel, 0, sizeof(cl_mem), _buffer); if(  
> errNo != CL_INVALID_MEM_OBJECT
>  && errNo != CL_INVALID_ARG_VALUE) { // two possible values
>   piglit_cl_check_error(errNo, CL_INVALID_MEM_OBJECT);
>   fprintf(stderr,
> - "Failed (error code: %s): Trigger

Re: [Piglit] [PATCH 1/1] cl: Split setKernelArg into subtests

2016-03-10 Thread Serge Martin
On Wednesday 09 March 2016 12:09:39 Dylan Baker wrote:
> Quoting Serge Martin (2016-03-05 07:18:29)
> 
> > On Monday 29 February 2016 10:45:47 Jan Vesely wrote:
> > > Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>
> > > ---
> > > applies on top of Serge's changes.
> > 
> > In get-mem-object-info.c we only make subtest reporting for positive case,
> > error path been reported globally.
> > 
> > I think reporting error as subtest is a little to verbose. May be we could
> > make a subtest report for the whole error case?
> 
> This breaks a basic assumption of piglit's report modules: that results
> don't randomly appear and disappear. If they do then you'll have odd
> failure/pass rates when comparing two results.

Don't get me wrong about that. When I was talking about "the whole error case"
I was talking about the input validation checks that could be coalesced in one 
subtest to report error or failure. Like the v2 Jan posted in fact.

But, anyway, I'm ok if this "let's join all input validation in one subtest to 
make it less verbose" idea of mine is not what people are expecting.

> 
> IE: tests should always report the same number of subtests, in both the
> pass and fail case, the test suite will automatically make the global
> state the "worst" state of the subtests.
> 
> Dylan

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 1/1] cl: Split setKernelArg into subtests

2016-03-05 Thread Serge Martin
On Monday 29 February 2016 10:45:47 Jan Vesely wrote:
> Signed-off-by: Jan Vesely 
> ---
> applies on top of Serge's changes.

In get-mem-object-info.c we only make subtest reporting for positive case, 
error path been reported globally.

I think reporting error as subtest is a little to verbose. May be we could 
make a subtest report for the whole error case?

> Jan
> 
>  tests/cl/api/set-kernel-arg.c | 24 ++--
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
> index 471fea1..61a16b7 100644
> --- a/tests/cl/api/set-kernel-arg.c
> +++ b/tests/cl/api/set-kernel-arg.c
> @@ -90,10 +90,12 @@ test (cl_kernel kernel,
>   if(!piglit_cl_check_error(errNo, expected_error)) {
>   fprintf(stderr, "Failed (error code: %s): %s.\n",
>   piglit_cl_get_error_name(errNo), test_str);
> + piglit_report_subtest_result(PIGLIT_FAIL, "%s", test_str);
>   piglit_merge_result(result, PIGLIT_FAIL);
>   return false;
>   }
> 
> + piglit_report_subtest_result(PIGLIT_PASS, "%s", test_str);
>   return true;
>  }
> 
> @@ -110,10 +112,11 @@ piglit_cl_test(const int argc,
>   } struct_arg_t;
> 
>   enum piglit_result result = PIGLIT_PASS;
> + const char * test_str = NULL;
> 
>   cl_int errNo;
>   cl_kernel kernel;
> -
> +
>   cl_mem buffer;
>   cl_float float_num = 1.1;
>   cl_int int_num = 1;
> @@ -175,6 +178,8 @@ piglit_cl_test(const int argc,
>   test(kernel, 3, sizeof(cl_sampler), ,
>CL_SUCCESS, ,
>"Set kernel argument for sampler");
> + } else {
> + piglit_report_subtest_result(PIGLIT_SKIP, "%s", "Set kernel 
> argument 
for
> sampler"); }
> 
>   test(kernel, 4, sizeof(cl_int3), ,
> @@ -232,28 +237,35 @@ piglit_cl_test(const int argc,
>* CL_INVALID_MEM_OBJECT for an argument declared to be a memory object
> when * the specified arg_value is not a valid memory object.
>*/
> + test_str = "Trigger CL_INVALID_MEM_OBJECT for an argument declared to 
> be a
> memory object when the specified arg_value is not a valid memory object.";
> errNo = clSetKernelArg(kernel, 0, sizeof(cl_mem), _buffer); if(  
> errNo != CL_INVALID_MEM_OBJECT
>  && errNo != CL_INVALID_ARG_VALUE) { // two possible values
>   piglit_cl_check_error(errNo, CL_INVALID_MEM_OBJECT);
>   fprintf(stderr,
> - "Failed (error code: %s): Trigger CL_INVALID_MEM_OBJECT 
> for an
> argument declared to be a memory object when the specified arg_value is not
> a valid memory object.\n", -  
> piglit_cl_get_error_name(errNo));
> + "Failed (error code: %s): %s\n",
> + piglit_cl_get_error_name(errNo), test_str);
> + piglit_report_subtest_result(PIGLIT_FAIL, "%s", test_str);
>   piglit_merge_result(, PIGLIT_FAIL);
> + } else {
> + piglit_report_subtest_result(PIGLIT_PASS, "%s", test_str);
>   }
> 
>   /*
>* CL_INVALID_SAMPLER for an argument declared to be of type sampler_t
> when * the specified arg_value is not a valid sampler object.
>*/
> + test_str = "Trigger CL_INVALID_SAMPLER for an argument declared to be a
> memory object when the specified arg_value is not a valid memory object.";
> errNo = clSetKernelArg(kernel, 3, sizeof(cl_sampler), NULL);
>   if(   errNo != CL_INVALID_SAMPLER
>  && errNo != CL_INVALID_ARG_VALUE) { // two possible values
>   piglit_cl_check_error(errNo, CL_INVALID_SAMPLER);
> - fprintf(stderr,
> - "Failed (error code: %s): Trigger CL_INVALID_SAMPLER 
> for an
> argument declared to be a memory object when the specified arg_value is not
> a valid memory object.\n", -  
> piglit_cl_get_error_name(errNo));
> + fprintf(stderr, "Failed (error code: %s): %s.\n",
> + piglit_cl_get_error_name(errNo), test_str);
> + piglit_report_subtest_result(PIGLIT_FAIL, "%s", test_str);
>   piglit_merge_result(, PIGLIT_FAIL);
> + } else {
> + piglit_report_subtest_result(PIGLIT_PASS, "%s", test_str);
>   }
> 
>   /*

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl: Add some tests for fdim

2016-02-27 Thread Serge Martin
On Saturday 27 February 2016 22:59:29 Aaron Watry wrote:
> Signed-off-by: Aaron Watry <awa...@gmail.com>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  generated_tests/gen_cl_math_builtins.py | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/generated_tests/gen_cl_math_builtins.py
> b/generated_tests/gen_cl_math_builtins.py index 35fbce3..29b4e1a 100644
> --- a/generated_tests/gen_cl_math_builtins.py
> +++ b/generated_tests/gen_cl_math_builtins.py
> @@ -52,6 +52,7 @@ CLC_VERSION_MIN = {
>  'erfc' : 10,
>  'exp' : 10,
>  'fabs' : 10,
> +'fdim' : 10,
>  'floor' : 10,
>  'fmax' : 10,
>  'fmin' : 10,
> @@ -274,6 +275,15 @@ tests = {
>  ],
>  'tolerance' : 0
>  },
> +'fdim' : {
> +'arg_types' : [F, F, F],
> +'function_type': 'ttt',
> +'values' : [
> +[0.0, 0.75, 0.0, 0.0, float("inf"),  0.0, 
> float("nan"), float("nan"), float("nan"), 2.2469 ], # Result +   
> [0.3, 1.0,  pi,  0.0, float("inf"),  float("inf"), float("nan"), 1.0,  
>float("nan"), 1.12345 ], # Arg0 +[1.5, 0.25, pi, -0.0,
> float("-inf"), float("inf"), float("nan"), float("nan"), 1.0, 
> -1.12345] # Arg1 +]
> +},
>  'floor' : {
>  'arg_types': [F, F],
>  'function_type': 'ttt',

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] cl: clSetKernelArg check for image support

2016-02-24 Thread Serge Martin
---
 tests/cl/api/set-kernel-arg.c | 51 +++
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
index 6bd7ec8..4e44fc0 100644
--- a/tests/cl/api/set-kernel-arg.c
+++ b/tests/cl/api/set-kernel-arg.c
@@ -51,6 +51,21 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
+static bool
+get_device_image_support(cl_device_id device)
+{
+   cl_bool *has_image =
+   piglit_cl_get_device_info(device, CL_DEVICE_IMAGE_SUPPORT);
+
+   if (!*has_image) {
+   fprintf(stdout, "No image support. Sampler arg won't be 
tested\n");
+   free(has_image);
+   return false;
+   }
+
+   free(has_image);
+   return true;
+}
 
 static bool
 test (cl_kernel kernel,
@@ -88,10 +103,13 @@ piglit_cl_test(const int argc,
cl_mem buffer;
cl_float float_num = 1.1;
cl_int int_num = 1;
-   cl_sampler sampler;
+   cl_sampler sampler = NULL;
 
cl_mem invalid_buffer;
 
+   cl_bool image_support =
+   get_device_image_support(env->context->device_ids[0]);
+
/*** Normal usage ***/
kernel = clCreateKernel(env->program, "kernel_fun", );
if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
@@ -113,16 +131,18 @@ piglit_cl_test(const int argc,
return PIGLIT_FAIL;
}
 
-   sampler = clCreateSampler(env->context->cl_ctx,
- CL_TRUE,
- CL_ADDRESS_NONE,
- CL_FILTER_NEAREST,
- );
-   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
-   fprintf(stderr,
-   "Failed (error code: %s): Create sampler.\n",
-   piglit_cl_get_error_name(errNo));
-   return PIGLIT_FAIL;
+   if (image_support) {
+   sampler = clCreateSampler(env->context->cl_ctx,
+ CL_TRUE,
+ CL_ADDRESS_NONE,
+ CL_FILTER_NEAREST,
+ );
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   "Failed (error code: %s): Create sampler.\n",
+   piglit_cl_get_error_name(errNo));
+   return PIGLIT_FAIL;
+   }
}
 
test(kernel, 0, sizeof(cl_mem), ,
@@ -134,9 +154,12 @@ piglit_cl_test(const int argc,
test(kernel, 2, sizeof(cl_int), NULL,
 CL_SUCCESS, ,
 "Set kernel argument for array");
-   test(kernel, 3, sizeof(cl_sampler), ,
-CL_SUCCESS, ,
-"Set kernel argument for sampler");
+
+   if (image_support) {
+   test(kernel, 3, sizeof(cl_sampler), ,
+CL_SUCCESS, ,
+"Set kernel argument for sampler");
+   }

/*
 * Next line is also valid.
-- 
2.5.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] cl: clSetKernelArg test more args kind

2016-02-24 Thread Serge Martin
---
 tests/cl/api/set-kernel-arg.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/tests/cl/api/set-kernel-arg.c b/tests/cl/api/set-kernel-arg.c
index 4e44fc0..471fea1 100644
--- a/tests/cl/api/set-kernel-arg.c
+++ b/tests/cl/api/set-kernel-arg.c
@@ -44,10 +44,18 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
config.create_context = true;
 
config.program_source =
+   "typedef struct struct_arg {\n"
+   "   int   m1;\n"
+   "   int4  m2;\n"
+   "   float m3;\n"
+   "} struct_arg_t;\n"
+   "\n"
"kernel void kernel_fun(__global int* arr, \
float float_num,   \
__local int* int_ptr,  \
-   sampler_t sampler) {}";
+   sampler_t sampler, \
+   int3 vec3, \
+   struct_arg_t s_arg) {}";
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
@@ -95,6 +103,12 @@ piglit_cl_test(const int argc,
const struct piglit_cl_api_test_config* config,
const struct piglit_cl_api_test_env* env)
 {
+   typedef struct struct_arg {
+   cl_int   m1;
+   cl_int4  m2;
+   cl_float m3;
+   } struct_arg_t;
+
enum piglit_result result = PIGLIT_PASS;
 
cl_int errNo;
@@ -104,6 +118,8 @@ piglit_cl_test(const int argc,
cl_float float_num = 1.1;
cl_int int_num = 1;
cl_sampler sampler = NULL;
+   cl_int3 vec3;
+   struct_arg_t s_arg;
 
cl_mem invalid_buffer;
 
@@ -160,7 +176,15 @@ piglit_cl_test(const int argc,
 CL_SUCCESS, ,
 "Set kernel argument for sampler");
}
-   
+
+   test(kernel, 4, sizeof(cl_int3), ,
+CL_SUCCESS, ,
+"Set kernel argument for cl_int3");
+
+   test(kernel, 5, sizeof(struct_arg_t), _arg,
+CL_SUCCESS, ,
+"Set kernel argument for struct");
+
/*
 * Next line is also valid.
 *
@@ -183,7 +207,7 @@ piglit_cl_test(const int argc,
/*
 * CL_INVALID_ARG_INDEX if arg_index is not a valid argument index.
 */
-   test(kernel, 4, sizeof(cl_float), _num,
+   test(kernel, 11, sizeof(cl_float), _num,
 CL_INVALID_ARG_INDEX, ,
 "Trigger CL_INVALID_ARG_INDEX if arg_index is not a valid argument 
index");
 
-- 
2.5.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 0/2] cl: more clSetKernelArg checks

2016-02-24 Thread Serge Martin
This serie is intended to add test case for GROMACS error when passing a struct
arg by value (currently a failure on Clover).
It also add a check for cl_int3 that are of the same size as cl_int4.

Serge Martin (2):
  cl: clSetKernelArg check for image support
  cl: clSetKernelArg test more args kind

 tests/cl/api/set-kernel-arg.c | 79 ++-
 1 file changed, 63 insertions(+), 16 deletions(-)

-- 
2.5.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] Fix cllinkprogram build kernal faill for llvm3.7+

2016-01-29 Thread Serge Martin
On Wednesday 27 January 2016 00:26:30 Meng Mengmeng wrote:
> Clang now does not support funciton declration like:
> int get_number();
> And it does not support impilict spir-function call.

This is strange it seems to work fine here.

Do you try with this patch : cl: improve clLinkProgram 
(https://patchwork.freedesktop.org/patch/60994/), that languish since October

> 
> Signed-off-by: Meng Mengmeng 
> ---
>  tests/cl/api/link-program.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/cl/api/link-program.c b/tests/cl/api/link-program.c
> index e98f428..d9abe27 100644
> --- a/tests/cl/api/link-program.c
> +++ b/tests/cl/api/link-program.c
> @@ -51,10 +51,10 @@ PIGLIT_CL_API_TEST_CONFIG_END
> 
> 
>  const char* strings[] = {
> - "int get_number() { return 42; }",
> - "int get_number();\n",
> - "kernel void test_kernel() { int i = get_number(); }",
> - "int get_number() { return 0; }"
> + "int get_number(void) { return 42; }",
> + "int get_number(void);\n",
> + "int get_number(void);\nkernel void test_kernel(void) { int i =
> get_number(); }", +   "int get_number(void) { return 0; }"
>  };
> 
>  #if defined(CL_VERSION_1_2)

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] Add tests for GL_ARB_shader_draw_parameters

2015-12-17 Thread Serge Martin
On Wednesday 16 December 2015 16:17:30 Kristian Høgsberg wrote:
> From: Kristian Høgsberg Kristensen 
> 
> ---
> 
> v2: Fix copy-paste error in drawid-indirect-vertexid case.
> 
>  tests/all.py   |  15 ++
>  tests/spec/CMakeLists.txt  |   1 +
>  .../arb_shader_draw_parameters/CMakeLists.gl.txt   |  14 ++
>  .../spec/arb_shader_draw_parameters/CMakeLists.txt |   1 +
>  tests/spec/arb_shader_draw_parameters/basevertex.c | 176 +
>  .../arb_shader_draw_parameters/drawid-indirect.c   | 216
> + tests/spec/arb_shader_draw_parameters/drawid.c |
> 173 + 7 files changed, 596 insertions(+)
>  create mode 100644 tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
>  create mode 100644 tests/spec/arb_shader_draw_parameters/CMakeLists.txt
>  create mode 100644 tests/spec/arb_shader_draw_parameters/basevertex.c
>  create mode 100644 tests/spec/arb_shader_draw_parameters/drawid-indirect.c
>  create mode 100644 tests/spec/arb_shader_draw_parameters/drawid.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index f61ff15..39cffbb 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4552,5 +4552,20 @@ with profile.group_manager(
>  for sample_count in (str(x) for x in MSAA_SAMPLE_COUNTS):
>  g(['ext_shader_samples_identical', sample_count])
> 
> +# Group ARR_shader_draw_parameters

# Group ARB_shader_draw_parameters

> +with profile.group_manager(
> +PiglitGLTest,
> +grouptools.join('spec', 'ARB_shader_draw_parameters')) as g:
> +g(['arb_shader_draw_parameters-drawid', 'drawid'], 'drawid')
> +g(['arb_shader_draw_parameters-drawid', 'vertexid'], 'drawid-vertexid')
> +g(['arb_shader_draw_parameters-basevertex', 'basevertex'],
> 'basevertex') +g(['arb_shader_draw_parameters-basevertex',
> 'baseinstance'], 'baseinstance') +   
> g(['arb_shader_draw_parameters-basevertex', 'basevertex-baseinstance'],
> 'basevertex-baseinstance') +g(['arb_shader_draw_parameters-basevertex',
> 'vertexid-zerobased'], 'vertexid-zerobased') +   
> g(['arb_shader_draw_parameters-drawid-indirect', 'drawid'],
> 'drawid-indirect') +g(['arb_shader_draw_parameters-drawid-indirect',
> 'basevertex'], 'drawid-indirect-basevertex') +   
> g(['arb_shader_draw_parameters-drawid-indirect', 'baseinstance'],
> 'drawid-indirect-baseinstance') +   
> g(['arb_shader_draw_parameters-drawid-indirect', 'vertexid'],
> 'drawid-indirect-vertexid') +
>  if platform.system() is 'Windows':
>  profile.filter_tests(lambda p, _: not p.startswith('glx'))
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 57ac541..b499cd8 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -139,3 +139,4 @@ add_subdirectory (ext_framebuffer_blit)
>  add_subdirectory (mesa_pack_invert)
>  add_subdirectory (ext_texture_format_bgra)
>  add_subdirectory (oes_draw_elements_base_vertex)
> +add_subdirectory (arb_shader_draw_parameters)
> diff --git a/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
> b/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt new file mode
> 100644
> index 000..f711e2c
> --- /dev/null
> +++ b/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
> @@ -0,0 +1,14 @@
> +include_directories(
> + ${GLEXT_INCLUDE_DIR}
> + ${OPENGL_INCLUDE_PATH}
> + ${piglit_SOURCE_DIR}/tests/mesa/util
> +)
> +
> +link_libraries (
> + piglitutil_${piglit_target_api}
> + ${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_shader_draw_parameters-basevertex basevertex.c)
> +piglit_add_executable (arb_shader_draw_parameters-drawid drawid.c)
> +piglit_add_executable (arb_shader_draw_parameters-drawid-indirect
> drawid-indirect.c) diff --git
> a/tests/spec/arb_shader_draw_parameters/CMakeLists.txt
> b/tests/spec/arb_shader_draw_parameters/CMakeLists.txt new file mode 100644
> index 000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_shader_draw_parameters/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_shader_draw_parameters/basevertex.c
> b/tests/spec/arb_shader_draw_parameters/basevertex.c new file mode 100644
> index 000..343c38c
> --- /dev/null
> +++ b/tests/spec/arb_shader_draw_parameters/basevertex.c
> @@ -0,0 +1,176 @@
> +/*
> + * Copyright © 2015 Intel Corporation
> + *
> + * 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 (including the
> next + * paragraph) shall be 

Re: [Piglit] [PATCH v2] cl-api-enqueue-fill-image: Fix memory leaks.

2015-11-29 Thread Serge Martin
On Sunday 22 November 2015 15:10:59 Vinson Lee wrote:
> Fixes Coverity "resource leak" defects.
> 
> Suggested-by: Serge Martin <edb+pig...@sigluy.net>
> Signed-off-by: Vinson Lee <v...@freedesktop.org>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/api/enqueue-fill-image.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/cl/api/enqueue-fill-image.c
> b/tests/cl/api/enqueue-fill-image.c index ebcfba4..2839b67 100644
> --- a/tests/cl/api/enqueue-fill-image.c
> +++ b/tests/cl/api/enqueue-fill-image.c
> @@ -114,6 +114,9 @@ piglit_cl_test(const int argc,
>   return PIGLIT_SKIP;
>   }
> 
> + free(image_support);
> + image_support = NULL;
> +
>   img_format.image_channel_order = CL_RGBA;
>   img_format.image_channel_data_type = CL_UNSIGNED_INT8;
>   img_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
> @@ -325,7 +328,6 @@ piglit_cl_test(const int argc,
>*/
>   /* This is a per device test, clCreateImage would have failed before */
> 
> - free(image_support);
>   clReleaseMemObject(image);
>   return result;
>  #else

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl-api-enqueue-fill-image: Fix memory leaks.

2015-11-22 Thread Serge Martin
I think we can

free(image_support):
image_suppot = NULL;

 right after the test

if (!*image_support) {
fprintf(stderr, "No image support\n");
free(image_support);
return PIGLIT_SKIP;
}

that would avoid the need to add it in every PIGLIT_FAIL return;

Serge

On Monday 16 November 2015 23:48:14 Vinson Lee wrote:
> Fixes Coverity "resource leak" defects.
> 
> Signed-off-by: Vinson Lee 
> ---
>  tests/cl/api/enqueue-fill-image.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/cl/api/enqueue-fill-image.c
> b/tests/cl/api/enqueue-fill-image.c index ebcfba4..994ccb4 100644
> --- a/tests/cl/api/enqueue-fill-image.c
> +++ b/tests/cl/api/enqueue-fill-image.c
> @@ -129,12 +129,14 @@ piglit_cl_test(const int argc,
>   if(!piglit_cl_check_error(err, CL_SUCCESS)) {
>   fprintf(stderr, "Failed (error code: %s): Creating an image\n",
>   piglit_cl_get_error_name(err));
> + free(image_support);
>   return PIGLIT_FAIL;
>   }
> 
>   if (!test(queue, image, pattern, origin, region,
> 0, NULL, NULL,
> CL_SUCCESS, , "Enqueuing the image to be filled")) {
> + free(image_support);
>   return PIGLIT_FAIL;
>   }
> 
> @@ -145,6 +147,7 @@ piglit_cl_test(const int argc,
>   if(!piglit_cl_check_error(err, CL_SUCCESS)) {
>   fprintf(stderr, "Failed (error code: %s): Reading image\n",
>   piglit_cl_get_error_name(err));
> + free(image_support);
>   return PIGLIT_FAIL;
>   }
> 
> @@ -169,6 +172,7 @@ piglit_cl_test(const int argc,
>   if (!piglit_cl_probe_integer(dst_buf[i], exp_buf[i], 0)) {
>   fprintf(stderr, "Error at %d: got %d, expected %d\n",
>   i, dst_buf[i], exp_buf[i]);
> + free(image_support);
>   return PIGLIT_FAIL;
>   }
>   }

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl-api-create-context: Remove unused variables.

2015-10-26 Thread Serge Martin
On Thursday 22 October 2015 22:46:27 Vinson Lee wrote:
> create-context.c:141:15: warning: unused variable 'num_platform_ids'
> [-Wunused-variable] unsigned int num_platform_ids;
>  ^
> create-context.c:139:7: warning: unused variable 'found_invalid_platform'
> [-Wunused-variable] bool found_invalid_platform = false;
>  ^
> create-context.c:140:18: warning: unused variable 'platform_ids'
> [-Wunused-variable] cl_platform_id* platform_ids;
> ^
> 
> Signed-off-by: Vinson Lee <v...@freedesktop.org>

Reviewed-by: Serge Martin <edb+pig...@sigluy.net>

> ---
>  tests/cl/api/create-context.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/tests/cl/api/create-context.c b/tests/cl/api/create-context.c
> index 551f8a2..4999bbf 100644
> --- a/tests/cl/api/create-context.c
> +++ b/tests/cl/api/create-context.c
> @@ -136,9 +136,6 @@ piglit_cl_test(const int argc,
>   cl_device_id* devices;
>   cl_context cl_ctx;
> 
> - bool found_invalid_platform = false;
> - cl_platform_id* platform_ids;
> - unsigned int num_platform_ids;
>   cl_platform_id invalid_platform_id = NULL;
> 
>   //TODO: test also CL_CONTEXT_INTEROP_USER_SYNC

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] cl: improve clLinkProgram

2015-10-04 Thread Serge Martin
  skip the test if there is no linker available
  fix CL_LINKER_NOT_AVAILABLE detection by testing device one by one
  print the build log in case of error
---
 tests/cl/api/link-program.c | 38 +++---
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/tests/cl/api/link-program.c b/tests/cl/api/link-program.c
index e98f428..75896d6 100644
--- a/tests/cl/api/link-program.c
+++ b/tests/cl/api/link-program.c
@@ -51,10 +51,10 @@ PIGLIT_CL_API_TEST_CONFIG_END
 
 
 const char* strings[] = {
-   "int get_number() { return 42; }",
+   "int get_number() { return 42; }\n",
"int get_number();\n",
-   "kernel void test_kernel() { int i = get_number(); }",
-   "int get_number() { return 0; }"
+   "kernel void test_kernel() { int i = get_number(); }\n",
+   "int get_number() { return 0; }\n"
 };
 
 #if defined(CL_VERSION_1_2)
@@ -87,8 +87,16 @@ compile_program(cl_context context,
   NULL, NULL);
 
if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   int i;
fprintf(stderr, "Failed (error code: %s): Compile program (for 
the %s).\n",
piglit_cl_get_error_name(errNo), err_str);
+
+   for(i = 0; i < num_devices; ++i) {
+   char *build_log = 
piglit_cl_get_program_build_info(program, device_list[i], CL_PROGRAM_BUILD_LOG);
+   fprintf(stderr, "Build log:\n%s\n", build_log);
+   free(build_log);
+   }
+
clReleaseProgram(program);
return NULL;
}
@@ -143,6 +151,7 @@ piglit_cl_test(const int argc,
 #if defined(CL_VERSION_1_2)
enum piglit_result result = PIGLIT_PASS;
 
+   bool linker_available;
int i;
cl_program_binary_type* binary_type;
cl_program compiled_programs[2];
@@ -150,6 +159,21 @@ piglit_cl_test(const int argc,
cl_program kernel_prog;
cl_program linked_prog;
 
+   linker_available = false;
+   for(i = 0; i < env->context->num_devices; ++i) {
+   cl_bool* dev_linker =
+   piglit_cl_get_device_info(env->context->device_ids[i],
+ CL_DEVICE_LINKER_AVAILABLE);
+
+   if (*dev_linker)
+   linker_available |= true;
+
+   free(dev_linker);
+   }
+
+   if (!linker_available)
+   return PIGLIT_SKIP;
+
/* Create compiled program */
function_prog = compile_program(env->context->cl_ctx,
env->context->num_devices, 
env->context->device_ids,
@@ -332,12 +356,12 @@ piglit_cl_test(const int argc,
 * for param_name for clGetDeviceInfo is set to CL_FALSE.
 */
for(i = 0; i < env->context->num_devices; ++i) {
-   cl_bool* linker_available =
+   cl_bool* dev_linker =
piglit_cl_get_device_info(env->context->device_ids[i],
  CL_DEVICE_LINKER_AVAILABLE);
-   if(!(*linker_available)) {
+   if(!(*dev_linker)) {
test(env->context->cl_ctx,
-env->context->num_devices, 
env->context->device_ids,
+1, >context->device_ids[i],
 "",
 2, compiled_programs,
 NULL, NULL,
@@ -345,7 +369,7 @@ piglit_cl_test(const int argc,
 CL_LINKER_NOT_AVAILABLE, ,
 "Trigger CL_LINKER_NOT_AVAILABLE if a 
linker is not available");
}
-   free(linker_available);
+   free(dev_linker);
}
 
 
-- 
2.5.2

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] cl: add printf builtin

2015-09-30 Thread Serge Martin
---
 tests/cl/program/build/printf.cl | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 tests/cl/program/build/printf.cl

diff --git a/tests/cl/program/build/printf.cl b/tests/cl/program/build/printf.cl
new file mode 100644
index 000..85ec712
--- /dev/null
+++ b/tests/cl/program/build/printf.cl
@@ -0,0 +1,9 @@
+/*!
+[config]
+name: printf builtin
+clc_version_min: 12
+!*/
+
+kernel void test_printf() {
+   printf("%s\n", "test_printf");
+}
-- 
2.5.2

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] cl: add popcount builtin

2015-09-30 Thread Serge Martin
---
 generated_tests/gen_cl_int_builtins.py | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/generated_tests/gen_cl_int_builtins.py 
b/generated_tests/gen_cl_int_builtins.py
index b94e118..03848f0 100644
--- a/generated_tests/gen_cl_int_builtins.py
+++ b/generated_tests/gen_cl_int_builtins.py
@@ -50,6 +50,7 @@ CLC_VERSION_MIN = {
 'rotate': 10,
 'sub_sat': 10,
 'upsample': 10,
+'popcount': 12,
 'mad24': 10,
 'mul24': 10
 }
@@ -83,6 +84,8 @@ def clz(type, val):
 count = count + 1
 return DATA_SIZES[type] - count
 
+def popcount(val):
+return bin(val).count('1')
 
 def div(val1, val2):
 return val1 // val2
@@ -104,10 +107,6 @@ def mul_hi(x, y, type):
 res = (x*y) >> DATA_SIZES[type]
 return res
 
-# def pop(val,type):
-# # TODO: Calculate number of non-zero bits in value (CLC 1.2)
-# return 0
-
 
 def pow(val, pow):
 return val ** pow
@@ -298,6 +297,17 @@ generic_tests = {
 [1, 1,  MAX, 0,   0, 1],
 [0, 1, UMAX, 0, MAX, 7]
 ]
+},
+'popcount': {
+'arg_types': [T, T],
+'function_type': 'ttt',
+'values': [
+[[popcount,   1],
+ [popcount,   3],
+ [popcount,   0],
+ [popcount, MAX],
+ [popcount, MIN]],
+[1, 3, 0, MAX, MIN]]
 }
 }
 
-- 
2.5.2

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2] cl: add clEnqueueFillImage

2015-09-29 Thread Serge Martin
Hello

I think I will push it in a few days if no one objects

On Saturday 12 September 2015 16:37:04 Serge Martin wrote:
> ---
> It' a little more than a ping so here is a v2.
> Since amdocl and pocl failed to pass the test (they even crash)
> I expend some of them to be more explicty about the error.
> 
> Also it have rebased so it will easier to apply
> 
> 
>  tests/cl.py   |   1 +
>  tests/cl/api/CMakeLists.cl.txt|   1 +
>  tests/cl/api/enqueue-fill-image.c | 334
> ++ 3 files changed, 336 insertions(+)
>  create mode 100644 tests/cl/api/enqueue-fill-image.c
> 
> diff --git a/tests/cl.py b/tests/cl.py
> index 161558b..34cf536 100644
> --- a/tests/cl.py
> +++ b/tests/cl.py
> @@ -59,6 +59,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
>  g(['cl-api-enqueue-read_write-buffer'],
>'clEnqueueReadBuffer and clEnqueueWriteBuffer')
>  g(['cl-api-enqueue-fill-buffer'], 'clEnqueueFillBuffer')
> +g(['cl-api-enqueue-fill-image'], 'clEnqueueFillImage')
>  g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
>  g(['cl-api-get-image-info'], 'clGetImageInfo')
>  g(['cl-api-retain_release-mem-object'],
> diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
> index 4a90c58..73ccbe3 100644
> --- a/tests/cl/api/CMakeLists.cl.txt
> +++ b/tests/cl/api/CMakeLists.cl.txt
> @@ -22,6 +22,7 @@ piglit_cl_add_api_test (enqueue-map-buffer
> enqueue-map-buffer.c) piglit_cl_add_api_test (enqueue-copy-buffer-rect
> enqueue-copy-buffer-rect.c) piglit_cl_add_api_test
> (enqueue-read_write-buffer enqueue-read_write-buffer.c)
> piglit_cl_add_api_test (enqueue-fill-buffer enqueue-fill-buffer.c)
> +piglit_cl_add_api_test (enqueue-fill-image enqueue-fill-image.c)
>  piglit_cl_add_api_test (retain_release-mem-object
> retain_release-mem-object.c) piglit_cl_add_api_test (get-mem-object-info
> get-mem-object-info.c) piglit_cl_add_api_test (get-image-info
> get-image-info.c)
> diff --git a/tests/cl/api/enqueue-fill-image.c
> b/tests/cl/api/enqueue-fill-image.c new file mode 100644
> index 000..ebcfba4
> --- /dev/null
> +++ b/tests/cl/api/enqueue-fill-image.c
> @@ -0,0 +1,334 @@
> +/*
> + * Copyright © 2015 Serge Martin <edb+pig...@sigluy.net>
> + *
> + * 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 (including the
> next + * paragraph) shall be included in all copies or substantial portions
> of the + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
> IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * @file enqueue-fill-image.c
> + *
> + * Test API function:
> + *
> + *   cl_int
> + *   clEnqueueFillImage(cl_command_queue command_queue, cl_mem image,
> + *  const void *fill_color, size_t *origin, size_t
> *region + *  cl_uint num_events_in_wait_list,
> + *  const cl_event *event_wait_list,
> + *  cl_event *event )
> + */
> +
> +#include "piglit-framework-cl-api.h"
> +
> +
> +PIGLIT_CL_API_TEST_CONFIG_BEGIN
> +
> + config.name = "clEnqueueFillImage";
> + config.version_min = 12;
> +
> + config.run_per_device = true;
> + config.create_context = true;
> +
> +PIGLIT_CL_API_TEST_CONFIG_END
> +
> +
> +#if defined(CL_VERSION_1_2)
> +static bool
> +test(cl_command_queue queue, cl_mem image,
> + const void *fill_color, size_t *origin, size_t *region,
> + cl_uint num_events_in_wait_list,
> + const cl_event *event_wait_list,
> + cl_event *event,
> + cl_int expected_error, enum piglit_result* result,
> + const char* test_str) {
> + cl_int errNo;
> +
> + errNo = clEnqueueFillImage(queue, image,
> +  

[Piglit] [PATCH] cl: add clGetExtensionFunctionAddressForPlatform

2015-09-27 Thread Serge Martin
---
 tests/cl/api/CMakeLists.cl.txt |   1 +
 .../get-extension-function-address-for-platform.c  | 121 +
 2 files changed, 122 insertions(+)
 create mode 100644 tests/cl/api/get-extension-function-address-for-platform.c

diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index 4a90c58..99303d9 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -7,6 +7,7 @@ piglit_cl_add_api_test (create-context create-context.c)
 piglit_cl_add_api_test (create-context-from-type create-context-from-type.c)
 piglit_cl_add_api_test (get-context-info get-context-info.c)
 piglit_cl_add_api_test (retain_release-context retain_release-context.c)
+piglit_cl_add_api_test (get-extension-function-address-for-platform 
get-extension-function-address-for-platform.c)
 
 # Command queues
 piglit_cl_add_api_test (create-command-queue create-command-queue.c)
diff --git a/tests/cl/api/get-extension-function-address-for-platform.c 
b/tests/cl/api/get-extension-function-address-for-platform.c
new file mode 100644
index 000..e53a429
--- /dev/null
+++ b/tests/cl/api/get-extension-function-address-for-platform.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2015 Serge Martin <edb+pig...@sigluy.net>
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file get-extension-function-address-for-platform.c
+ *
+ * Test API function:
+ *
+ *   void *
+ *   clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
+ *const char *funcname)
+ */
+
+#include "piglit-framework-cl-api.h"
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = "clGetExtensionFunctionAddressForPlatform";
+   config.version_min = 12;
+
+   config.run_per_platform = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined(CL_VERSION_1_2)
+   enum piglit_result result = PIGLIT_PASS;
+
+   size_t pos;
+   size_t last_pos;
+   void *ptr;
+   char *exts_list = piglit_cl_get_platform_info(env->platform_id,
+ CL_PLATFORM_EXTENSIONS);
+
+   if(!exts_list) {
+   fprintf(stderr, "clGetPlatformInfo error.\n");
+   return PIGLIT_FAIL;
+   }
+
+   printf("extensions list: %s\n", exts_list);
+
+   /*** Normal usage ***/
+
+   last_pos = 0;
+   pos = strcspn(exts_list + last_pos, " ");
+   while (pos) {
+   char *extension = NULL;
+   char *function_name = NULL;
+   ptr = NULL;
+
+   if (strncmp(exts_list + last_pos, "cl_khr_icd", pos) == 0) {
+   extension = "cl_khr_icd";
+   function_name = "clIcdGetPlatformIDsKHR";
+   }
+
+   if (function_name) {
+   printf("%s: %s\n", extension, function_name);
+   ptr = 
clGetExtensionFunctionAddressForPlatform(env->platform_id,
+function_name);
+   if (!ptr) {
+   fprintf(stderr, "Failed to get %s address\n",
+   function_name);
+   piglit_merge_result(, PIGLIT_FAIL);
+   }
+   }
+
+   last_pos += pos + 1;
+   pos = strcspn(exts_list + last_pos, " ");
+   }
+
+   /*** Errors ***/
+
+   /* clIcdGetPlatformIDsKHR is present in most of OpenCL 1.2 libs */
+   ptr = clG

[Piglit] [PATCH v2] cl: add clEnqueueMigrateMemObjects

2015-09-27 Thread Serge Martin
v2: (Jan Vesely comments)
  Remove extra whitespace
  Single flag test cases

Reviewed-by: Jan Vesely <jan.ves...@rutgers.edu>
---
 tests/cl.py|   1 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 tests/cl/api/enqueue-migrate-mem-objects.c | 244 +
 3 files changed, 246 insertions(+)
 create mode 100644 tests/cl/api/enqueue-migrate-mem-objects.c

diff --git a/tests/cl.py b/tests/cl.py
index 161558b..046aa87 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -59,6 +59,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
 g(['cl-api-enqueue-fill-buffer'], 'clEnqueueFillBuffer')
+g(['cl-api-enqueue-migrate-mem-objects'], 'clEnqueueMigrateMemObjects')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index 4a90c58..4de6763 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -22,6 +22,7 @@ piglit_cl_add_api_test (enqueue-map-buffer 
enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
 piglit_cl_add_api_test (enqueue-fill-buffer enqueue-fill-buffer.c)
+piglit_cl_add_api_test (enqueue-migrate-mem-objects 
enqueue-migrate-mem-objects.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-migrate-mem-objects.c 
b/tests/cl/api/enqueue-migrate-mem-objects.c
new file mode 100644
index 000..f0bc71b
--- /dev/null
+++ b/tests/cl/api/enqueue-migrate-mem-objects.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright © 2015 Serge Martin <edb+pig...@sigluy.net>
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-migrate-mem-objects.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueMigrateMemObjects(cl_command_queue command_queue,
+ *  cl_uint num_mem_objects,
+ *  const cl_mem *mem_objects,
+ *  cl_mem_migration_flags flags,
+ *  cl_uint num_events_in_wait_list,
+ *  const cl_event *event_wait_list,
+ *  cl_event *event)
+ */
+
+#include "piglit-framework-cl-api.h"
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = "clEnqueueMigrateMemObjects";
+   config.version_min = 12;
+
+   config.run_per_platform = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_uint num_mem_objects,
+ const cl_mem *mem_objects, cl_mem_migration_flags flags,
+ cl_uint num_events_in_wait_list, const cl_event *event_wait_list,
+ cl_event *event,
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueMigrateMemObjects(queue, num_mem_objects,
+  mem_objects, flags,
+  num_events_in_wait_list,
+  event_wait_list,
+  event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, "Failed (error code: %s): %s.\n",
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);

Re: [Piglit] [PATCH] cl: add clEnqueueMigrateMemObjects

2015-09-18 Thread Serge Martin
On Thursday 17 September 2015 19:30:41 Jan Vesely wrote:
> On Sat, 2015-09-12 at 14:53 +0200, Serge Martin wrote:
> > On Thursday 13 August 2015 23:14:23 Serge Martin wrote:
> > 
> > 
> > Please note that I will made those changes :
> > 
> > s/Migrating the buffer./Migrating the buffer/
> > s/Migrating the buffer with flag./Migrating the buffer with flag/
> > 
> > in order to remove the extra dot printed in case of error for the
> > normal case.
> > 
> > With this, can I get a R-b ?
> > 
> > > ---
> > > 
> > >  tests/cl.py|   1 +
> > >  tests/cl/api/CMakeLists.cl.txt |   1 +
> > >  tests/cl/api/enqueue-migrate-mem-objects.c | 227
> > > 
> > > +
> > > 
> > >  3 files changed, 229 insertions(+)
> > >  create mode 100644 tests/cl/api/enqueue-migrate-mem-objects.c
> > > 
> > > diff --git a/tests/cl.py b/tests/cl.py
> > > index 4668ddc..07f5fd4 100644
> > > --- a/tests/cl.py
> > > +++ b/tests/cl.py
> > > @@ -58,6 +58,7 @@ with profile.group_manager(PiglitCLTest, 'api')
> > > 
> > > as g:
> > >  g(['cl-api-enqueue-copy-buffer-rect'],
> > > 
> > > 'clEnqueueCopyBufferRect')
> > > 
> > >  g(['cl-api-enqueue-read_write-buffer'],
> > >  
> > >'clEnqueueReadBuffer and clEnqueueWriteBuffer')
> > > 
> > > +g(['enqueue-migrate-mem-objects'],
> > > 'clEnqueueMigrateMemObjects')
> > > 
> > >  g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
> > >  g(['cl-api-get-image-info'], 'clGetImageInfo')
> > >  g(['cl-api-retain_release-mem-object'],
> > > 
> > > diff --git a/tests/cl/api/CMakeLists.cl.txt
> > > b/tests/cl/api/CMakeLists.cl.txt
> > > index b598528..939f1f3 100644
> > > --- a/tests/cl/api/CMakeLists.cl.txt
> > > +++ b/tests/cl/api/CMakeLists.cl.txt
> > > @@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer
> > > enqueue-copy-buffer.c)
> > > 
> > >  piglit_cl_add_api_test (enqueue-map-buffer enqueue-map-buffer.c)
> > >  piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy
> > > 
> > > -buffer-rect.c)
> > > 
> > >  piglit_cl_add_api_test (enqueue-read_write-buffer enqueue
> > > 
> > > -read_write-buffer.c)
> > > +piglit_cl_add_api_test (enqueue-migrate-mem-objects enqueue
> > > -migrate-mem-objects.c)
> > > 
> > >  piglit_cl_add_api_test (retain_release-mem-object retain_release
> > > 
> > > -mem-object.c)
> > > 
> > >  piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
> > >  piglit_cl_add_api_test (get-image-info get-image-info.c)
> > > 
> > > diff --git a/tests/cl/api/enqueue-migrate-mem-objects.c
> > > b/tests/cl/api/enqueue-migrate-mem-objects.c
> > > new file mode 100644
> > > index 000..eafadce
> > > --- /dev/null
> > > +++ b/tests/cl/api/enqueue-migrate-mem-objects.c
> > > @@ -0,0 +1,227 @@
> > > +/*
> > > + * Copyright © 2015 Serge Martin (EdB) <edb+pig...@sigluy.net>
> > > + *
> > > + * 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
> > > (including the next
> > > + * paragraph) shall be included in all copies or substantial
> > > portions of the
> > > + * Software.
> > > + *
> > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > > EXPRESS OR
> > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > > MERCHANTABILITY,
> > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> > > EVENT SHALL
> > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> > > DAMAGES OR OTHER
> > > + * LIABILI

Re: [Piglit] [PATCH 1/2] cl: Update integer limit tests to detect incorrect storage sizes

2015-09-15 Thread Serge Martin
On Thursday 10 September 2015 10:12:49 Aaron Watry wrote:
> The tests for the char/short/integer/long minimums do not properly
> check that the value is stored in the correct type.  E.g. (-32768)
> actually gets parsed as an int by the preprocessor, and INT_MIN is
> actually stored as a long.
> 
> By subtracting a vector with value of 0 from the given defined *_MIN
> and then grabbing the first element of the resulting vector, we can
> make sure that the values are actually stored in the correct type.

It puzzle me why a vector operation will raise an error. It's because CL is 
more strict than C
Could you please add something like that in the commit message (as explain in 
the llvm thread):

According to chapter 6.2.6  "Usual Arithmetic Conversions"
"An error shall occur if any scalar operand has greater rank than the type of 
the vector element."

In any case, the series is
Reviewed-by Serge Martin <edb+pig...@sigluy.net>

> 
> Reported-By: Moritz Pflanzer <moritz.pflanze...@imperial.ac.uk>
> Signed-off-by: Aaron Watry <awa...@gmail.com>
> ---
>  tests/cl/program/execute/int-definitions.cl | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/cl/program/execute/int-definitions.cl
> b/tests/cl/program/execute/int-definitions.cl index 011599d..3d8ee63 100644
> --- a/tests/cl/program/execute/int-definitions.cl
> +++ b/tests/cl/program/execute/int-definitions.cl
> @@ -36,29 +36,29 @@ kernel void test_char(global int* out) {
>int i = 0;
>out[i++] = CHAR_BIT;
>out[i++] = CHAR_MAX;
> -  out[i++] = CHAR_MIN;
> +  out[i++] = (CHAR_MIN - (char2)(0)).s0;
>out[i++] = SCHAR_MAX;
> -  out[i++] = SCHAR_MIN;
> +  out[i++] = (SCHAR_MIN - (char2)(0)).s0;
>out[i++] = UCHAR_MAX;
>  }
> 
>  kernel void test_short(global int* out) {
>int i = 0;
>out[i++] = SHRT_MAX;
> -  out[i++] = SHRT_MIN;
> +  out[i++] = (SHRT_MIN - (short2)(0)).s0;
>out[i++] = USHRT_MAX;
>  }
> 
>  kernel void test_int(global int* out) {
>int i = 0;
>out[i++] = INT_MAX;
> -  out[i++] = INT_MIN;
> +  out[i++] = (INT_MIN - (int2)(0)).s0;
>out[i++] = UINT_MAX;
>  }
> 
>  kernel void test_long(global long* out) {
>int i = 0;
>out[i++] = LONG_MAX;
> -  out[i++] = LONG_MIN;
> +  out[i++] = (LONG_MIN - (long2)(0)).s0;
>out[i++] = ULONG_MAX;
>  }

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2] cl: check values returned from clGetMemObjectInfo

2015-09-12 Thread Serge Martin
---
 tests/cl/api/get-mem-object-info.c | 285 -
 1 file changed, 246 insertions(+), 39 deletions(-)

diff --git a/tests/cl/api/get-mem-object-info.c 
b/tests/cl/api/get-mem-object-info.c
index c24b51d..2db3b6a 100644
--- a/tests/cl/api/get-mem-object-info.c
+++ b/tests/cl/api/get-mem-object-info.c
@@ -46,6 +46,142 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
+#define BUFFER_SIZE 512
+
+static enum piglit_result
+test_get_value(cl_mem memobj,
+   cl_mem_info param_name,
+   size_t *param_value_size,
+   void **param_value) {
+   cl_int errNo;
+
+   errNo = clGetMemObjectInfo(memobj,
+  param_name,
+  0,
+  NULL,
+  param_value_size);
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   "Failed (error code: %s): Get size of %s.\n",
+   piglit_cl_get_error_name(errNo),
+   piglit_cl_get_enum_name(param_name));
+   *param_value = NULL;
+   return PIGLIT_FAIL;
+   }
+
+   *param_value = malloc(*param_value_size);
+   errNo = clGetMemObjectInfo(memobj,
+  param_name,
+  *param_value_size,
+  *param_value,
+  NULL);
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   "Failed (error code: %s): Get value of %s.\n",
+   piglit_cl_get_error_name(errNo),
+   piglit_cl_get_enum_name(param_name));
+   free(*param_value);
+   *param_value = NULL;
+   return PIGLIT_FAIL;
+   }
+
+   return PIGLIT_PASS;
+}
+
+static enum piglit_result
+test(int n,
+ cl_mem memobj,
+ cl_mem_info param_name,
+ cl_mem_object_type mem_type,
+ cl_mem_flags mem_flags,
+ size_t mem_size,
+ void *mem_ptr,
+ const struct piglit_cl_api_test_env *env,
+ cl_mem mem_parent,
+ size_t mem_offset) {
+   size_t param_value_size;
+   void* param_value;
+
+   if (test_get_value(memobj,
+  param_name,
+  _value_size,
+  _value) != PIGLIT_PASS) {
+   fprintf(stderr,
+   "Buffer %d, test_get_value() failed.\n", n);
+   return PIGLIT_FAIL;
+   }
+
+#define CHECK_SIZE(_type_) \
+   if (param_value_size != sizeof(_type_)) { \
+   fprintf(stderr, \
+   "Buffer %d, failed: the returned size doesn't match. 
Expected %lu, got %lu\n", \
+   n, sizeof(_type_), param_value_size); \
+   return PIGLIT_FAIL; \
+   }
+
+#define CHECK_VALUE(_type_, _value_) \
+   if (*(_type_*)param_value != _value_) { \
+   fprintf(stderr, \
+   "Buffer %d, failed: the returned value doesn't 
match.\n", \
+   n); \
+   return PIGLIT_FAIL; \
+   }
+
+   switch (param_name) {
+   case CL_MEM_TYPE:
+   CHECK_SIZE(cl_mem_object_type)
+   CHECK_VALUE(cl_mem_object_type, mem_type)
+   break;
+   case CL_MEM_FLAGS:
+   CHECK_SIZE(cl_mem_flags)
+   CHECK_VALUE(cl_mem_flags, mem_flags)
+   break;
+   case CL_MEM_SIZE:
+   CHECK_SIZE(size_t)
+   CHECK_VALUE(size_t, mem_size)
+   break;
+   case CL_MEM_HOST_PTR:
+   CHECK_SIZE(void *)
+   CHECK_VALUE(void *, mem_ptr)
+   break;
+   case CL_MEM_MAP_COUNT:
+   CHECK_SIZE(cl_uint)
+   //stale
+   break;
+   case CL_MEM_REFERENCE_COUNT:
+   CHECK_SIZE(cl_uint)
+   //stale
+   break;
+   case CL_MEM_CONTEXT:
+   CHECK_SIZE(cl_context)
+   CHECK_VALUE(cl_context, env->context->cl_ctx)
+   break;
+#if defined(CL_VERSION_1_1)
+   case CL_MEM_ASSOCIATED_MEMOBJECT:
+   if (env->version >= 11) {
+   CHECK_SIZE(cl_mem)
+   CHECK_VALUE(cl_mem, mem_parent)
+   }
+   break;
+   case CL_MEM_OFFSET:
+   if (env->version >= 11) {
+   CHECK_SIZE(size_t)
+   CHECK_VALUE(size_t, mem_offset)
+   }
+

[Piglit] [PATCH v2] cl: add clEnqueueFillImage

2015-09-12 Thread Serge Martin
---
It' a little more than a ping so here is a v2.
Since amdocl and pocl failed to pass the test (they even crash)
I expend some of them to be more explicty about the error.

Also it have rebased so it will easier to apply


 tests/cl.py   |   1 +
 tests/cl/api/CMakeLists.cl.txt|   1 +
 tests/cl/api/enqueue-fill-image.c | 334 ++
 3 files changed, 336 insertions(+)
 create mode 100644 tests/cl/api/enqueue-fill-image.c

diff --git a/tests/cl.py b/tests/cl.py
index 161558b..34cf536 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -59,6 +59,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
 g(['cl-api-enqueue-fill-buffer'], 'clEnqueueFillBuffer')
+g(['cl-api-enqueue-fill-image'], 'clEnqueueFillImage')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index 4a90c58..73ccbe3 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -22,6 +22,7 @@ piglit_cl_add_api_test (enqueue-map-buffer 
enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
 piglit_cl_add_api_test (enqueue-fill-buffer enqueue-fill-buffer.c)
+piglit_cl_add_api_test (enqueue-fill-image enqueue-fill-image.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-fill-image.c 
b/tests/cl/api/enqueue-fill-image.c
new file mode 100644
index 000..ebcfba4
--- /dev/null
+++ b/tests/cl/api/enqueue-fill-image.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright © 2015 Serge Martin <edb+pig...@sigluy.net>
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-fill-image.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueFillImage(cl_command_queue command_queue, cl_mem image,
+ *  const void *fill_color, size_t *origin, size_t *region
+ *  cl_uint num_events_in_wait_list,
+ *  const cl_event *event_wait_list,
+ *  cl_event *event )
+ */
+
+#include "piglit-framework-cl-api.h"
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = "clEnqueueFillImage";
+   config.version_min = 12;
+
+   config.run_per_device = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_mem image,
+ const void *fill_color, size_t *origin, size_t *region,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event,
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueFillImage(queue, image,
+  fill_color, origin, region,
+  num_events_in_wait_list, event_wait_list,
+  event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, "Failed (error code: %s): %s.\n",
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   return true;
+}
+#endif
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,

[Piglit] [PATCH] cl: check value returned from clGetMemObjectInfo

2015-09-06 Thread Serge Martin (EdB)
From: Serge Martin <edb+pig...@sigluy.net>

---
 tests/cl/api/get-mem-object-info.c | 253 +++--
 1 file changed, 213 insertions(+), 40 deletions(-)

diff --git a/tests/cl/api/get-mem-object-info.c 
b/tests/cl/api/get-mem-object-info.c
index c24b51d..b68262c 100644
--- a/tests/cl/api/get-mem-object-info.c
+++ b/tests/cl/api/get-mem-object-info.c
@@ -46,6 +46,127 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
+#define BUFFER_SIZE 512
+
+static bool
+test(int n,
+ cl_mem memobj,
+ cl_mem_info param_name,
+ cl_mem_object_type mem_type,
+ cl_mem_flags mem_flags,
+ size_t mem_size,
+ void *mem_ptr,
+ const struct piglit_cl_api_test_env* env,
+ cl_mem mem_parent,
+ size_t mem_offset,
+ enum piglit_result* result) {
+   cl_int errNo;
+   size_t param_value_size;
+   void* param_value;
+
+   errNo = clGetMemObjectInfo(memobj,
+  param_name,
+  0,
+  NULL,
+  _value_size);
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   "Buffer %d, failed (error code: %s): Get size of %s.\n",
+   n,
+   piglit_cl_get_error_name(errNo),
+   piglit_cl_get_enum_name(param_name));
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   param_value = malloc(param_value_size);
+   errNo = clGetMemObjectInfo(memobj,
+  param_name,
+  param_value_size,
+  param_value,
+  NULL);
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   "Buffer %d, failed (error code: %s): Get value of 
%s.\n",
+   n,
+   piglit_cl_get_error_name(errNo),
+   piglit_cl_get_enum_name(param_name));
+   piglit_merge_result(result, PIGLIT_FAIL);
+   free(param_value);
+   return false;
+   }
+
+#define CHECK_SIZE(_type_) \
+   if (param_value_size != sizeof(_type_)) { \
+   fprintf(stderr, \
+   "Buffer %d, failed: the returned size doesn't matches. 
Expected %lu, got %lu\n", \
+   n, sizeof(_type_), param_value_size); \
+   piglit_merge_result(result, PIGLIT_FAIL); \
+   }
+
+#define CHECK_VALUE(_type_, _value_) \
+   if (*(_type_*)param_value != _value_) { \
+   fprintf(stderr, \
+   "Buffer %d, failed: the returned value doesn't 
matches.\n", \
+   n); \
+   piglit_merge_result(result, PIGLIT_FAIL); \
+   }
+
+   switch (param_name) {
+   case CL_MEM_TYPE:
+   CHECK_SIZE(cl_mem_object_type)
+   CHECK_VALUE(cl_mem_object_type, mem_type)
+   break;
+   case CL_MEM_FLAGS:
+   CHECK_SIZE(cl_mem_flags)
+   CHECK_VALUE(cl_mem_flags, mem_flags)
+   break;
+   case CL_MEM_SIZE:
+   CHECK_SIZE(size_t)
+   CHECK_VALUE(size_t, mem_size)
+   break;
+   case CL_MEM_HOST_PTR:
+   CHECK_SIZE(void *)
+   CHECK_VALUE(void *, mem_ptr)
+   break;
+   case CL_MEM_MAP_COUNT:
+   CHECK_SIZE(cl_uint)
+   //stale
+   break;
+   case CL_MEM_REFERENCE_COUNT:
+   CHECK_SIZE(cl_uint)
+   //stale
+   break;
+   case CL_MEM_CONTEXT:
+   CHECK_SIZE(cl_context)
+   CHECK_VALUE(cl_context, env->context->cl_ctx)
+   break;
+#if defined(CL_VERSION_1_1)
+   case CL_MEM_ASSOCIATED_MEMOBJECT:
+   if (env->version >= 11) {
+   CHECK_SIZE(cl_mem)
+   CHECK_VALUE(cl_mem, mem_parent)
+   }
+   break;
+   case CL_MEM_OFFSET:
+   if (env->version >= 11) {
+   CHECK_SIZE(size_t)
+   CHECK_VALUE(size_t, mem_offset)
+   }
+   break;
+#endif
+   default:
+   fprintf(stderr, "Warn: untested parameter %s\n",
+   piglit_cl_get_enum_name(param_name));
+   piglit_merge_resul

Re: [Piglit] [PATCH v5] cl: add clEnqueue-read_write BufferRect releated tests

2015-08-18 Thread Serge Martin (EdB)
Hello

I was about to push it, be find that some of the errors tests return CL_SUCCESS 
when they shouldn't have, sorry about that.
Does this test pass on INTEL OCL?

See comments below

On Monday 03 August 2015 01:59:44 Meng Mengmeng wrote:
 It's a simple function test for clEnqueueReadBufferRect and
 clEnqueueWriteBufferRect.
 ---
  tests/cl.py   |   2 +
  tests/cl/api/CMakeLists.cl.txt|   1 +
  tests/cl/api/enqueue-read_write-buffer-rect.c | 338
 ++ 3 files changed, 341 insertions(+)
  create mode 100644 tests/cl/api/enqueue-read_write-buffer-rect.c
 
 diff --git a/tests/cl.py b/tests/cl.py
 index 4668ddc..572ccdc 100644
 --- a/tests/cl.py
 +++ b/tests/cl.py
 @@ -58,6 +58,8 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
  g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
  g(['cl-api-enqueue-read_write-buffer'],
'clEnqueueReadBuffer and clEnqueueWriteBuffer')
 +g(['cl-api-enqueue-read_write-buffer-rect'],
 +  'clEnqueueReadBufferRect and clEnqueueWriteBufferRect')
  g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
  g(['cl-api-get-image-info'], 'clGetImageInfo')
  g(['cl-api-retain_release-mem-object'],
 diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
 index b598528..f0a388f 100644
 --- a/tests/cl/api/CMakeLists.cl.txt
 +++ b/tests/cl/api/CMakeLists.cl.txt
 @@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer
 enqueue-copy-buffer.c) piglit_cl_add_api_test (enqueue-map-buffer
 enqueue-map-buffer.c)
  piglit_cl_add_api_test (enqueue-copy-buffer-rect
 enqueue-copy-buffer-rect.c) piglit_cl_add_api_test
 (enqueue-read_write-buffer enqueue-read_write-buffer.c)
 +piglit_cl_add_api_test (enqueue-read_write-buffer-rect
 enqueue-read_write-buffer-rect.c) piglit_cl_add_api_test
 (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
 diff --git a/tests/cl/api/enqueue-read_write-buffer-rect.c
 b/tests/cl/api/enqueue-read_write-buffer-rect.c new file mode 100644
 index 000..6f7d2ca
 --- /dev/null
 +++ b/tests/cl/api/enqueue-read_write-buffer-rect.c
 @@ -0,0 +1,338 @@
 +/*
 + * Copyright © 2015 Intel Corporation
 + *
 + * 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 (including the
 next + * paragraph) shall be included in all copies or substantial portions
 of the + * Software.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE.
 + *
 + * Authors: Meng Mengmeng mengmeng.meng at intel.com
 + *
 + */
 +
 +#include piglit-framework-cl-api.h
 +#include piglit-util-cl.h
 +
 +
 +PIGLIT_CL_API_TEST_CONFIG_BEGIN
 +
 + config.name = clEnqueueReadBufferRect and clEnqueueWriteBufferRect;
 + config.version_min = 11;
 +
 + config.run_per_platform = true;
 + config.create_context = true;
 +
 +PIGLIT_CL_API_TEST_CONFIG_END
 +
 +static bool
 +test_read_rect(cl_command_queue command_queue,
 +   cl_mem buffer,
 +   cl_bool blocking_read,
 +   const size_t * buffer_origin,
 +   const size_t * host_origin,
 +   const size_t * region,
 +   size_t buffer_row_pitch,
 +   size_t buffer_slice_pitch,
 +   size_t host_row_pitch,
 +   size_t host_slice_pitch,
 +   void *ptr,
 +   cl_uint num_events_in_wait_list,
 +   const cl_event *event_wait_list,
 +   cl_event *event,
 +   cl_int expected_error,
 +   enum piglit_result* result,
 +   const char* test_str) {
 + cl_int errNo;
 +
 + errNo = clEnqueueReadBufferRect(command_queue,
 + buffer,
 + blocking_read,
 + buffer_origin,
 + host_origin,
 + region,
 + 

Re: [Piglit] [PATCH] cl-api-get-kernel-work-group-info: Fix memory leak.

2015-08-18 Thread Serge Martin
Reviewed-by: Serge Martin (EdB) edb+pig...@sigluy.net

On Monday 17 August 2015 21:37:14 Vinson Lee wrote:
 Fix resource leak defect reported by Coverity.
 
 Signed-off-by: Vinson Lee v...@freedesktop.org
 ---
  tests/cl/api/get-kernel-work-group-info.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/tests/cl/api/get-kernel-work-group-info.c
 b/tests/cl/api/get-kernel-work-group-info.c index 5942e15..4a393c3 100644
 --- a/tests/cl/api/get-kernel-work-group-info.c
 +++ b/tests/cl/api/get-kernel-work-group-info.c
 @@ -94,6 +94,7 @@ piglit_cl_test(const int argc,
  piglit_cl_get_device_info(env-device_id, 
 CL_DEVICE_TYPE);
   if (*dev_type_ptr != CL_DEVICE_TYPE_CUSTOM)
   success_code = CL_INVALID_VALUE;
 + free(dev_type_ptr);
   }
  #endif

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] cl: fix invalid platform test in create-context

2015-08-14 Thread Serge Martin (EdB)
OpenCL objects are just pointers in the end, using random pointer value
is likely to make an application crash.
Also, all others tests use NULL as an invalid object.

See also Francisco Jerez comments:
http://lists.freedesktop.org/archives/mesa-dev/2014-November/070520.html
http://lists.freedesktop.org/archives/mesa-dev/2013-October/046830.html
---
 tests/cl/api/create-context.c | 16 +---
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/tests/cl/api/create-context.c b/tests/cl/api/create-context.c
index f4929f0..551f8a2 100644
--- a/tests/cl/api/create-context.c
+++ b/tests/cl/api/create-context.c
@@ -139,7 +139,7 @@ piglit_cl_test(const int argc,
bool found_invalid_platform = false;
cl_platform_id* platform_ids;
unsigned int num_platform_ids;
-   cl_platform_id invalid_platform_id;
+   cl_platform_id invalid_platform_id = NULL;
 
//TODO: test also CL_CONTEXT_INTEROP_USER_SYNC
cl_context_properties context_properties[] = {
@@ -160,20 +160,6 @@ piglit_cl_test(const int argc,
0
};
 
-   /* Find invalid platform_id */
-   invalid_platform_id = 0;
-   num_platform_ids = piglit_cl_get_platform_ids(platform_ids);
-   while(!found_invalid_platform) {
-   found_invalid_platform = true;
-   invalid_platform_id = (cl_platform_id)1;
-   for(i = 0; i  num_platform_ids; i++) {
-   if(invalid_platform_id == platform_ids[i]) {
-   found_invalid_platform = false;
-   break;
-   }
-   }
-   }
-   free(platform_ids);
invalid_platform_context_properties[1] =
(cl_context_properties)invalid_platform_id;
 
-- 
2.5.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] cl: add clEnqueueMigrateMemObjects

2015-08-13 Thread Serge Martin (EdB)
---
 tests/cl.py|   1 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 tests/cl/api/enqueue-migrate-mem-objects.c | 227 +
 3 files changed, 229 insertions(+)
 create mode 100644 tests/cl/api/enqueue-migrate-mem-objects.c

diff --git a/tests/cl.py b/tests/cl.py
index 4668ddc..07f5fd4 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -58,6 +58,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
+g(['enqueue-migrate-mem-objects'], 'clEnqueueMigrateMemObjects')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index b598528..939f1f3 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer 
enqueue-copy-buffer.c)
 piglit_cl_add_api_test (enqueue-map-buffer enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
+piglit_cl_add_api_test (enqueue-migrate-mem-objects 
enqueue-migrate-mem-objects.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-migrate-mem-objects.c 
b/tests/cl/api/enqueue-migrate-mem-objects.c
new file mode 100644
index 000..eafadce
--- /dev/null
+++ b/tests/cl/api/enqueue-migrate-mem-objects.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright © 2015 Serge Martin (EdB) edb+pig...@sigluy.net
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-migrate-mem-objects.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueMigrateMemObjects(cl_command_queue command_queue,
+ *  cl_uint num_mem_objects,
+ *  const cl_mem *mem_objects,
+ *  cl_mem_migration_flags flags,
+ *  cl_uint num_events_in_wait_list,
+ *  const cl_event *event_wait_list,
+ *  cl_event *event)
+ */
+
+#include piglit-framework-cl-api.h
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = clEnqueueMigrateMemObjects;
+   config.version_min = 12;
+
+   config.run_per_platform = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_uint num_mem_objects,
+ const cl_mem *mem_objects, cl_mem_migration_flags flags,
+ cl_uint num_events_in_wait_list, const cl_event *event_wait_list,
+ cl_event *event, 
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueMigrateMemObjects(queue, num_mem_objects,
+  mem_objects, flags,
+  num_events_in_wait_list,
+  event_wait_list,
+  event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, Failed (error code: %s): %s.\n,
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   return true;
+}
+#endif
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct

[Piglit] [PATCH] cl: add clEnqueueFillImage

2015-08-11 Thread Serge Martin (EdB)
---
 tests/cl.py   |   1 +
 tests/cl/api/CMakeLists.cl.txt|   1 +
 tests/cl/api/enqueue-fill-image.c | 297 ++
 3 files changed, 299 insertions(+)
 create mode 100644 tests/cl/api/enqueue-fill-image.c

diff --git a/tests/cl.py b/tests/cl.py
index 4668ddc..1680d29 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -58,6 +58,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
+g(['cl-api-enqueue-fill-image'], 'clEnqueueFillImage')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index b598528..2d55e23 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer 
enqueue-copy-buffer.c)
 piglit_cl_add_api_test (enqueue-map-buffer enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
+piglit_cl_add_api_test (enqueue-fill-image enqueue-fill-image.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-fill-image.c 
b/tests/cl/api/enqueue-fill-image.c
new file mode 100644
index 000..479475d
--- /dev/null
+++ b/tests/cl/api/enqueue-fill-image.c
@@ -0,0 +1,297 @@
+/*
+ * Copyright © 2015 Serge Martin (EdB) edb+pig...@sigluy.net
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-fill-image.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueFillImage(cl_command_queue command_queue, cl_mem image,
+ *  const void *fill_color, size_t *origin, size_t *region
+ *  cl_uint num_events_in_wait_list,
+ *  const cl_event *event_wait_list,
+ *  cl_event *event )
+ */
+
+#include piglit-framework-cl-api.h
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = clEnqueueFillImage;
+   config.version_min = 12;
+
+   config.run_per_device = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_mem image,
+ const void *fill_color, size_t *origin, size_t *region,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event,
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueFillImage(queue, image,
+  fill_color, origin, region,
+  num_events_in_wait_list, event_wait_list,
+  event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, Failed (error code: %s): %s.\n,
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   return true;
+}
+#endif
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined(CL_VERSION_1_2)
+   enum piglit_result result = PIGLIT_PASS;
+   cl_int err;
+
+#define IMG_WIDTH 4
+#define IMG_HEIGHT 4
+#define IMG_DATA_SIZE 4
+#define IMG_BUFFER_SIZE IMG_WIDTH * IMG_HEIGHT

[Piglit] [PATCH] cl: add clGetKernelArgInfo

2015-08-11 Thread Serge Martin (EdB)
v2 and v3: modifications according Jan Vesely's comments
---
 tests/cl.py|   1 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 tests/cl/api/get-kernel-arg-info.c | 274 +
 tests/util/piglit-util-cl-enum.c   |  11 ++
 tests/util/piglit-util-cl-enum.h   |   3 +
 5 files changed, 290 insertions(+)
 create mode 100644 tests/cl/api/get-kernel-arg-info.c

diff --git a/tests/cl.py b/tests/cl.py
index 4668ddc..673b522 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -77,6 +77,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 # Kernel
 g(['cl-api-create-kernel'], 'clCreateKernel')
 g(['cl-api-create-kernels-in-program'], 'clCreateKernelsInProgram')
+g(['cl-api-get-kernel-arg-info'], 'clGetKernelArgInfo')
 g(['cl-api-get-kernel-info'], 'clGetKernelInfo')
 g(['cl-api-get-kernel-work-group-info'], 'clGetKernelWorkGroupInfo')
 g(['cl-api-retain_release-kernel'], 'clRetainKernel and clReleaseKernel')
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index b598528..4f2f268 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -42,6 +42,7 @@ piglit_cl_add_api_test (create-kernels-in-program 
create-kernels-in-program.c)
 piglit_cl_add_api_test (set-kernel-arg set-kernel-arg.c)
 piglit_cl_add_api_test (retain_release-kernel retain_release-kernel.c)
 piglit_cl_add_api_test (get-kernel-info get-kernel-info.c)
+piglit_cl_add_api_test (get-kernel-arg-info get-kernel-arg-info.c)
 piglit_cl_add_api_test (get-kernel-work-group-info 
get-kernel-work-group-info.c)
 
 # Events
diff --git a/tests/cl/api/get-kernel-arg-info.c 
b/tests/cl/api/get-kernel-arg-info.c
new file mode 100644
index 000..5f51cb2
--- /dev/null
+++ b/tests/cl/api/get-kernel-arg-info.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright © 2014 EdB edb+pig...@sigluy.net
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * copied from get-kernel-info.c
+ * Copyright © 2012 Blaž Tomažič blaz.toma...@gmail.com
+ */
+
+/**
+ * @file get-kernel-arg-info.c
+ *
+ * Test API function:
+ *
+ *   cl_int clGetKernelArgInfo (cl_kernel kernel,
+ *  cl_uint arg_indx,
+ *  cl_kernel_arg_info param_name,
+ *  size_t param_value_size,
+ *  void *param_value,
+ *  size_t *param_value_size_ret)
+ */
+
+#include piglit-framework-cl-api.h
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = clGetKernelArgInfo;
+   config.version_min = 12;
+
+   config.run_per_platform = true;
+   config.create_context = true;
+
+   config.program_source = kernel void dummy_kernel(int param_1) {};
+   config.build_options = -cl-kernel-arg-info;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char** argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined(CL_VERSION_1_2)
+   enum piglit_result result = PIGLIT_PASS;
+
+   int i;
+   cl_int errNo;
+   cl_kernel kernel;
+
+   size_t param_value_size;
+   size_t ret_value_size;
+   size_t expected_size;
+#define BUFFER_SIZE 8
+   char param_value[BUFFER_SIZE];
+
+   int num_kernel_arg_infos = PIGLIT_CL_ENUM_NUM(cl_kernel_arg_info, 
env-version);
+   const cl_kernel_arg_info* kernel_arg_infos = 
PIGLIT_CL_ENUM_ARRAY(cl_kernel_arg_info);
+
+   kernel = clCreateKernel(env-program,
+   dummy_kernel,
+   errNo);
+   if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+   fprintf(stderr,
+   Failed (error code: %s): Create kernel.\n,
+   piglit_cl_get_error_name(errNo));
+   return PIGLIT_FAIL;
+ 

[Piglit] [PATCH v2] cl: add clEnqueueFillBuffer

2015-08-11 Thread Serge Martin (EdB)
v2:
spaces/tabs formating
clReleaseMemObject the buffer

Reviewed-by: Tom Stellard thomas.stell...@amd.com
---
 tests/cl.py|   1 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 tests/cl/api/enqueue-fill-buffer.c | 270 +
 3 files changed, 272 insertions(+)
 create mode 100644 tests/cl/api/enqueue-fill-buffer.c

diff --git a/tests/cl.py b/tests/cl.py
index 4668ddc..6246ba1 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -58,6 +58,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
+g(['cl-api-enqueue-fill-buffer'], 'clEnqueueFillBuffer')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index b598528..0af42d1 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer 
enqueue-copy-buffer.c)
 piglit_cl_add_api_test (enqueue-map-buffer enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
+piglit_cl_add_api_test (enqueue-fill-buffer enqueue-fill-buffer.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-fill-buffer.c 
b/tests/cl/api/enqueue-fill-buffer.c
new file mode 100644
index 000..a77c422
--- /dev/null
+++ b/tests/cl/api/enqueue-fill-buffer.c
@@ -0,0 +1,270 @@
+/*
+ * Copyright © 2015 Serge Martin (EdB) edb+pig...@sigluy.net
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-fill-buffer.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueFillBuffer(cl_command_queue command_queue, cl_mem buffer,
+ *   const void *pattern, size_t pattern_size,
+ *   size_t offset, size_t size,
+ *   cl_uint num_events_in_wait_list,
+ *   const cl_event *event_wait_list,
+ *   cl_event *event )
+ */
+
+#include piglit-framework-cl-api.h
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = clEnqueueFillBuffer;
+   config.version_min = 12;
+
+   config.run_per_device = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_mem buffer,
+ const void *pattern, size_t pattern_size,
+ size_t offset, size_t size,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event ,
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueFillBuffer(queue, buffer,
+   pattern, pattern_size, offset, size,
+   num_events_in_wait_list, event_wait_list,
+   event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, Failed (error code: %s): %s.\n,
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   return true;
+}
+#endif
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined

Re: [Piglit] [PATCH v2] cl: add clGetKernelArgInfo

2015-08-10 Thread Serge Martin
On Sunday 09 August 2015 17:58:11 Jan Vesely wrote:
 On Sun, 2015-08-09 at 17:17 -0500, Jan Vesely wrote:
  On Sun, 2015-08-02 at 00:54 +0200, EdB wrote:
   ---
   
tests/cl.py|   1 +
tests/cl/api/CMakeLists.cl.txt |   1 +
tests/cl/api/get-kernel-arg-info.c | 281
   
   +
   
tests/util/piglit-util-cl-enum.c   |  11 ++
tests/util/piglit-util-cl-enum.h   |   1 +
5 files changed, 295 insertions(+)
create mode 100644 tests/cl/api/get-kernel-arg-info.c
   
   diff --git a/tests/cl.py b/tests/cl.py
   index c55d3dd..53153e8 100644
   --- a/tests/cl.py
   +++ b/tests/cl.py
   @@ -76,6 +76,7 @@ with profile.group_manager(PiglitCLTest, 'api')
   as
   
   g:
# Kernel
g(['cl-api-create-kernel'], 'clCreateKernel')
g(['cl-api-create-kernels-in-program'],
   
   'clCreateKernelsInProgram')
   +g(['cl-api-get-kernel-arg-info'], 'clGetKernelArgInfo')
   
g(['cl-api-get-kernel-info'], 'clGetKernelInfo')
g(['cl-api-get-kernel-work-group-info'],
   
   'clGetKernelWorkGroupInfo')
   
g(['cl-api-retain_release-kernel'], 'clRetainKernel and
   
   clReleaseKernel')
   diff --git a/tests/cl/api/CMakeLists.cl.txt
   b/tests/cl/api/CMakeLists.cl.txt
   index 7e78491..3082411 100644
   --- a/tests/cl/api/CMakeLists.cl.txt
   +++ b/tests/cl/api/CMakeLists.cl.txt
   @@ -41,6 +41,7 @@ piglit_cl_add_api_test (create-kernels-in-program
   create-kernels-in-program.c)
   
piglit_cl_add_api_test (set-kernel-arg set-kernel-arg.c)
piglit_cl_add_api_test (retain_release-kernel retain_release
   
   -kernel.c)
   
piglit_cl_add_api_test (get-kernel-info get-kernel-info.c)
   
   +piglit_cl_add_api_test (get-kernel-arg-info get-kernel-arg-info.c)
   
piglit_cl_add_api_test (get-kernel-work-group-info get-kernel-work
   
   -group-info.c)
   
# Events
   
   diff --git a/tests/cl/api/get-kernel-arg-info.c b/tests/cl/api/get
   -kernel-arg-info.c
   new file mode 100644
   index 000..147e7d8
   --- /dev/null
   +++ b/tests/cl/api/get-kernel-arg-info.c
   @@ -0,0 +1,280 @@
   +/*
   + * Copyright © 2014 EdB edb+pig...@sigluy.net
   + *
   + * 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
   (including
   the next
   + * paragraph) shall be included in all copies or substantial
   portions of the
   + * Software.
   + *
   + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR
   + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY,
   + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
   EVENT SHALL
   + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES
   OR OTHER
   + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   ARISING
   + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   OTHER
   + * DEALINGS IN THE SOFTWARE.
   + *
   + * copied from get-kernel-info.c
   + * Copyright © 2012 Blaž Tomažič blaz.toma...@gmail.com
   + */
   +
   +/**
   + * @file get-kernel-arg-info.c
   + *
   + * Test API function:
   + *
   + *   cl_int clGetKernelArgInfo (cl_kernel kernel,
   + *  cl_uint arg_indx,
   + *  cl_kernel_arg_info param_name,
   + *  size_t param_value_size,
   + *  void *param_value,
   + *  size_t *param_value_size_ret)
   + */
   +
   +#include piglit-framework-cl-api.h
   +
   +
   +PIGLIT_CL_API_TEST_CONFIG_BEGIN
   +
   + config.name = clGetKernelArgInfo;
   + config.version_min = 12;
   +
   + config.run_per_platform = true;
   + config.create_context = true;
   +
   + config.program_source = kernel void dummy_kernel(int
   param_1) {};
   + config.build_options = -cl-kernel-arg-info;
   +
   +PIGLIT_CL_API_TEST_CONFIG_END
   +
   +
   +enum piglit_result
   +piglit_cl_test(const int argc,
   +   const char** argv,
   +   const struct piglit_cl_api_test_config* config,
   +   const struct piglit_cl_api_test_env* env)
   +{
   +#if defined(CL_VERSION_1_2)
   + enum piglit_result result = PIGLIT_PASS;
   +
   + int i;
   + cl_int errNo;
   + cl_kernel kernel;
   +
   + size_t param_value_size;
   + size_t ret_value_size;
   + size_t expected_size;
   +#define BUFFER_SIZE 8
   + char param_value[BUFFER_SIZE];
   +
   + int num_kernel_arg_infos =
   

[Piglit] [PATCH] cl: test clEnqueueFillBuffer

2015-08-07 Thread Serge Martin (EdB)
---
 tests/cl.py|   1 +
 tests/cl/api/CMakeLists.cl.txt |   1 +
 tests/cl/api/enqueue-fill-buffer.c | 269 +
 3 files changed, 271 insertions(+)
 create mode 100644 tests/cl/api/enqueue-fill-buffer.c

diff --git a/tests/cl.py b/tests/cl.py
index 4668ddc..6246ba1 100644
--- a/tests/cl.py
+++ b/tests/cl.py
@@ -58,6 +58,7 @@ with profile.group_manager(PiglitCLTest, 'api') as g:
 g(['cl-api-enqueue-copy-buffer-rect'], 'clEnqueueCopyBufferRect')
 g(['cl-api-enqueue-read_write-buffer'],
   'clEnqueueReadBuffer and clEnqueueWriteBuffer')
+g(['cl-api-enqueue-fill-buffer'], 'clEnqueueFillBuffer')
 g(['cl-api-get-mem-object-info'], 'clGetMemObjectInfo')
 g(['cl-api-get-image-info'], 'clGetImageInfo')
 g(['cl-api-retain_release-mem-object'],
diff --git a/tests/cl/api/CMakeLists.cl.txt b/tests/cl/api/CMakeLists.cl.txt
index b598528..0af42d1 100644
--- a/tests/cl/api/CMakeLists.cl.txt
+++ b/tests/cl/api/CMakeLists.cl.txt
@@ -21,6 +21,7 @@ piglit_cl_add_api_test (enqueue-copy-buffer 
enqueue-copy-buffer.c)
 piglit_cl_add_api_test (enqueue-map-buffer enqueue-map-buffer.c)
 piglit_cl_add_api_test (enqueue-copy-buffer-rect enqueue-copy-buffer-rect.c)
 piglit_cl_add_api_test (enqueue-read_write-buffer enqueue-read_write-buffer.c)
+piglit_cl_add_api_test (enqueue-fill-buffer enqueue-fill-buffer.c)
 piglit_cl_add_api_test (retain_release-mem-object retain_release-mem-object.c)
 piglit_cl_add_api_test (get-mem-object-info get-mem-object-info.c)
 piglit_cl_add_api_test (get-image-info get-image-info.c)
diff --git a/tests/cl/api/enqueue-fill-buffer.c 
b/tests/cl/api/enqueue-fill-buffer.c
new file mode 100644
index 000..af711de
--- /dev/null
+++ b/tests/cl/api/enqueue-fill-buffer.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright © 2015 Serge Martin (EdB) edb+pig...@sigluy.net
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @file enqueue-fill-buffer.c
+ *
+ * Test API function:
+ *
+ *   cl_int
+ *   clEnqueueFillBuffer(cl_command_queue command_queue, cl_mem buffer,
+ *   const void *pattern, size_t pattern_size,
+ *   size_t offset, size_t size,
+ *   cl_uint num_events_in_wait_list,
+ *   const cl_event *event_wait_list,
+ *   cl_event *event )
+ */
+
+#include piglit-framework-cl-api.h
+
+
+PIGLIT_CL_API_TEST_CONFIG_BEGIN
+
+   config.name = clEnqueueFillBuffer;
+   config.version_min = 12;
+
+   config.run_per_device = true;
+   config.create_context = true;
+
+PIGLIT_CL_API_TEST_CONFIG_END
+
+
+#if defined(CL_VERSION_1_2)
+static bool
+test(cl_command_queue queue, cl_mem buffer,
+ const void *pattern, size_t pattern_size,
+ size_t offset, size_t size,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event ,
+ cl_int expected_error, enum piglit_result* result,
+ const char* test_str) {
+   cl_int errNo;
+
+   errNo = clEnqueueFillBuffer(queue, buffer,
+   pattern, pattern_size, offset, size,
+   num_events_in_wait_list, event_wait_list,
+   event);
+
+   if(!piglit_cl_check_error(errNo, expected_error)) {
+   fprintf(stderr, Failed (error code: %s): %s.\n,
+   piglit_cl_get_error_name(errNo), test_str);
+   piglit_merge_result(result, PIGLIT_FAIL);
+   return false;
+   }
+
+   return true;
+}
+#endif
+
+enum piglit_result
+piglit_cl_test(const int argc,
+   const char **argv,
+   const struct piglit_cl_api_test_config* config,
+   const struct piglit_cl_api_test_env* env)
+{
+#if defined(CL_VERSION_1_2)
+   enum piglit_result result = PIGLIT_PASS;
+   cl_int src_buf[4] = {4, 5, 6, 7