Deal of the Day

Home » Main » Manning Forums » 2010 » OpenCL in Action

Thread: Errors and Corrections

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 16 - Pages: 2 [ 1 2 | Next ] - Last Post: Apr 14, 2014 11:26 AM by: jknapka
luke.bace

Posts: 66
Registered: 7/7/09
Errors and Corrections
Posted: Jan 4, 2011 9:57 PM
  Click to reply to this thread Reply

Please post all errata here. Thanks.

andaluri

Posts: 4
From: New York, NY
Registered: 1/19/11
Re: Errors and Corrections
Posted: Feb 14, 2011 6:51 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On Page 49, Section 3.2.2, I think there is a typo in the text shown below:

"The size field defines the size of the sub-buffer. The following code creates a sub-buffer containing 40 ints from a buffer object containing 100 ints. The start of the sub-buffer data is the 50th float in the main buffer.

cl_buffer_region region;
region.size = 40*sizeof(float);
region.origin = 50*sizeof(float);
"

I'm assuming the "ints" (shown in bold) should have been "floats" isn't it? The sample code indeed looking at the size of a float. It's just the text that could be wrong. Comments?

matthew.scarpino

Posts: 9
Registered: 12/2/10
Re: Errors and Corrections
Posted: Feb 14, 2011 7:38 PM   in response to: andaluri in response to: andaluri
  Click to reply to this thread Reply

Hello,

You're quite right. The 'ints' should be 'floats.' I'll get that corrected immediately.

Thank you!
Matt

andaluri

Posts: 4
From: New York, NY
Registered: 1/19/11
Re: Errors and Corrections
Posted: Feb 22, 2011 10:34 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

The source code listings on linux were packaged with Windows line endings. At least the first upload of source code. Just want to share this with fellow readers: You may need to use dos2unix to convert the line endings for *nix.

matthew.scarpino

Posts: 9
Registered: 12/2/10
Re: Errors and Corrections
Posted: Feb 22, 2011 4:11 PM   in response to: andaluri in response to: andaluri
  Click to reply to this thread Reply

Hello Andaluri,

Thank you for mentioning that. I'll make sure that every future GNU source release has UNIX-style line endings.

Thanks again,
Matt

andaluri

Posts: 4
From: New York, NY
Registered: 1/19/11
Re: Errors and Corrections
Posted: Mar 22, 2011 4:35 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On Page 174, the text reads "For example, if a main buffer contains 200 floats and you want to create a sub-buffer containing floats 70-99, you could use the following function:"

Should the text in bold above i.e. "70-99" should read "70-89" as the code right below the text is creating 20 float region?

matthew.scarpino

Posts: 9
Registered: 12/2/10
Re: Errors and Corrections
Posted: Mar 22, 2011 4:09 PM   in response to: andaluri in response to: andaluri
  Click to reply to this thread Reply

Hello again andaluri,

You're absolutely right. "70-89" it is. Thank you for paying such close attention!

Best regards,
Matt

mato

Posts: 44
Registered: 3/31/10
Re: Errors and Corrections
Posted: Mar 22, 2011 6:08 PM   in response to: matthew.scarpino in response to: matthew.scarpino
  Click to reply to this thread Reply

Thanks! That correction will be in the next MEAP release.

Maria Townsley
Developmental Editor
Manning Publications Co.

hazelnusse

Posts: 2
From: United States
Registered: 12/18/11
Re: Errors and Corrections
Posted: Dec 18, 2011 3:37 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On page 21, in the listing for platform_ext_test.c, it seems like:

err = clGetPlatformIDS(1, NULL, &num_platforms);

will always result in num_platforms being either 0 or 1, so the subsequent for loop is a bit redundant. Shouldn't the first argument be the maximum number of platforms you want to get, so something larger than 1?

This is also in the GNU source code.

hazelnusse

Posts: 2
From: United States
Registered: 12/18/11
Re: Errors and Corrections
Posted: Dec 18, 2011 3:39 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

page 65 has:

work_items_per_kernel = 4;

but the source code has:

work_units_per_kernel = 4; /* 4 work-units per kernel */

The source code should probably be changed to match the text to eliminate confusion.

jb4652

Posts: 9
From: China
Registered: 8/16/12
Re: Errors and Corrections
Posted: Aug 16, 2012 9:02 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On page 51, Section 3.3.2
"The data type of the fourth argument is cl_image_info."
I guess the fourth should be the second.

Another code issue (ch3 buffer check):
by running it on both Intel SDK and Nvidia SDK, I got "CL_INVALID_VALUE" error code after calling clCreateSubBuffer().
If I change it from
sub_buffer = clCreateSubBuffer(main_buffer, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, CL_BUFFER_CREATE_TYPE_REGION, Žion, &err);
to
sub_buffer = clCreateSubBuffer(main_buffer, CL_MEM_READ_ONLY, CL_BUFFER_CREATE_TYPE_REGION, Žion, &err);
Nvidia SDK will work. Intel SDK still gets CL_DEVICE_MEM_BASE_ADDR_ALIGN error code, but this is beyond the topic of this section.
OpenCL 1.1 specification also states that on page 61:
CL_INVALID_VALUE if buffer was created with CL_MEM_WRITE_ONLY and flags specifies CL_MEM_READ_WRITE or CL_MEM_READ_ONLY, or if buffer was created with CL_MEM_READ_ONLY and flags specifies CL_MEM_READ_WRITE or CL_MEM_WRITE_ONLY, or if flags specifies CL_MEM_USE_HOST_PTR or CL_MEM_ALLOC_HOST_PTR or CL_MEM_COPY_HOST_PTR.

Thanks.

jb4652

Posts: 9
From: China
Registered: 8/16/12
Re: Errors and Corrections
Posted: Aug 18, 2012 12:48 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Windows version code, ch4_double_test.c
Line 133-134:
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(ext_data), NULL, &ext_size);
should be
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 0, NULL, &ext_size);

Just as the one used in Listing 2.1, or ext_size will be incorrect.

jb4652

Posts: 9
From: China
Registered: 8/16/12
Re: Errors and Corrections
Posted: Aug 18, 2012 2:49 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Page 84, Fig 4.5
uint4 vec = (vec4)(0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F);
should be consist with Listing 4.4
uint4 vec = (global uint4)(0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F);
and (vec4) is itself a gramma error.

The blue bar of Listing 4.4 on top of page 85 should be on page 84, above:
__kernel void vector_bytes(__global uchar16 *test) {

jb4652

Posts: 9
From: China
Registered: 8/16/12
Re: Errors and Corrections
Posted: Aug 26, 2012 1:47 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Code: Ch10_reduction: reduction.c

vector_sum_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, num_groups * sizeof(float), vector_sum, &err);
shoule be
vector_sum_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, num_groups / 4 * sizeof(float), vector_sum, &err);

However, the result is not affected.

phaethon

Posts: 1
From: Ohio, USA
Registered: 10/21/12
Re: Errors and Corrections
Posted: Oct 21, 2012 3:56 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On page 218 (the pyOpenCL section), a line reads:

kernel.enqueue_nd_range_kernel(queue, kernel, (20,), (4,))

And should actually be:

cl.enqueue_nd_range_kernel(queue, kernel, (20,), (4,))

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor