Revision: 70015
          http://sourceforge.net/p/brlcad/code/70015
Author:   vasco_costa
Date:     2017-07-28 22:02:04 +0000 (Fri, 28 Jul 2017)
Log Message:
-----------
Cleanups.

Modified Paths:
--------------
    brlcad/branches/opencl/include/rt/rt_instance.h
    brlcad/branches/opencl/src/librt/prep.c
    brlcad/branches/opencl/src/librt/primitives/primitive_util.c

Modified: brlcad/branches/opencl/include/rt/rt_instance.h
===================================================================
--- brlcad/branches/opencl/include/rt/rt_instance.h     2017-07-28 21:44:22 UTC 
(rev 70014)
+++ brlcad/branches/opencl/include/rt/rt_instance.h     2017-07-28 22:02:04 UTC 
(rev 70015)
@@ -363,7 +363,7 @@
 clt_db_store_regions(size_t sz_tree_rpn, union tree_rpn *rtp, size_t nregions, 
struct cl_bool_region *regions, struct clt_region *mtls);
 
 RT_EXPORT extern void
-clt_db_store_regions_table(uint *regions_table, size_t regions_table_size);
+clt_db_store_regions_table(cl_uint *regions_table, size_t regions_table_size);
 
 RT_EXPORT extern void clt_db_release(void);
 

Modified: brlcad/branches/opencl/src/librt/prep.c
===================================================================
--- brlcad/branches/opencl/src/librt/prep.c     2017-07-28 21:44:22 UTC (rev 
70014)
+++ brlcad/branches/opencl/src/librt/prep.c     2017-07-28 22:02:04 UTC (rev 
70015)
@@ -462,7 +462,7 @@
 
 
 #ifdef USE_OPENCL
-void
+static void
 rt_rtree_translate(struct rt_i *rtip, struct soltab **primitives, union 
tree_rpn *rtp, size_t start, size_t end, const long n_primitives)
 {
     size_t i;
@@ -483,17 +483,17 @@
     }
 }
 
-void
-build_regions_table(uint *regions_table, union tree_rpn *rtp, size_t start, 
size_t end, const long n_primitives, const int n_regions, const int reg_id)
+static void
+build_regions_table(cl_uint *regions_table, union tree_rpn *rtp, size_t start, 
size_t end, const long n_primitives, const size_t n_regions, const long reg_id)
 {
     size_t i;
     long st_bit;
     uint rt_index;
 
-    rt_index = n_regions/32 +1;
+    rt_index = n_regions/32 + 1;
     for (i=start; i<start+end; i++) {
        st_bit = rtp[i].st_bit;
-       if (st_bit >= 0L && st_bit < (long)n_primitives) {
+       if (st_bit >= 0L && st_bit < n_primitives) {
            regions_table[st_bit * rt_index + (reg_id >> 5)] |= 1 << (reg_id & 
31);
        }
     }
@@ -582,7 +582,7 @@
            struct cl_bool_region *regions;
            struct clt_region *mtls;
            union tree_rpn *rtree;
-           uint *regions_table;
+           cl_uint *regions_table;
            size_t sz_regions_table;
            size_t sz_rtree_array;
            size_t len;
@@ -642,7 +642,7 @@
 
            sz_regions_table = n_primitives * ((n_regions/32) + 1);
            rtree = (union tree_rpn *)bu_calloc(sz_rtree_array, sizeof(union 
tree_rpn), "region rtree array");
-           regions_table = (uint*)bu_calloc(sz_regions_table, sizeof(cl_uint), 
"regions_table");
+           regions_table = (cl_uint*)bu_calloc(sz_regions_table, 
sizeof(cl_uint), "regions_table");
 
            len = 0;
            i = 0;

Modified: brlcad/branches/opencl/src/librt/primitives/primitive_util.c
===================================================================
--- brlcad/branches/opencl/src/librt/primitives/primitive_util.c        
2017-07-28 21:44:22 UTC (rev 70014)
+++ brlcad/branches/opencl/src/librt/primitives/primitive_util.c        
2017-07-28 22:02:04 UTC (rev 70015)
@@ -787,12 +787,14 @@
 }
 
 void
-clt_db_store_regions_table(uint *regions_table, size_t regions_table_size)
+clt_db_store_regions_table(cl_uint *regions_table, size_t regions_table_size)
 {
     cl_int error;
 
-    clt_db_regions_table = clCreateBuffer(clt_context, 
CL_MEM_READ_ONLY|CL_MEM_HOST_WRITE_ONLY|CL_MEM_COPY_HOST_PTR, 
sizeof(uint)*regions_table_size, regions_table, &error);
-    if (error != CL_SUCCESS) bu_bomb("failed to create OpenCL regions_table 
buffer");
+    if (regions_table_size != 0) {
+       clt_db_regions_table = clCreateBuffer(clt_context, 
CL_MEM_READ_ONLY|CL_MEM_HOST_WRITE_ONLY|CL_MEM_COPY_HOST_PTR, 
sizeof(cl_uint)*regions_table_size, regions_table, &error);
+       if (error != CL_SUCCESS) bu_bomb("failed to create OpenCL regions_table 
buffer");
+    }
 
     clt_db_regions_table_size = regions_table_size;
 }
@@ -948,10 +950,10 @@
                sz_partitions = sizeof(struct cl_partition)*h[npix]*2; /*create 
partition buffer with size= 2*number of segments */
                ipart = (cl_uint*)bu_calloc(1, sz_ipartitions, "ipart");
 
-               sz_bv = sizeof(cl_uint) * (h[npix]*2) * (max_depth/32 + 1); /* 
bitarray to represent the segs in each partition */
+               sz_bv = sizeof(cl_uint)*(h[npix]*2)*(max_depth/32 + 1); /* 
bitarray to represent the segs in each partition */
                bv = (cl_uint*)bu_calloc(1, sz_bv, "bv");
 
-               sz_regiontable = sizeof(cl_uint) * npix * (clt_db_nregions/32 
+1); /* bitarray to represent the regions involved in each partition */
+               sz_regiontable = sizeof(cl_uint)*npix*(clt_db_nregions/32 +1); 
/* bitarray to represent the regions involved in each partition */
                regiontable = (cl_uint*)bu_calloc(1, sz_regiontable, 
"regiontable");
 
            bu_free(h, "h");

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to