Comments for enj http://enja.org casin' the joint since '85 Wed, 09 May 2012 06:22:44 +0000 hourly 1 http://wordpress.org/?v=3.3.2 Comment on Floating down a Tributary by Krzysztof Kula http://enja.org/2012/05/07/floating-down-a-tributary/comment-page-1/#comment-1938 Krzysztof Kula Wed, 09 May 2012 06:22:44 +0000 http://enja.org/?p=767#comment-1938 Awesome! Thanks for this! :) Awesome! Thanks for this! :)

]]>
Comment on Floating down a Tributary by Rafael Ehlers http://enja.org/2012/05/07/floating-down-a-tributary/comment-page-1/#comment-1936 Rafael Ehlers Tue, 08 May 2012 23:45:08 +0000 http://enja.org/?p=767#comment-1936 Sorry but, everything it does (at the ui side) is showing a slider everytime you click on a integer in javascript. At least if it does a colorpick or something else. Seems to me that, all projects based on Bret Victor's talk only implement a few features, and that's not enough yet. Anyway, congratulations on the effort. Sorry but, everything it does (at the ui side) is showing a slider everytime you click on a integer in javascript. At least if it does a colorpick or something else.

Seems to me that, all projects based on Bret Victor’s talk only implement a few features, and that’s not enough yet.

Anyway, congratulations on the effort.

]]>
Comment on Floating down a Tributary by John Harrison http://enja.org/2012/05/07/floating-down-a-tributary/comment-page-1/#comment-1934 John Harrison Tue, 08 May 2012 21:53:30 +0000 http://enja.org/?p=767#comment-1934 soooo cool. but the square circle illusion is going to make me vomit. i can't handle it. soooo cool. but the square circle illusion is going to make me vomit. i can’t handle it.

]]>
Comment on Adventures in PyOpenCL: Part 1 Getting Started with Python by Allan Douglas R. de Oliveira http://enja.org/2011/02/22/adventures-in-pyopencl-part-1-getting-started-with-python/comment-page-1/#comment-1932 Allan Douglas R. de Oliveira Tue, 08 May 2012 03:40:40 +0000 http://enja.org/?p=424#comment-1932 pm, You need to run the test 1000 times. Like: time1 = time() for i in range(1000): c_result = (a + b) * (a + b) * (a / 2.0) time2 = time() print("Execution time with numpy: ", time2 - time1, "s") You will see OpenCL performs better than NumPy (but NumPy is still pretty good, IMHO). On my machine: ('Execution time of test without OpenCL: ', 9.549367904663086, 's') ('Execution time with numpy: ', 0.01725006103515625, 's') =============================================================== ('Platform name:', 'Intel(R) OpenCL') ('Platform profile:', 'FULL_PROFILE') ('Platform vendor:', 'Intel(R) Corporation') ('Platform version:', 'OpenCL 1.1 LINUX') --------------------------------------------------------------- ('Device name:', ' Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz') ('Device type:', 'CPU') ('Device memory: ', 5864, 'MB') ('Device max clock speed:', 2000, 'MHz') ('Device compute units:', 8) Execution time of test: 0.000382 s Results OK =============================================================== ('Platform name:', 'NVIDIA CUDA') ('Platform profile:', 'FULL_PROFILE') ('Platform vendor:', 'NVIDIA Corporation') ('Platform version:', 'OpenCL 1.1 CUDA 4.2.1') --------------------------------------------------------------- ('Device name:', 'GeForce GT 540M') ('Device type:', 'GPU') ('Device memory: ', 2047, 'MB') ('Device max clock speed:', 1344, 'MHz') ('Device compute units:', 2) Execution time of test: 0.000624512 s Results OK pm,

You need to run the test 1000 times. Like:
time1 = time()
for i in range(1000):
c_result = (a + b) * (a + b) * (a / 2.0)
time2 = time()
print(“Execution time with numpy: “, time2 – time1, “s”)

You will see OpenCL performs better than NumPy (but NumPy is still pretty good, IMHO). On my machine:

(‘Execution time of test without OpenCL: ‘, 9.549367904663086, ‘s’)
(‘Execution time with numpy: ‘, 0.01725006103515625, ‘s’)
===============================================================
(‘Platform name:’, ‘Intel(R) OpenCL’)
(‘Platform profile:’, ‘FULL_PROFILE’)
(‘Platform vendor:’, ‘Intel(R) Corporation’)
(‘Platform version:’, ‘OpenCL 1.1 LINUX’)
—————————————————————
(‘Device name:’, ‘ Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz’)
(‘Device type:’, ‘CPU’)
(‘Device memory: ‘, 5864, ‘MB’)
(‘Device max clock speed:’, 2000, ‘MHz’)
(‘Device compute units:’, 8)
Execution time of test: 0.000382 s
Results OK
===============================================================
(‘Platform name:’, ‘NVIDIA CUDA’)
(‘Platform profile:’, ‘FULL_PROFILE’)
(‘Platform vendor:’, ‘NVIDIA Corporation’)
(‘Platform version:’, ‘OpenCL 1.1 CUDA 4.2.1′)
—————————————————————
(‘Device name:’, ‘GeForce GT 540M’)
(‘Device type:’, ‘GPU’)
(‘Device memory: ‘, 2047, ‘MB’)
(‘Device max clock speed:’, 1344, ‘MHz’)
(‘Device compute units:’, 2)
Execution time of test: 0.000624512 s
Results OK

]]>
Comment on Adventures in PyOpenCL: Part 2, Particles with PyOpenGL by Ryan http://enja.org/2011/03/22/adventures-in-pyopencl-part-2-particles-with-pyopengl/comment-page-1/#comment-1913 Ryan Sun, 29 Apr 2012 16:50:01 +0000 http://enja.org/?p=493#comment-1913 Thanks for this. I hacked the nbody algo into the kernel. It works fantastic on my gtx285 with around 10k particles. Thanks for this. I hacked the nbody algo into the kernel. It works fantastic on my gtx285 with around 10k particles.

]]>
Comment on Adventures in OpenCL Part 3: Constant Memory Structs by Emanuel Ey http://enja.org/2011/03/30/adventures-in-opencl-part-3-constant-memory-structs/comment-page-1/#comment-1893 Emanuel Ey Tue, 17 Apr 2012 10:26:16 +0000 http://enja.org/?p=521#comment-1893 So i have been playing around with passing structures to OpenCL kernels as well, and I've actually been able to pass structs directly (i.e., without a pointer). I did this in C, but it should be easy to adapt for C++. Here are the most relevant points from the host code: <code> typedef struct{ cl_uchar cDist; cl_uchar cClass float y[N_POINTS_DEPTH]; float x[N_POINTS_RANGE]; float c1D[N_POINTS_DEPTH]; }myStruct_t; </code> The test kernel takes only 2 arguments, the struct as for input, and another struct of the same type to hold some test data computed from the input. Here's the host-side memory allocation: <code> //instantiate a struct for input: myStruct_t a; a.y[0] = 1.4; a.y[1] = 2.5; //allocate memory for output: cl_mem out = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(myStruct_t), NULL, &errNum); if(errNum != CL_SUCCESS){ fatal(clError(errNum)); }else{ DEBUG(2, "Successfully allocated memory for output.\n"); } </code> Then, set the kernel args: <code> errNum = clSetKernelArg(kernel, 0, sizeof(myStruct_t), &a); errNum |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &out); if (errNum != CL_SUCCESS){ fprintf(stderr, "Error setting kernel arguments.\n"); fatal(clError(errNum)); exit(EXIT_FAILURE); }else{ DEBUG(2, "Successfully defined kernel arguments.\n"); } </code> The kernel: <code> __kernel void testStructs( private myStruct_t soundIn, global myStruct_t *result){ local myStruct_t ssp; ssp.y[0] = 2*soundIn.y[0]; ssp.y[1] = 2*soundIn.y[1]; *result = ssp; } </code> So from my tests i figured out that apparently you cannot actually use the 'constant' qualifier when passing in a struct, it has to be 'private'. This is ok for me, since 'constant' is a special type of 'global' and reading it comes at a performance penalty anyway. To me it makes sense to have a settings struct in the fastest available memory. I tested this on an Nvidia GPU with OpenCL 1.1 and on a Intel Ivy Bridge CPU also with a OpenCL 1.1 implementation. So i have been playing around with passing structures to OpenCL kernels as well, and I’ve actually been able to pass structs directly (i.e., without a pointer).
I did this in C, but it should be easy to adapt for C++.

Here are the most relevant points from the host code:

typedef struct{
cl_uchar cDist;
cl_uchar cClass
float y[N_POINTS_DEPTH];
float x[N_POINTS_RANGE];
float c1D[N_POINTS_DEPTH];
}myStruct_t;

The test kernel takes only 2 arguments, the struct as for input, and another struct of the same type to hold some test data computed from the input. Here’s the host-side memory allocation:

//instantiate a struct for input:
myStruct_t a;
a.y[0] = 1.4;
a.y[1] = 2.5;

//allocate memory for output:
cl_mem out = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(myStruct_t), NULL, &errNum);
if(errNum != CL_SUCCESS){
fatal(clError(errNum));
}else{
DEBUG(2, "Successfully allocated memory for output.\n");
}

Then, set the kernel args:

errNum = clSetKernelArg(kernel, 0, sizeof(myStruct_t), &a);
errNum |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &out);
if (errNum != CL_SUCCESS){
fprintf(stderr, "Error setting kernel arguments.\n");
fatal(clError(errNum));
exit(EXIT_FAILURE);
}else{
DEBUG(2, "Successfully defined kernel arguments.\n");
}

The kernel:

__kernel void testStructs( private myStruct_t soundIn,
global myStruct_t *result){
local myStruct_t ssp;

ssp.y[0] = 2*soundIn.y[0];
ssp.y[1] = 2*soundIn.y[1];

*result = ssp;
}

So from my tests i figured out that apparently you cannot actually use the ‘constant’ qualifier when passing in a struct, it has to be ‘private’. This is ok for me, since ‘constant’ is a special type of ‘global’ and reading it comes at a performance penalty anyway. To me it makes sense to have a settings struct in the fastest available memory.
I tested this on an Nvidia GPU with OpenCL 1.1 and on a Intel Ivy Bridge CPU also with a OpenCL 1.1 implementation.

]]>
Comment on A Python Function Timing Decorator by Rndm » Blog Archive » Python generators http://enja.org/2011/03/09/a-python-function-timing-decorator/comment-page-1/#comment-1861 Rndm » Blog Archive » Python generators Thu, 29 Mar 2012 22:43:20 +0000 http://enja.org/?p=473#comment-1861 [...] Interesting article on how to create a timer wrapper in python: timer decorator [...] [...] Interesting article on how to create a timer wrapper in python: timer decorator [...]

]]>
Comment on Adventures in PyOpenCL: Part 2, Particles with PyOpenGL by joost http://enja.org/2011/03/22/adventures-in-pyopencl-part-2-particles-with-pyopengl/comment-page-1/#comment-1846 joost Sun, 25 Mar 2012 20:54:42 +0000 http://enja.org/?p=493#comment-1846 I also had the ImportError: cannot import name get_gl_sharing_context_properties first, so I built pyopencl-2011.2 from source. Then I had the 'GL_CONTEXT_KHR' exception, which I tried to solve by following the advice above, but after some trial-and-error this worked for me: ./configure.py --cl-enable-gl i am on Kubuntu 11.10 (same as Ubuntu), using the most recent nvidia driver. I also had the ImportError: cannot import name get_gl_sharing_context_properties first, so I built pyopencl-2011.2 from source.
Then I had the ‘GL_CONTEXT_KHR’ exception, which I tried to solve by following the advice above, but after some trial-and-error this worked for me:
./configure.py –cl-enable-gl

i am on Kubuntu 11.10 (same as Ubuntu), using the most recent nvidia driver.

]]>
Comment on [RTPS] Fluid and Rigid body interaction by Conzul http://enja.org/2011/12/01/rtps-fluid-and-rigid-body-interaction/comment-page-1/#comment-1764 Conzul Tue, 06 Mar 2012 16:07:44 +0000 http://enja.org/?p=722#comment-1764 This looks amazing! True Particle physics has been the only major thing lacking in the BGE. I've been psyching myself to learn CryEngine or UDK, but this makes me want to revisit BGE as an option. After all, why limit your product to one OS when with blender you can get it out to three or more? This looks amazing! True Particle physics has been the only major thing lacking in the BGE. I’ve been psyching myself to learn CryEngine or UDK, but this makes me want to revisit BGE as an option. After all, why limit your product to one OS when with blender you can get it out to three or more?

]]>
Comment on [dd3] d3.js selection tutorial by Gavin Kistner http://enja.org/2011/12/05/dd3-d3-js-selection-tutorial/comment-page-1/#comment-1756 Gavin Kistner Thu, 01 Mar 2012 20:13:58 +0000 http://enja.org/?p=727#comment-1756 Very nice. I've just developed an interactive D3.js playground tool (http://phrogz.net/JS/d3-playground/) and was pointed to yours and found the screencast. Very nice. I’ve just developed an interactive D3.js playground tool (http://phrogz.net/JS/d3-playground/) and was pointed to yours and found the screencast.

]]>