Révision 174
Pi/OpenCL/PiOpenCL.c (revision 174) | ||
---|---|---|
1 | 1 |
// Pi Dart Dash in OpenCL in C, illustrative example |
2 | 2 |
// |
3 |
// Emmanuel Quemener <emmanuel.quemener@ens-lyon.fr |
|
3 |
// Emmanuel Quemener <emmanuel.quemener@gmail.com> |
|
4 |
// |
|
5 |
// CC BY-NC-SA 2011 : Emmanuel QUEMENER <emmanuel.quemener@gmail.com> |
|
4 | 6 |
// Copyleft Cecill v2 |
5 | 7 |
// |
6 | 8 |
// -h : print the documentation and detect devices as (platform,device) |
... | ... | |
11 | 13 |
// #3 Minimal number of iterations: |
12 | 14 |
// #4 Parallel Rate: scattering global work in parts executed //ly |
13 | 15 |
// #5 Loops (to improve statistics) |
16 |
// #6 Type of variables INT32, INT64, FP32, FP64 |
|
14 | 17 |
// |
18 |
// To compile : gcc -o PiOpenCL PiOpenCL.c -lOpenCL |
|
15 | 19 |
|
16 | 20 |
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS |
17 | 21 |
#include <stdio.h> |
NBody/NBody.py (revision 174) | ||
---|---|---|
3 | 3 |
""" |
4 | 4 |
NBody Demonstrator implemented in OpenCL, rendering OpenGL |
5 | 5 |
|
6 |
Emmanuel QUEMENER <emmanuel.quemener@ens-lyon.fr> CeCILLv2 |
|
6 |
CC BY-NC-SA 2011 : Emmanuel QUEMENER <emmanuel.quemener@gmail.com> |
|
7 |
Cecill v2 : Emmanuel QUEMENER <emmanuel.quemener@gmail.com> |
|
8 |
|
|
9 |
Thanks to Andreas Klockner for PyOpenCL: |
|
10 |
http://mathema.tician.de/software/pyopencl |
|
11 |
|
|
7 | 12 |
""" |
8 | 13 |
import getopt |
9 | 14 |
import sys |
... | ... | |
510 | 515 |
pass |
511 | 516 |
|
512 | 517 |
def keyboard(k,x,y): |
513 |
global ViewRZ,SizeOfBox,SpeedRendering
|
|
518 |
global ViewRZ,SpeedRendering |
|
514 | 519 |
LC_Z = as_8_bit( 'z' ) |
515 | 520 |
UC_Z = as_8_bit( 'Z' ) |
516 | 521 |
Plus = as_8_bit( '+' ) |
... | ... | |
518 | 523 |
Switch = as_8_bit( 's' ) |
519 | 524 |
|
520 | 525 |
Zoom=1 |
521 |
if k == LC_Z: |
|
526 |
if k == GLUT_KEY_UP: |
|
527 |
ViewRX += 1.0 |
|
528 |
elif k == GLUT_KEY_DOWN: |
|
529 |
ViewRX -= 1.0 |
|
530 |
elif k == GLUT_KEY_LEFT: |
|
531 |
ViewRY += 1.0 |
|
532 |
elif k == GLUT_KEY_RIGHT: |
|
533 |
ViewRY -= 1.0 |
|
534 |
elif k == LC_Z: |
|
522 | 535 |
ViewRZ += 1.0 |
523 | 536 |
elif k == UC_Z: |
524 | 537 |
ViewRZ -= 1.0 |
... | ... | |
541 | 554 |
glutPostRedisplay() |
542 | 555 |
|
543 | 556 |
def special(k,x,y): |
544 |
global ViewRX, ViewRY, ViewRZ
|
|
557 |
global ViewRX, ViewRY |
|
545 | 558 |
|
546 | 559 |
if k == GLUT_KEY_UP: |
547 | 560 |
ViewRX += 1.0 |
... | ... | |
795 | 808 |
else: |
796 | 809 |
SizeOfBox=SizeOfShape |
797 | 810 |
|
811 |
if OpenGL: |
|
812 |
print('\tTiny documentation to interact OpenGL rendering:\n') |
|
813 |
print('\t<Left|Right> Rotate around X axis') |
|
814 |
print('\t <Up|Down> Rotate around Y axis') |
|
815 |
print('\t <z|Z> Rotate around Z axis') |
|
816 |
print('\t <-|+> Unzoom/Zoom') |
|
817 |
print('\t <s> Toggle to display Positions or Velocities') |
|
818 |
print('\t <Esc> Quit\n') |
|
819 |
|
|
798 | 820 |
wall_time_start=time.time() |
799 | 821 |
|
800 | 822 |
Durations=np.array([],dtype=MyFloat) |
Formats disponibles : Unified diff