Code Monkey home page Code Monkey logo

opencl-book-samples's Introduction

Logo OpenCL Programming Guide 1.2 Examples

This project contains all of the source code to the example programs from the OpenCL Programming Guide. Instructions on checking out the source code and building it on various platforms can be found on the Installation page.

This book is getting old now and I'm pleased to say that we are working on new version that will cover OpenCL 2.1; more information soon.

opencl-book-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencl-book-samples's Issues

Confusing description of work-item functions (p. 150)

Is this errata for the book or an issue with the source code? Errata

If errata, please describe the problem in the book (with page number). If
this is an issue with the source code, please specify the problem,
platform, OpenCL implementation, and any additional information that will
help us reproduce the problem:

Under Work-Item Functions on page 150, it is stated that OpenCL does not 
describe how global and local IDs map to work-items and work-groups and that 
nothing can be assumed of these.  However, such a mapping is given in chapter 
1, on pages 14-16.  This mapping is described in the same way in section 3.2 of 
the OpenCL specification.

Original issue reported on code.google.com by [email protected] on 12 Aug 2011 at 7:13

Errata: Typing error (ch.6, pg.224)

When explaining the effects of using #ifdef controlled code construction on 
kernel function headers, the explenation contains a typing error, where the 
type 'float' appears twice. Once where it should be, and once before the 
correct type 'int'.

See attached file for clarification.

Original issue reported on code.google.com by [email protected] on 15 Aug 2011 at 8:33

Attachments:

LNK2019 errors when building Hello World

Is this errata for the book or an issue with the source code?

Source Code.
I am having a problem with the source code. Here is my environment.

Windows 7
Visual Studio 2010
AMD implementation

Please provide any additional information below.

I just downloaded the code a few hours ago. I am trying to compile and run the 
"Hello World" program in VS2010. The compilation works fine but I get a bunch 
of errors with the linker.

error LNK2019: unresolved external symbol _clCreateContextFromType@24 ...
error LNK2019: unresolved external symbol _clGetPlatformIDs@12  ...
error LNK2019: unresolved external symbol _clCreateCommandQueue@20  ...
error LNK2019: unresolved external symbol _clGetContextInfo@20  ...
error LNK2019: unresolved external symbol _clReleaseProgram@4  ...
error LNK2019: unresolved external symbol _clGetProgramBuildInfo@24  ...
error LNK2019: unresolved external symbol _clBuildProgram@24  ...
error LNK2019: unresolved external symbol _clCreateProgramWithSource@20  ...
error LNK2019: unresolved external symbol _clCreateBuffer@24  ...
error LNK2019: unresolved external symbol _clReleaseContext@4  ...
error LNK2019: unresolved external symbol _clReleaseKernel@4  ...
error LNK2019: unresolved external symbol _clReleaseCommandQueue@4  ...
error LNK2019: unresolved external symbol _clReleaseMemObject@4  ...
error LNK2019: unresolved external symbol _clEnqueueReadBuffer@36  ...
error LNK2019: unresolved external symbol _clEnqueueNDRangeKernel@36  ...
error LNK2019: unresolved external symbol _clSetKernelArg@16  ...
error LNK2019: unresolved external symbol _clCreateKernel@12 ...

More detailed errors are in the attached file.

Any help is greatly appreciated.

Thanks

Chris



Original issue reported on code.google.com by [email protected] on 4 Aug 2011 at 9:00

Attachments:

Typo on page 340

This is a typo on page 340.

On the second line from the *bottom* of the page, variable name "vbo_cl_mem" 
should be "cl_vbo_mem"

Thanks.

Original issue reported on code.google.com by [email protected] on 13 Sep 2011 at 12:29

Errata: Mail addresses for reporting errors

The Preface of the book has a section about how to submit Errata. The section 
states:

"If you find something in the book that you believe is in error, please send us 
a note at [email protected]. The list of errata for the book can be found 
on the book’s Web site at www.openclprogrammingguide.com."

The specified e-mail address is invalid. At 
http://www.openclprogrammingguide.com there is a different address listed: 
"[email protected]", however this address is incorrect as well 
as it is missing a 'g' in the domain name. The correct address should be: 
"[email protected]".

Either make a correction in the printed book (hard to implement) or produce a 
valid alias at "[email protected]" (should be much easier to implement).

Original issue reported on code.google.com by [email protected] on 31 Jul 2011 at 1:51

Errata: Wrong explenation of assignment operator behvior (ch.4, pg.132)

The explenation for the behavior of the assignment operator is incorrect. 
Please see attached file for clarification and focus.

In case the lvalue is a vector type, and the expression is a scalar type, then 
the expression is widened and the assignment is done component-wise.
However, in case the lvalue is a scalar type, and the expression is a vector 
type, this should result in a compilation error.

Also, if both the lvalue and the expression are of vector type, they must be of 
the same width and the same base-type.

Original issue reported on code.google.com by [email protected] on 7 Aug 2011 at 12:06

Attachments:

Typo on page 341

This is a typo on page 341

The last paragraph of the page is an exact copy of the third paragraph from the 
bottom. I believe the author intended to copy paste and replace "acquire" with 
"release" and "OpenGL" with "OpenCL" but forgot to do so.

Thanks.

Original issue reported on code.google.com by [email protected] on 13 Sep 2011 at 12:32

Ported sparse matrix multiplcation (Chapter 22) spmv to Windows

Hi,
I'm studying OpenCl and made Sparse matrix multiplcation spmv run
under Windows 32/64bis OS; tested with bcsstk35.mtx and consph.mtx.

All the changes are ifdefed for _Win32. Also fixed one bug in matrix_gen.cpp 
for .mtx parsing.

I hate to throw this port away... do you want it?

Regards,
Sergei.

Original issue reported on code.google.com by [email protected] on 3 Nov 2011 at 6:45

Typo (p. 255)

There is a typo in the second line of the source code listing:

"buffer = clCreate(..."

In general the code is a bit confusing since the mentioned intention is to 
create sub-buffers. That particular part is missing in the code. One can only 
imagine that the sub-buffers are created elsewhere and then used here:

"errNum = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&buffers[i]);"

Except for those little errors it is a really nice book!

Thank you and regards,
Martin


Original issue reported on code.google.com by [email protected] on 2 Nov 2011 at 11:34

Errata: Incorrect num_devices argument in clCreateContext (ch.3, pg.86)

The fourth argument of the second call to clGetDeviceIDs() is 
“&devices[0]“, which is technically correct but inconsistent with the third 
argument of clCreateContext(), “devices“.

The real errata is the second argument of clCreateContext(), “size / 
sizeof(cl_device_id)“.  Here “size“ is undefined and the argument should 
instead be “num“.  

Original issue reported on code.google.com by [email protected] on 19 Aug 2011 at 11:32

Defect: Visual Studio & AMD/ATI compilation documentation

After tinkering a bit the compilation for Visual Studio I found out:

You need to install the DirectX SDK (http://msdn.microsoft.com/en-us/directx/ 
-> "Get the Latest DirectX SDK". After it is installed CMake will discover this 
by itself. Please add this to the documentation.

The example using Boost (ch16) is not supposed to work on Windows, I'll leave 
it at that for now. Would be nice to change the "Could NOT find Boost" error 
message in CMake to "Could NOT find Boost, this is expected on Windows".

For AMD/ATI OpenCL you can now get the AMD APP SDK 
(http://developer.amd.com/sdks/AMDAPPSDK) instead of ATI Stream SDK. To use the 
AMD APP SDK (64bit) you need to change these variables in CMake:

* OPENCL_LIBRARIES = C:/Program Files (x86)/AMD APP/lib/x86_64/OpenCL.lib
* OPENCL_INCLUDE_DIRS = C:/Program Files (x86)/AMD APP/include
* _OPENCL_CPP_INCLUDE_DIRS = C:/Program Files (x86)/AMD APP/include

The paths in 32bit Windows are probably different.

Might be nice to add these paths in FindOpenCL.cmake. The AMD APP SDK can be 
found at %AMDAPPSDKROOT% (instead of %ATISTREAMSDKROOT%).

Original issue reported on code.google.com by [email protected] on 8 Sep 2011 at 1:39

Defect: Missing release in sample code (ch.2, pg. 51)

The sample code for chapter 2 contains a potential memory leak in function 
CreateCommandQueue().

The function returns without releasing an internally allocated buffer, in case 
an error occured while attempting to get context information.

Following is the code in question:

// Allocate memory for the devices buffer
devices = new cl_device_id[deviceBufferSize / sizeof(cl_device_id)];
errNum = clGetContextInfo(context, CL_CONTEXT_DEVICES, 
deviceBufferSize, devices, NULL);
if (errNum != CL_SUCCESS)
{
  cerr << "Failed to get device IDs";
  return NULL;
}

Original issue reported on code.google.com by [email protected] on 4 Aug 2011 at 12:36

Typo on page 342

This is a typo on page 342.

At the very end of the first paragraph, "clFinish()" is said to be called after 
the "clEnqueueReleaseGLObjects()" call. I believe "clFinish()" should be called 
immediately *before* the "clEnqueueReleaseGLObjects()" call.

Thanks.


Original issue reported on code.google.com by [email protected] on 13 Sep 2011 at 12:36

Typo at page 253

This is a typo in the book's text.

Page 253, the boxed definition of "clCreateSubBuffer" function:

The definition of the parameter "buffer_create_info" reads:
"Combined with buffer_create_info, describes the ..."
should read
"Combined with buffer_create_type, describes the ..."

Thanks.


Original issue reported on code.google.com by [email protected] on 9 Sep 2011 at 10:24

Errata: Buffer arg comment should say "written to", ch 7, pg 273

errata for the book:
ch 7, pg 273, shaded code snippet says:
cl_int  clEnqueueWriteBufferRect(
                              cl_command_queue command_queue,
                              cl_mem buffer,
                              cl_bool blocking_write,
                              const size_t buffer_origin[3],
                              const size_t host_origin[3],
                              const size_t region[3],
                              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)

buffer A valid buffer object, which will be read from. 

I think the comment for the buffer arg should say "which will be written to", 
because you are enqueueing a write op. and reading from the buffer pointed to 
by "ptr", which is correctly described.


Original issue reported on code.google.com by [email protected] on 5 Sep 2011 at 1:27

Errata: Incorrect array subscripts, ch 9, pg 324

Errata: ch 9, pg 324
The example shows indexes on k_events as [1] and [2].  Since the array is of 
size 2, the indexes should be [0] and [1].

// Set up memory objs, programs, kernels and enqueue a DAG spanning 
// two command-queues (only the last few "enqueues" are shown).
    err = clEnqueueNDRangeKernel(Comm1, kernel1, 1, NULL, &global, 
                 &local,0, NULL, &k_events[1]);
    err = clEnqueueNDRangeKernel(Comm1, kernel2, 1, NULL, &global,
                 &local, 0, NULL, &k_events[2]);

Original issue reported on code.google.com by [email protected] on 5 Sep 2011 at 2:33

Error in description of conditional operator (p. 129)

On page 129 (Conditional Operator):

"If the result is a scalar value, the second expression, expr2, is evaluated if 
the result compares equal to 0; otherwise the third expression, expr3, is 
evaluated."

This is the exact opposite of the usual ?: semantics.  I guess it should say 
"compares UNequal to 0" instead.

Original issue reported on code.google.com by [email protected] on 11 Aug 2011 at 1:03

Errata: Incorrect param_value_size_ret argument in clGetDeviceInfo (ch.3, pg.70)

The fifth argument in clGetDeviceInfo() is “&size“ but should probably be 
“NULL“.  If you specify the “param_value_size“ and a non-NULL 
“param_value“ then their is no need to also query the 
“param_value_size_ret“, right?  As written in the book, 
which--“param_value“, “param_value_size_ret“, or both--values are 
queried?

Original issue reported on code.google.com by [email protected] on 19 Aug 2011 at 12:06

Errata: Incorrect param_value argument in clGetPlatformInfo (ch.3, pg.65)

cl_int err;
size_t size;

err = clGetPlatformInfo(id, CL_PLATFORM_NAME, 0, NULL, &size);
char * name = (char *)alloca(sizeof(char) * size);
/* INCORRECT
err = gl GetPaltformInfo(id, CL_PALTFORM_NAME, size, info, NULL);
 */
err = gl GetPaltformInfo(id, CL_PALTFORM_NAME, size, name, NULL);

err = clGetPlatformInfo(id, CL_PLATFORM_VENDOR, 0, NULL, &size);
char * vname = (char *)alloca(sizeof(char) * size);
/* INCORRECT
err = gl GetPaltformInfo(id, CL_PLATFORM_VENDOR, size, info, NULL);
 */
err = gl GetPaltformInfo(id, CL_PLATFORM_VENDOR, size, vname, NULL);

Original issue reported on code.google.com by [email protected] on 5 Sep 2011 at 5:55

Errata: Wrong values in figure 3.2 (ch.3 pg.90)

Figure 3.2 is meant to illustrate the process of convolution. However, wrong 
values in the 'result' matrix, may confuse the unsespecting reader.

These are the errors in the figure:
* The value in cell (1, 3) is 19, where it should be 27.
* The value in cell (6, 6) is 38, which is the correct result for the marked 
cells in the input matrix, however, these refer to cell (4, 5) of the output 
matrix, not cell (6, 6).

See attached file for the relevant figure.

Original issue reported on code.google.com by [email protected] on 4 Aug 2011 at 2:34

Attachments:

Can not compile first sample

Hello.
I need your help with compiling source code.
I add the screenshot of my Visual Studio 2010. I dont know what can i do. Where 
can I download this 'CL/cl.h' library?
Please, help me.

Original issue reported on code.google.com by [email protected] on 28 Dec 2011 at 11:17

Attachments:

Errata: Miss-use of returned value from clGetContextInfo (ch.3, pg.88)

The code example on page 88 contains a miss-use of a returned value from a call 
to clGetContextInfo() with param_name = CL_CONTEXT_DEVICES. The returned 'size' 
is already the size of the cl_device_id[] that the next call would return, in 
bytes, yet the following allocation multiplies this value by 
sizeof(cl_device_id).

P.S.
As with a lot of examples in the book, releasing memory allocated for these 
such tasks is not denoted in the code, which leads to memory leaks.

P.P.S.
A lot of tables (e.g. 3.3, 3.4, 3.5) are missing a lot of border lines between 
rows. This is a cosmetic issue.

Original issue reported on code.google.com by [email protected] on 4 Aug 2011 at 2:15

Attachments:

Errata: Wrong description of Floating-point constant (ch.5, pg.163)

Table 5.4 lists the constant values available in OpenCL C. At the end of the 
table on page 163, the last two rows describe the constants M_SQRT2(_F) and 
M_SQRT1_2(_F). The description for these constants is incorrect as it denotes 
 to be in the sqrt(), where the correct value is 2.

Original issue reported on code.google.com by [email protected] on 7 Aug 2011 at 10:08

Errata: Incorrect comment in sample code (ch.4 pg.117)

The sample explicit cast at the top of the page contains an incorrect comment 
about the result of the cast:

uchar4 vtrue =(uchar4)true; // vtrue is a uchar4 vector with
                            // elements(0xFF, 0xFF, 0xFF, 0xFF)

The correct result would be elements(0x01, 0x01, 0x01, 0x01), as the value true 
should be extended to the integer value 1, as correctly mentioned in table 4.1 
at the begining of the chapter (pg. 100).

Original issue reported on code.google.com by [email protected] on 6 Aug 2011 at 6:53

Errata: undeclared identifier "info" used in sample code

Chapter 3, page 65: in the sample code showing how to use  clGetPlatformInfo 
function, an undeclared identifier "info" is used as argument in the function 
calls, in place of the declared variables "char* name" and "char* vname".


Original issue reported on code.google.com by [email protected] on 4 Sep 2011 at 10:11

Errata: Missing token explenation (ch.5, pg.168)

At the end of page 168, the last paragraph describes the tokens used in the 
following table (5.6). The tokens mentioned are 'gentype' and 'ugentype'. 
However, the table makes use of 'sgentype', which is a signed type. It seems 
fitting that this would be mentioned as well.

Note: this token does get explained prior to other tables in the following 
pages.

Original issue reported on code.google.com by [email protected] on 8 Aug 2011 at 5:52

Typo: Chapter 4, Page 103

text says: "... the compiler can assume that the pointee is always..."

"pointee" should be "pointer" of course.


Original issue reported on code.google.com by [email protected] on 24 Nov 2011 at 1:48

Buffer arg comment should say "written to", ch 7, pg 259

errata for the book:
ch 7, pg259, shaded code snippet says:
cl_int clEnqueueWriteBuffer(cl_command_queuecommand_queue,
                              cl_mem buffer,
                              cl_bool blocking_write,
                              size_t offset,
                              size_t cb,
                              void * ptr,
                              cl_uint num_events_in_wait_list,
                              const cl_event * event_wait_list,
                              cl_event *event)
command_queue   The command-queue in which the write com-
mand will be queued.
buffer A valid buffer object, which will be read from. 

I think the comment for the buffer arg should say "which will be written to", 
because you are enqueueing a write op. and reading from the buffer pointed to 
by "ptr", which is correctly described.

Original issue reported on code.google.com by [email protected] on 5 Sep 2011 at 12:03

Defect: (ch7)

If this is an issue with the source code, please specify the problem,
platform, OpenCL implementation, and any additional information that will help 
us reproduce the problem:

After a fresh checkout and following the build instructions on the wiki, GCC on 
OS X 10.6.8 & Xcode 4.0 errors out due to undefined variables in the 
SimpleBufferSubBuffer example of chapter 7.


Please provide any additional information below.


henksmacbook:build henk$ uname -a
Darwin henksmacbook.fritz.box 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
henksmacbook:build henk$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
henksmacbook:build henk$ cmake ../
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found OpenCL: /System/Library/Frameworks/OpenCL.framework 
-- Boost version: 1.47.0
-- Found the following Boost libraries:
--   program_options
-- Configuring done
-- Generating done
-- Build files have been written to: 
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/build
henksmacbook:build henk$ make
Scanning dependencies of target HelloWorld
[  8%] Building CXX object 
src/Chapter_2/HelloWorld/CMakeFiles/HelloWorld.dir/HelloWorld.cpp.o
Linking CXX executable HelloWorld
[  8%] Built target HelloWorld
Scanning dependencies of target OpenCLInfo
[ 16%] Building CXX object 
src/Chapter_3/OpenCLInfo/CMakeFiles/OpenCLInfo.dir/OpenCLInfo.cpp.o
Linking CXX executable OpenCLInfo
[ 16%] Built target OpenCLInfo
Scanning dependencies of target OpenCLConvolutionChap3
[ 25%] Building CXX object 
src/Chapter_3/OpenCLConvolution/CMakeFiles/OpenCLConvolutionChap3.dir/Convolutio
n.cpp.o
Linking CXX executable OpenCLConvolutionChap3
[ 25%] Built target OpenCLConvolutionChap3
Scanning dependencies of target HelloBinaryWorld
[ 33%] Building CXX object 
src/Chapter_6/HelloBinaryWorld/CMakeFiles/HelloBinaryWorld.dir/HelloBinaryWorld.
cpp.o
Linking CXX executable HelloBinaryWorld
[ 33%] Built target HelloBinaryWorld
Scanning dependencies of target SimpleBufferSubBuffer
[ 41%] Building CXX object 
src/Chapter_7/SimpleBufferSubBuffer/CMakeFiles/SimpleBufferSubBuffer.dir/simple.
cpp.o
In file included from 
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:22:
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/info.hpp: In static member function ‘static void 
InfoDevice<T>::display(_cl_device_id*, cl_device_info, std::string)’:
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/info.hpp:200: error: ‘CL_FP_SOFT_FLOAT’ was not declared 
in this scope
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp: In function ‘int main(int, char**)’:
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:205: error: ‘cl_buffer_region’ was not 
declared in this scope
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:205: error: expected `;' before ‘region’
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:213: error: ‘CL_BUFFER_CREATE_TYPE_REGION’ 
was not declared in this scope
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:214: error: ‘region’ was not declared in this 
scope
/Users/henk/Dropbox/Programmeren/opencl-book-samples-read-only/src/Chapter_7/Sim
pleBufferSubBuffer/simple.cpp:215: error: ‘clCreateSubBuffer’ was not 
declared in this scope
make[2]: *** 
[src/Chapter_7/SimpleBufferSubBuffer/CMakeFiles/SimpleBufferSubBuffer.dir/simple
.cpp.o] Error 1
make[1]: *** 
[src/Chapter_7/SimpleBufferSubBuffer/CMakeFiles/SimpleBufferSubBuffer.dir/all] 
Error 2
make: *** [all] Error 2


Original issue reported on code.google.com by [email protected] on 7 Sep 2011 at 6:42

Errata: Memory leak in example code (ch3. pg.67)

Listing 3.2 on page 67 contains a memory leak, with internally allocated memory 
for the platform information not being released.

See attached file for code snippet.



P.S.
I realize that this isn't the focus of the example code, however it is still an 
errata. If these types of issue reports are of no need, please let me know.

Original issue reported on code.google.com by [email protected] on 4 Aug 2011 at 1:01

Attachments:

chapter 21, wrong array indexes

Hello
I was looking at the book that you guys wrote.
In chapter 21, on matrix multiplication, I am afraid but the indexes for 
accessing the array data are wrong. Either you apply row major order or column 
major order. But the way you access does not make sense.
You have for instance A[Ndim][Pdim], accessing to element A[i][j] would be 
A[i*Pdim + j] for row major order and A[j*Ndim + i] for column major order. 
In the book chapter you write 

Given A[Ndim][Pdim], B[Pdim][Mdim],C[Ndim][Mdim]
tmp=0;
for (k=0; k<Pdim; k++) {
// C[i][j]+=A[i][k]*B[k][j]
tmp += *(A + (i*Ndim + k))* *(B + (k*Pdim + j));
}
*(C + (i*Ndim + j)) = tmp;

And it should be if following for instance row major order:
Given A[Ndim][Pdim], B[Pdim][Mdim],C[Ndim][Mdim]
tmp=0;
for (k=0; k<Pdim; k++) {
// C[i][j]+=A[i][k]*B[k][j]
tmp += *(A + (i*Pdim + k))* *(B + (k*Mdim + j));
}
*(C + (i*Mdim + j)) = tmp;

You can for instance do performance improvements by having B copied into local 
space but transposed, ie then it is row major order, so access to B is also 
continuous instead of jumping Mdim at each k.

On the matematical definition of the problem page 500 it reads 
Cij = Cij + sum(k=0 to P) Aik*Bkj
for 0<= i <= N and 0<= j <= M 
It should be 
Cij = sum(k=0 to P-1)Aik*Bkj
for 0<= i < N  and 0<= j < M

Let me know if I am missing anything.

Joshua

Original issue reported on code.google.com by [email protected] on 12 Sep 2011 at 4:56

Sample code not linked from book website

The book claims that the sample code is accessible from 
http://www.openclprogrammingguide.com/, but this does not seem to be the case. 
I know the site claims the book won't be published until Monday, but the Kindle 
version is already available :)

Original issue reported on code.google.com by [email protected] on 24 Jul 2011 at 12:41

Typo at page 313

This is a typo in the book's text.

Page 313, the paragraph right before the boxed prototype of the function 
"clEnqueueBarrier()"

The very end of this paragraph reads:
"... single queue using the clBarrier() function:"
should read
"... single queue using the clEnqueueBarrier() function:"

Thanks.


Original issue reported on code.google.com by [email protected] on 9 Sep 2011 at 10:29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.