PageRenderTime 27ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/libsrc/cu2/cu2_menu.c

https://gitlab.com/oytunistrator/QuIP
C | 601 lines | 401 code | 98 blank | 102 comment | 15 complexity | f5d57e527867a8951b76aee0ff44ec57 MD5 | raw file
  1. #include "quip_config.h"
  2. // includes, system
  3. #include <stdio.h>
  4. #ifdef HAVE_STDLIB_H
  5. #include <stdlib.h>
  6. #endif
  7. #ifdef HAVE_STRING_H
  8. #include <string.h>
  9. #endif
  10. #ifdef HAVE_MATH_H
  11. #include <math.h>
  12. #endif
  13. #ifdef HAVE_CUDA
  14. #include "my_cu2.h"
  15. #include "quip_prot.h"
  16. #include "veclib/cu2_menu_prot.h"
  17. //#include "veclib/menu_decls.c"
  18. #ifdef FOOBAR
  19. #define ADD_CMD(s,f,h) ADD_COMMAND(unary_menu,s,MENU_FUNC_NAME(f),h)
  20. MENU_BEGIN(unary)
  21. ADD_CMD( set, vset, set to a constant )
  22. #ifdef NOT_YET
  23. ADD_CMD( convert, convert, convert to from one type to another )
  24. ADD_CMD( abs, vabs, convert to absolute value )
  25. ADD_CMD( mov, rvmov, copy data )
  26. ADD_CMD( neg, rvneg, convert to negative )
  27. ADD_CMD( sign, vsign, take sign of vector )
  28. ADD_CMD( round, vround,
  29. round vector elements to nearest integer using round() )
  30. ADD_CMD( floor, vfloor, take floor of vector )
  31. ADD_CMD( ceil, vceil, take ceiling of vector )
  32. //ADD_CMD( conj, , "convert to complex conjugate )
  33. //ADD_CMD( find, , return indeces of non-zero elements )
  34. //ADD_CMD( dimsum, , return sum along comumns (rows) )
  35. //ADD_CMD( sum, vsum, get sum of vector )
  36. //ADD_CMD( flip, , copy a vector, reversing the order of the elements )
  37. //ADD_CMD( flipall, , copy an object, reversing order of all dimensions )
  38. //ADD_CMD( vrint, vrint, round vector elements to nearest integer using rint() )
  39. //ADD_CMD( uni, , "uniform random numbers )
  40. #endif // NOT_YET
  41. MENU_END(unary)
  42. static PF_COMMAND_FUNC( unary )
  43. {
  44. PUSH_MENU(unary);
  45. }
  46. #ifdef NOT_YET
  47. //OpenCL TRIG COMMAND TABLE - ALL KNOWN FUNCTIONS ACCOUNTED FOR
  48. #undef ADD_CMD
  49. #define ADD_CMD(s,f,h) ADD_COMMAND(trig_menu,s,MENU_FUNC_NAME(f),h)
  50. MENU_BEGIN(trig)
  51. ADD_CMD( atan, vatan, compute arc tangent )
  52. ADD_CMD( atan2, vatan2, compute arc tangent (two real args) )
  53. ADD_CMD( cos, vcos, compute cosine )
  54. ADD_CMD( erf, verf, compute error function (erf) )
  55. ADD_CMD( exp, rvexp, exponentiate (base e) )
  56. ADD_CMD( log, vlog, natural logarithm )
  57. ADD_CMD( log10, vlog10, logarithm base 10 )
  58. ADD_CMD( sin, vsin, sompute sine )
  59. ADD_CMD( square, rvsqr, compute square )
  60. ADD_CMD( sqrt, vsqrt, computer square root )
  61. ADD_CMD( tan, vtan, compute tangent )
  62. ADD_CMD( pow, rvpow, raise to a power )
  63. ADD_CMD( acos, vacos, compute inverse cosine )
  64. ADD_CMD( asin, vasin, compute inverse sine )
  65. //ADD_CMD( magsq, , convert to magnitude squared )
  66. //ADD_CMD( atn2, , compute arc tangent (single xomplex arg) )
  67. //ADD_CMD( j0, vj0, compute bessel function j0 )
  68. //ADD_CMD( j1, vj1, compute bessel function j1 )
  69. MENU_END(trig)
  70. static PF_COMMAND_FUNC( trig )
  71. {
  72. PUSH_MENU(trig);
  73. }
  74. //OpenCL LOGICAL COMMAND TABLE - ALL KNOWN FUNCTIONS ACCOUNTED FOR
  75. #undef ADD_CMD
  76. #define ADD_CMD(s,f,h) ADD_COMMAND(logical_menu,s,MENU_FUNC_NAME(f),h)
  77. MENU_BEGIN(logical)
  78. ADD_CMD( and, vand, logical AND )
  79. ADD_CMD( nand, vnand, logical NAND )
  80. ADD_CMD( not, vnot, logical NOT )
  81. ADD_CMD( or, vor, logical OR )
  82. ADD_CMD( xor, vxor, logical XOR )
  83. ADD_CMD( sand, vsand, logical AND with scalar )
  84. ADD_CMD( sor, vsor, logical OR with scalar )
  85. ADD_CMD( sxor, vsxor, logical XOR with scalar )
  86. ADD_CMD( shr, vshr, right shift )
  87. ADD_CMD( shl, vshl, left shift )
  88. ADD_CMD( sshr, vsshr, right shift by a constant )
  89. ADD_CMD( sshl, vsshl, left shift by a constant )
  90. ADD_CMD( sshr2, vsshr2, right shift a constant )
  91. ADD_CMD( sshl2, vsshl2, left shift a constant )
  92. //ADD_CMD( cmp, , bitwise complement )
  93. MENU_END(logical)
  94. static PF_COMMAND_FUNC( logic )
  95. {
  96. PUSH_MENU(logical);
  97. }
  98. #endif // NOT_YET
  99. //OpenCL VVECTOR COMMAND TABLE - ALL KNOWN FUNCTIONS ACCOUNTED FOR
  100. #undef ADD_CMD
  101. #define ADD_CMD(s,f,h) ADD_COMMAND(vvector_menu,s,MENU_FUNC_NAME(f),h)
  102. MENU_BEGIN(vvector)
  103. ADD_CMD( add, vadd, vector addition )
  104. #ifdef NOT_YET
  105. ADD_CMD( div, rvdiv, element by element division )
  106. ADD_CMD( mul, rvmul, element by element multiplication )
  107. ADD_CMD( sub, rvsub, vector subtraction )
  108. // cmul, , multiply by complex conjugation )
  109. #endif // NOT_YET
  110. MENU_END(vvector)
  111. static PF_COMMAND_FUNC( vv )
  112. {
  113. PUSH_MENU(vvector);
  114. }
  115. #ifdef NOT_YET
  116. //OpenCL RSV COMMAND TABLE - ALL KNOWN FUNCTIONS ACCOUNTED FOR
  117. #undef ADD_CMD
  118. #define ADD_CMD(s,f,h) ADD_COMMAND(svector_menu,s,MENU_FUNC_NAME(f),h)
  119. MENU_BEGIN(svector)
  120. ADD_CMD( add, rvsadd, add scalar to elements of a vector )
  121. ADD_CMD( sub, rvssub, subtract elements of a vecotr from a scalar )
  122. ADD_CMD( div, rvsdiv, divide a scalar by the elements of a vector )
  123. ADD_CMD( div2, rvsdiv2, divide elements of a vector by a scalar )
  124. ADD_CMD( mul, rvsmul, multiply a vector by a real scalar )
  125. ADD_CMD( mod, vsmod, integer modulo of a vector by a real scalar )
  126. ADD_CMD( mod2, vsmod2, integer modulo of a real scalar by a vector )
  127. ADD_CMD( pow, vspow, raise the elements of a vector to a scalar power )
  128. ADD_CMD( pow2, vspow2, raise a scalar to powers given by the elements of a vector )
  129. ADD_CMD( atan2, vsatan2, compute 4-quadrant arc tangent of vector and scalar )
  130. ADD_CMD( atan22, vsatan22, compute 4-quadrant arc tangent of a scalar and vector )
  131. //ADD_CMD( and, , bitwise and of scalar and vector )
  132. //ADD_CMD( or, , bitwise or of scalar and vector )
  133. //ADD_CMD( xor, , bitwise xor of scalar and vector )
  134. MENU_END(svector)
  135. static PF_COMMAND_FUNC( rvs )
  136. {
  137. PUSH_MENU(svector);
  138. }
  139. //OpenCL CSV COMMAND TABLE
  140. #undef ADD_CMD
  141. #define ADD_CMD(s,f,h) ADD_COMMAND(csvector_menu,s,MENU_FUNC_NAME(f),h)
  142. MENU_BEGIN(csvector)
  143. //ADD_CMD( add, , add complex scalar to elements of a vector )
  144. //ADD_CMD( mul, , multiply a vector by a complex scalar )
  145. //ADD_CMD( sub, , subtract elements of a vector from a complex scalar )
  146. //ADD_CMD( sub2, , subtract elements of a vector from a complex scalar )
  147. //ADD_CMD( div, , divide a complex scalar by the elements of a vector )
  148. //ADD_CMD( div2, , divide elements of a vector by a complex scalar )
  149. //ADD_CMD( conjmul, , multiply vector conjugation by a complex scalar )
  150. MENU_END(csvector)
  151. static PF_COMMAND_FUNC( cvs )
  152. {
  153. PUSH_MENU(csvector);
  154. }
  155. //OpenCL QSV COMMAND TABLE
  156. #undef ADD_CMD
  157. #define ADD_CMD(s,f,h) ADD_COMMAND(qsvector_menu,s,MENU_FUNC_NAME(f),h)
  158. MENU_BEGIN(qsvector)
  159. //ADD_CMD( add, , add quaternion scalar to elements of a vector )
  160. //ADD_CMD( mul, , multiply a vector by a quaternion scalar )
  161. //ADD_CMD( sub, , subtract elements of a vector from a quaternion scalar )
  162. //ADD_CMD( sub2, , subtract elements of a vector from a quaternion scalar )
  163. //ADD_CMD( div, , divide a quaternion scalar by the elements of a vector )
  164. //ADD_CMD( div2, , divide elements of a vector by a quaternion scalar )
  165. MENU_END(qsvector)
  166. static PF_COMMAND_FUNC( qvs )
  167. {
  168. PUSH_MENU(qsvector);
  169. }
  170. //OpenCL MINMAX COMMAND TABLE - ALL KNOWN FUNCTIONS ACCOUNTED FOR
  171. #undef ADD_CMD
  172. #define ADD_CMD(s,f,h) ADD_COMMAND(minmax_menu,s,MENU_FUNC_NAME(f),h)
  173. MENU_BEGIN(minmax)
  174. ADD_CMD( max, vmax, find maximum value )
  175. ADD_CMD( min, vmin, find minimum value )
  176. ADD_CMD( max_mag, vmaxm, find maximum absolute value )
  177. ADD_CMD( min_mag, vminm, find minimum absolute value )
  178. //ADD_CMD( max_index, , find index of maximum value )
  179. //ADD_CMD( min_index, , find index of minimum value )
  180. //ADD_CMD( max_mag_index, , find index of maximum absolute value )
  181. //ADD_CMD( min_mag_index, , find index of minimum absolute value )
  182. //ADD_CMD( max_times, , find index of maximum & # of occurrences )
  183. //ADD_CMD( min_times, , find index of minimum & # of occurrences )
  184. //ADD_CMD( max_mag_times, , find index of max. mag. & # of occurrences )
  185. //ADD_CMD( min_mag_times, , find index of min. mag. & # of occurrences )
  186. MENU_END(minmax)
  187. static PF_COMMAND_FUNC( minmax )
  188. {
  189. PUSH_MENU(minmax);
  190. }
  191. //OpenCL CMP COMMAND TABLE
  192. #undef ADD_CMD
  193. #define ADD_CMD(s,f,h) ADD_COMMAND(compare_menu,s,MENU_FUNC_NAME(f),h)
  194. MENU_BEGIN(compare)
  195. ADD_CMD( max, vmax, take the max of two vectors )
  196. ADD_CMD( min, vmin, take the min of two vectors )
  197. ADD_CMD( max_mag, vmaxm, take the max mag of two vectors )
  198. ADD_CMD( min_mag, vminm, take the min mag of two vectors )
  199. ADD_CMD( clip, vclip, clip elements of a vector )
  200. ADD_CMD( iclip, viclp, inverted clip )
  201. ADD_CMD( vscmp, vscmp, vector-scalar comparison (>=) )
  202. ADD_CMD( vscmp2, vscmp2, vector-scalar comparison (<=) )
  203. ADD_CMD( bound, vbnd, bound elements of a vector )
  204. ADD_CMD( ibound, vibnd, inverted bound )
  205. ADD_CMD( cmp, vcmp, vector-vector comparison )
  206. ADD_CMD( vsmax, vsmax, scalar-vector maximum )
  207. ADD_CMD( vsmxm, vsmxm, scalar-vector maximum magnitude )
  208. ADD_CMD( vsmin, vsmin, scalar-vector minimum )
  209. ADD_CMD( vsmnm, vsmnm, scalar-vector minimum magnitude )
  210. //ADD_CMD( vmscm, , bit-map scalar-vector mag. comparison )
  211. //ADD_CMD( vmscp, , bit-map scalar-vector comparison )
  212. //ADD_CMD( vcmpm, , vector-vector magnitude comparison )
  213. //ADD_CMD( vscmm, , scalar-vector magnitude comparison )
  214. //ADD_CMD( vvm_lt, , bit-map vector comparison (<) )
  215. //ADD_CMD( vvm_gt, , bit-map vector comparison (>) )
  216. //ADD_CMD( vvm_le, , bit-map vector comparison (<=) )
  217. //ADD_CMD( vvm_ge, , bit-map vector comparison (>=) )
  218. //ADD_CMD( vvm_ne, , bit-map vector comparison (!=) )
  219. //ADD_CMD( vvm_eq, , bit-map vector comparison (==) )
  220. //ADD_CMD( vsm_lt, , bit-map vector/scalar comparison (<) )
  221. //ADD_CMD( vsm_gt, , bit-map vector/scalar comparison (>) )
  222. //ADD_CMD( vsm_ge, , bit-map vector/scalar comparison (<=) )
  223. //ADD_CMD( vsm_ne, , bit-map vector/scalar comparison (>=) )
  224. //ADD_CMD( vsm_eq, , bit-map vector/scalar comparison (==) )
  225. //ADD_CMD( vmcmp, , bit-map vector comarison )
  226. //ADD_CMD( select, , vector/vector selection based on bit-map )
  227. //ADD_CMD( vv_select, , vector/vector selection based on bit-map )
  228. //ADD_CMD( vs_select, , vector/scalar selection based on bit-map )
  229. //ADD_CMD( ss_select, , scalar/scalar selection based on bit-map )
  230. MENU_END(compare)
  231. static PF_COMMAND_FUNC( docmp )
  232. {
  233. PUSH_MENU(compare);
  234. }
  235. //CUFFT COMMAND TABLE
  236. #undef ADD_CMD
  237. #define ADD_CMD(s,f,h) ADD_COMMAND(fft_menu,s,MENU_FUNC_NAME(f),h)
  238. MENU_BEGIN( fft )
  239. ADD_CMD( fft, fwdfft, forward complex Fourier Transform )
  240. //ADD_CMD( newfft, newfft, test new chainable complex fft )
  241. /*
  242. ADD_CMD( row_fft, fwdrowfft, forward complex Fourier Transform of rows only )
  243. ADD_CMD( rfft, fwdrfft, forward Fourier Transform, real input )
  244. ADD_CMD( row_rfft, fwdrowrfft, forward Fourier transform of rows only, real input )
  245. ADD_CMD( irfft, invrfft, inverse Fourier Transform, real output )
  246. ADD_CMD( row_irfft, invrowrfft, inverse Fourier Transform of rows only, real output )
  247. ADD_CMD( invfft, invfft, inverse complex Fourier Transform )
  248. ADD_CMD( row_invfft, invrowfft, inverse complex Fourier Transform of rows only )
  249. ADD_CMD( radavg, radavg, compute radial average )
  250. ADD_CMD( oriavg, oriavg, compute orientation average )
  251. ADD_CMD( wrap, wrap, wrap DFT iamge )
  252. ADD_CMD( wrap3d, wrap3d, wrap 3-D DFT )
  253. ADD_CMD( scroll, scroll, scroll image )
  254. ADD_CMD( dct, dct, compute blocked discrete cosine xform )
  255. ADD_CMD( odct, odct, compute DCT using old method )
  256. ADD_CMD( idct, idct, compute inverse descrete cosine xform )
  257. */
  258. MENU_END( fft )
  259. static PF_COMMAND_FUNC( fft )
  260. {
  261. PUSH_MENU(fft);
  262. }
  263. // NOTE: NPP is cuda-only... - but this is
  264. //COMMAND TABLE FOR Cuda NPP LIBRARY
  265. #undef ADD_CMD
  266. #define ADD_CMD(s,f,h) ADD_COMMAND(npp_menu,s,MENU_FUNC_NAME(f),h)
  267. MENU_BEGIN( npp )
  268. ADD_CMD( image, npp_malloc, declare new image )
  269. ADD_CMD( vadd, npp_vadd, add two images )
  270. ADD_CMD( erode, npp_erosion, erosion )
  271. ADD_CMD( dilate, npp_dilation, dilation )
  272. ADD_CMD( filter, npp_filter, space-domain filtering )
  273. ADD_CMD( sum, npp_sum, compute sum )
  274. ADD_CMD( sum_scratch, npp_sum_scratch, allocate scratch space for sum )
  275. ADD_CMD( i_vmul, nppi_vmul, image/image multiplication )
  276. ADD_CMD( s_vmul, npps_vmul, in-place signel multiplication )
  277. ADD_CMD( version, report_npp_version, report NPP library version )
  278. MENU_END( npp )
  279. static PF_COMMAND_FUNC( npp_menu )
  280. {
  281. PUSH_MENU(npp);
  282. }
  283. static PF_COMMAND_FUNC( fill )
  284. {
  285. Data_Obj *dp;
  286. int x,y;
  287. float fill_val, tol;
  288. dp = PICK_OBJ("image");
  289. x=HOW_MANY("seed point x");
  290. y=HOW_MANY("seed point y");
  291. fill_val=HOW_MUCH("fill value");
  292. tol = HOW_MUCH("tolerance");
  293. h_sp_ifl(dp,x,y,tol,fill_val);
  294. }
  295. static PF_COMMAND_FUNC( fill2 )
  296. {
  297. Data_Obj *dp;
  298. int x,y;
  299. float fill_val, tol;
  300. dp = PICK_OBJ("image");
  301. x=HOW_MANY("seed point x");
  302. y=HOW_MANY("seed point y");
  303. fill_val=HOW_MUCH("fill value");
  304. tol = HOW_MUCH("tolerance");
  305. h_sp_ifl2(dp,x,y,tol,fill_val);
  306. }
  307. static PF_COMMAND_FUNC( yuv2rgb )
  308. {
  309. Data_Obj *rgb_dp;
  310. Data_Obj *yuv_dp;
  311. rgb_dp = PICK_OBJ("RGB image");
  312. yuv_dp = PICK_OBJ("YUV image");
  313. // BUG do all checks:
  314. // pixel types, mating sizes
  315. cu2_yuv422_to_rgb24(rgb_dp,yuv_dp);
  316. }
  317. static PF_COMMAND_FUNC( centroid )
  318. {
  319. Data_Obj *dst1_dp;
  320. Data_Obj *dst2_dp;
  321. Data_Obj *src_dp;
  322. Vec_Obj_Args oargs;
  323. dst1_dp = PICK_OBJ("x scratch image");
  324. dst2_dp = PICK_OBJ("y scratch image");
  325. src_dp = PICK_OBJ("source image");
  326. if( OBJ_MACH_PREC(src_dp) != PREC_SP && OBJ_MACH_PREC(src_dp) != PREC_DP ){
  327. sprintf(ERROR_STRING,"Object %s (%s) must have %s or %s precision for centroid helper",
  328. OBJ_NAME(src_dp),PREC_NAME(OBJ_PREC_PTR(src_dp)),PREC_NAME(PREC_FOR_CODE(PREC_SP)),
  329. PREC_NAME(PREC_FOR_CODE(PREC_DP)));
  330. WARN(ERROR_STRING);
  331. return;
  332. }
  333. // BUG - do more checking here sizes must match, precisions must match.
  334. setvarg3(&oargs,dst1_dp,dst2_dp,src_dp); /* abusing this a little */
  335. if( OBJ_PREC(src_dp) == PREC_SP )
  336. sp_cu2_centroid(&oargs);
  337. else if( OBJ_PREC(src_dp) == PREC_DP )
  338. dp_cu2_centroid(&oargs);
  339. #ifdef CAUTIOUS
  340. else ERROR1("CAUTIOUS: centroid: unexpected source precision!?");
  341. #endif /* CAUTIOUS */
  342. }
  343. //COMMAND TABLE FOR OpenCL NPP LIBRARY
  344. #undef ADD_CMD
  345. #define ADD_CMD(s,f,h) ADD_COMMAND(misc_menu,s,MENU_FUNC_NAME(f),h)
  346. MENU_BEGIN( misc )
  347. ADD_CMD( fill, fill, flood fill )
  348. ADD_CMD( fill2, fill2, flood fill version 2 )
  349. ADD_CMD( yuv2rgb, yuv2rgb, YUV to RGB conversion )
  350. ADD_CMD( centroid, centroid, centroid helper function )
  351. MENU_END( misc )
  352. static PF_COMMAND_FUNC( misc )
  353. {
  354. PUSH_MENU(misc);
  355. }
  356. #endif // NOT_YET
  357. //OpenCL WAR COMMAND TABLE
  358. #undef ADD_CMD
  359. #define ADD_CMD(s,f,h) ADD_COMMAND(compute_menu,s,MENU_FUNC_NAME(f),h)
  360. MENU_BEGIN( compute )
  361. ADD_CMD( unary, unary, unary operations on data )
  362. ADD_CMD( vvector, vv, vector-vector operations )
  363. #ifdef NOT_YET
  364. ADD_CMD( trig, trig, trigonometric operations )
  365. ADD_CMD( logical, logic, logical operations on data )
  366. ADD_CMD( svector, rvs, real scalar-vector operations )
  367. ADD_CMD( csvector, cvs, complex scalar-vector operations )
  368. ADD_CMD( Qsvector, qvs, quaternion scalar-vector operations )
  369. ADD_CMD( minmax, minmax, minimum/maximum routines )
  370. ADD_CMD( compare, comp, comparison routines )
  371. ADD_CMD( fft, fft, fft )
  372. ADD_CMD( misc, misc, miscellaneous platform functions )
  373. #endif // NOT_YET
  374. MENU_END( compute )
  375. static PF_COMMAND_FUNC(func_menu)
  376. {
  377. /* Do platform-specific init here? */
  378. PUSH_MENU(compute);
  379. }
  380. #ifdef HAVE_OPENGL
  381. #ifdef HAVE_GLUT
  382. //OpenCL GL COMMAND TABLE
  383. #undef ADD_CMD
  384. #define ADD_CMD(s,f,h) ADD_COMMAND(pf_gl_menu,s,MENU_FUNC_NAME(f),h)
  385. MENU_BEGIN( pf_gl )
  386. ADD_CMD( buffer, new_gl_buffer, create a named GL buffer )
  387. #ifdef FOOBAR
  388. ADD_CMD( test, gl_test, gl test function )
  389. ADD_CMD( display, gl_disp, update display window )
  390. #endif /* FOOBAR */
  391. ADD_CMD( viewer, new_vwr, create a new image viewer )
  392. ADD_CMD( load, load_vwr, write an image to a viewer )
  393. MENU_END( pf_gl )
  394. static PF_COMMAND_FUNC(pf_gl_menu)
  395. {
  396. /* Do platform-specific init here? */
  397. PUSH_MENU(pf_gl);
  398. }
  399. #endif /* HAVE_GLUT */
  400. #endif /* HAVE_OPENGL */
  401. //OpenCL EVENT CHECKPOINTING COMMAND TABLE
  402. #undef ADD_CMD
  403. #define ADD_CMD(s,f,h) ADD_COMMAND(event_menu,s,MENU_FUNC_NAME(f),h)
  404. MENU_BEGIN( event )
  405. ADD_CMD( max_checkpoints, init_ckpts, set maximum number of checkpoints )
  406. ADD_CMD( set_checkpoint, set_ckpt, set a checkpoint )
  407. ADD_CMD( reset, clear_ckpts, clear all checkpoints )
  408. ADD_CMD( show, show_ckpts, show checkpoint times )
  409. MENU_END( event )
  410. static PF_COMMAND_FUNC( event_menu )
  411. {
  412. PUSH_MENU(event);
  413. }
  414. //OpenCL EVENT CHECKPOINTING COMMAND TABLE
  415. #undef ADD_CMD
  416. #define ADD_CMD(s,f,h) ADD_COMMAND(stream_menu,s,MENU_FUNC_NAME(f),h)
  417. MENU_BEGIN( stream )
  418. ADD_CMD( stream, new_stream, create a new stream )
  419. ADD_CMD( list, list_streams, list all streams )
  420. ADD_CMD( info, stream_info, report information about a stream )
  421. ADD_CMD( sync, sync_stream, synchronize host execution with a stream )
  422. MENU_END( stream )
  423. static PF_COMMAND_FUNC( stream_menu )
  424. {
  425. PUSH_MENU(stream);
  426. }
  427. static PF_COMMAND_FUNC( prt_cap )
  428. {
  429. #ifdef HAVE_OpenCL
  430. #ifdef OpenCL_COMP_CAP
  431. sprintf(MSG_STR,"Compiled for compute capability %d.%d",
  432. OpenCL_COMP_CAP/10,OpenCL_COMP_CAP%10);
  433. #else // ! OpenCL_COMP_CAP
  434. ERROR1("CAUTIOUS: HAVE_OpenCL is defined, but OpenCL_COMP_CAP is not!?!?");
  435. #endif // ! OpenCL_COMP_CAP
  436. #else // ! HAVE_OpenCL
  437. sprintf(MSG_STR,"No OpenCL support in this build");
  438. #endif // ! HAVE_OpenCL
  439. prt_msg(MSG_STR);
  440. }
  441. static PF_COMMAND_FUNC( about_platform )
  442. {
  443. #ifdef HAVE_OpenCL
  444. sprintf(MSG_STR,"OpenCL version: %d.%d",
  445. OpenCL_VERSION/1000,(OpenCL_VERSION%100)/10);
  446. prt_msg(MSG_STR);
  447. #else // ! HAVE_OpenCL
  448. prt_msg("No OpenCL support in this build");
  449. #endif // ! HAVE_OpenCL
  450. #ifdef FOOBAR
  451. report_npp_version(SINGLE_QSP_ARG);
  452. #endif // FOOBAR
  453. }
  454. static PF_COMMAND_FUNC( select_device )
  455. {
  456. Platform_Device *pdp;
  457. pdp = PICK_PFDEV((char *)"device");
  458. if( pdp == NO_PFDEV ) return;
  459. curr_pdp = pdp;
  460. }
  461. //OpenCL MAIN MENU
  462. #undef ADD_CMD
  463. #define ADD_CMD(s,f,h) ADD_COMMAND(platform_menu,s,MENU_FUNC_NAME(f),h)
  464. MENU_BEGIN( platform )
  465. //ADD_CMD( devices, query_devices, list all platform devices )
  466. ADD_CMD( capability, prt_cap, print GPU capabilities )
  467. ADD_CMD( about, about_platform, print software versions)
  468. //ADD_CMD( test_blas, test_blas, simple test of OpenCL BLAS )
  469. ADD_CMD( list, list_devs, list all GPU devices )
  470. ADD_CMD( info, dev_info, print information about a device )
  471. ADD_CMD( select, select_device, select device for operations )
  472. ADD_CMD( upload, obj_upload, upload data to a GPU )
  473. ADD_CMD( dnload, obj_dnload, download data from a GPU )
  474. ADD_CMD( compute, func_menu, compute function submenu )
  475. #ifdef FOOBAR
  476. ADD_CMD( npp, npp_menu, NPP library submenu )
  477. #endif // FOOBAR
  478. #ifdef HAVE_OPENGL
  479. #ifdef HAVE_GLUT
  480. ADD_CMD( gl, pf_gl_menu, openCL GL submenu )
  481. #endif /* HAVE_GLUT */
  482. #endif /* HAVE_OPENGL */
  483. ADD_CMD( streams, stream_menu, OpenCL stream submenu )
  484. ADD_CMD( events, event_menu, event submenu )
  485. MENU_END( platform )
  486. PF_COMMAND_FUNC( menu )
  487. {
  488. static int inited=0;
  489. if( ! inited ){
  490. PF_FUNC_NAME(init_platform)(SINGLE_QSP_ARG);
  491. inited=1;
  492. }
  493. PUSH_MENU(platform);
  494. }
  495. #endif // FOOBAR
  496. #else // ! HAVE_CUDA
  497. #ifdef FOOBAR
  498. COMMAND_FUNC( do_cu2_menu )
  499. {
  500. WARN("No CUDA support in this build!?");
  501. }
  502. #endif // FOOBAR
  503. #endif // ! HAVE_CUDA