<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>979</bug_id>
          
          <creation_ts>2014-02-19 01:54:17 +0100</creation_ts>
          <short_desc>CLBuffer.createSubBuffer(..) does not consider CL_DEVICE_MEM_BASE_ADDR_ALIGN</short_desc>
          <delta_ts>2014-02-26 17:07:27 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jocl</product>
          <component>opencl</component>
          <version>1</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>wwalker3</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>d4f04ddd3ef3b65b7c31d3504cf55489153c60c1</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3748</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-02-19 01:54:17 +0100</bug_when>
    <thetext>CLBufferTest&apos;s test of createSubBuffer fails on AMD devices
correctly due to not considering CL_DEVICE_MEM_BASE_ADDR_ALIGN.

&quot;CL_MISALIGNED_SUB_BUFFER_OFFSET is
returned in errcode_ret if there are no devices in
context associated with buffer for which the origin
value is aligned to the
CL_DEVICE_MEM_BASE_ADDR_ALIGN value.&quot;

Each device has it&apos;s CL_DEVICE_MEM_BASE_ADDR_ALIGN attribute
and buffers used for a specific device must be aligned to it.

In case the OpenCL implementation does not fail w/ above
operation, subsequent buffer operations (enqueue .. etc) may fail later.

+++
typedef unsigned __int32        cl_uint;

cl_uint CL_DEVICE_MEM_BASE_ADDR_ALIGN:

&quot;The minimum value is the size (in bits) of the largest OpenCL built-in
data type supported by the device (long16 in FULL profile, 
long16 or int16 in EMBEDDED profile) for devices that are not of type
CL_DEVICE_TYPE_CUSTOM .&quot;

+++

I experimented w/ reading our said value and aligned the sub-buffer
offset as specified, which works well.

However a major problem is that the offset and size values passed 
to CLBuffer.createSubBuffer(..) do not reflect the byte-size,
but the element-count.

Implementation must correct the byte-offset to be aligned properly.

Further more, another complication is the lack of knowledge 
for which device the buffer shall be aligned to.
Hence a device attribute may be given here as a hint.
If the latter does not to exist, we would need to align the buffer for all devices.

+++

I currently re-implement a general purpose bitstream reader
allowing properly fetching values like cl_uint .. etc.

+++</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3757</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-02-21 08:39:46 +0100</bug_when>
    <thetext>d4f04ddd3ef3b65b7c31d3504cf55489153c60c1
    Add &apos;CL_DEVICE_MEM_BASE_ADDR_ALIGN&apos; to CLDevice and overal maximum to CLContext
    Split CLBufferTest and use alignment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3770</commentid>
    <comment_count>2</comment_count>
    <who name="Wade Walker">wwalker3</who>
    <bug_when>2014-02-22 19:12:53 +0100</bug_when>
    <thetext>Which tests does this affect? It looks like all the remaining failures except those on Mac OS X 10.6 cause the VM to crash, but I can&apos;t see the stack traces of the crash from the build server.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3778</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-02-23 00:47:12 +0100</bug_when>
    <thetext>(In reply to comment #2)
&gt; Which tests does this affect? It looks like all the remaining failures
&gt; except those on Mac OS X 10.6 cause the VM to crash, but I can&apos;t see the
&gt; stack traces of the crash from the build server.

Well, the crash is fixed now w/ the patch d4f04ddd3ef3b65b7c31d3504cf55489153c60c1,
i.e. the CLBufferTest works now &lt;http://jogamp.org/git/?p=jocl.git;a=blobdiff;f=test/com/jogamp/opencl/CLBufferTest.java;h=5b5d0e38d19454f89eab920a69c87fb04a8536f9;hp=0638844dfee19ababb19540ddc14b9835c285481;hb=d4f04ddd3ef3b65b7c31d3504cf55489153c60c1;hpb=84e5e16a4aaa206c39b04b980d8d63ffacb97dbb&gt;

(I always add a git-sha1 reference ..)

However .. maybe we should add &apos;auto-alignment&apos;  option in that
&apos;createSubBuffer&apos; methods ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3807</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-02-26 17:07:27 +0100</bug_when>
    <thetext>Test CLBufferTest is stable now.

We may reconsider the auto-alignment at a later time
in it&apos;s own bug report.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>