main   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/opencl.xtm

Implementation

(bind-func main
  (lambda (argc:i32 argv:i8**)
    (letz ((DATA_SIZE 1024)
           (err:i32* (alloc)) ;; error code returned from api calls
           (data:float* (alloc DATA_SIZE)) ;; original data set given to device
           (results:float* (alloc DATA_SIZE)) ;; results returned from device
           (correct 0) ;; number of correct results returned
           (global:size_t* (alloc)) ;; global domain size for our calculation
           (local:size_t* (alloc)) ;; local domain size for our calculation
           (device_id:cl_device_id* (alloc))    ;; compute device id
           (context:cl_context* (alloc))        ;; compute context
           (commands:cl_command_queue* (alloc)) ;; compute command queue
           (program:cl_program* (alloc))        ;; compute program
           (kernel:cl_kernel* (alloc))          ;; compute kernel
           (input:cl_mem* (alloc)) ;; device memory used for the input array
           (output:cl_mem* (alloc)) ;; device memory used for the output array
           (count:size_t DATA_SIZE)
           (KernelSourcePtr:i8** (salloc))
           (gpu #t))
      ;; fill data set with random values
      (doloop (i DATA_SIZE)
        (pset! data i (random)))
      ;; connect to a compute device
      (pset! err 0 (clGetDeviceIDs null
                                                      (if gpu
                                                          CL_DEVICE_TYPE_GPU
                                                          CL_DEVICE_TYPE_CPU)
                                                      1
                                                      device_id
                                                      null))
      (if (<> (pref err 0) CL_SUCCESS)
          (println "Error: Failed to create a device group!"))
      ;; Create a compute context
      (pset! context 0 (clCreateContext null 1 device_id null null err))
      (if (null? (pref context 0))
          (println "Error: Failed to create a compute context!"))
      ;; Create a command queue
      (pset! commands 0 (clCreateCommandQueue (pref context 0) (pref device_id 0) 0 err))
      (if (null? (pref commands 0))
          (println "Error: Failed to create a command queue!"))
      ;; Create the compute program from the source buffer
      (pset! KernelSourcePtr 0 KernelSource)
      (pset! program 0 (clCreateProgramWithSource (pref context 0) 1 KernelSourcePtr null err))
      (if (null? (pref program 0))
          (println "Error: Failed to create compute program!"))
      ;; Build the program executable
      (pset! err 0 (clBuildProgram (pref program 0) 0 null null null null))
      (if (<> (pref err 0) CL_SUCCESS)
          (let ((len:size_t* (salloc))
                (buffer:i8* (salloc 2048)))


Back to Index

Similar Entries

  • _glib_main_loop_call    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/slideshow.xtm
  • _glib_main_loop_call    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/gstvideo_multi.xtm
  • _glib_main_loop_call    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/gstvideo.xtm
  • _gst_main_loop_call    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mediaplayer.xtm
  • cerberus_main_cc    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/cerberus_midi.xtm
  • clock_scheduler_main_callback    xtlang    /digego/extempore/tree/v0.8.9/libs/core/scheduler.xtm
  • decompose_domain    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/random-walk.xtm
  • get_main_frame    xtlang    /digego/extempore/tree/v0.8.9/libs/external/cef/cef.xtm
  • glib-main-loop    scheme    /digego/extempore/tree/v0.8.9/examples/contrib/slideshow.xtm
  • glib-main-loop    scheme    /digego/extempore/tree/v0.8.9/examples/contrib/gstvideo_multi.xtm
  • glib_main_loop    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/gstvideo.xtm
  • gst-main-loop    scheme    /digego/extempore/tree/v0.8.9/examples/contrib/mediaplayer.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/core/fasta_lang_shootout.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/core/nbody_lang_shootout.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/80211.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/mpitest.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/send-recv.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/random-walk.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/hello-world.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/reduce-average.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/mpi/ping-pong.xtm
  • main    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/extempore-fortran/simulation.xtm
  • mainLoop    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/horde3d_knight.xtm
  • mainLoop    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/bullet.xtm
  • main_cc    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue_midi.xtm
  • main_gain    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • main_reverb    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • run_main_event_loop    xtlang    /digego/extempore/tree/v0.8.9/libs/core/scheduler.xtm
  • set_dl_main    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/dlogue.xtm