code: def BlackHoleCL(zImage, fImage, InputCL):
      Device = InputCL["Device"]
      Mass = InputCL["Mass"]
      InternalRadius = InputCL["InternalRadius"]
      ExternalRadius = InputCL["ExternalRadius"]
      Angle = InputCL["Angle"]
      Method = InputCL["Method"]
      TrackPoints = InputCL["TrackPoints"]
      Physics = InputCL["Physics"]
      NoImage = InputCL["NoImage"]
      TrackSave = InputCL["TrackSave"]
  
      PhysicsList = DictionariesAPI()
  
      if InputCL["BlackBody"]:
          # Spectrum is Black Body one
          Line = 0
      else:
          # Spectrum is Monochromatic Line one
          Line = 1
  
      Trajectories = numpy.zeros(
          (int(InputCL["Size"] / 2), InputCL["TrackPoints"]),
          dtype=numpy.float32,
      )
      IdLast = numpy.zeros(int(InputCL["Size"] / 2), dtype=numpy.int32)
  
      # Je detecte un peripherique GPU dans la liste des peripheriques
      Id = 0
      HasXPU = False
      for platform in cl.get_platforms():
          for device in platform.get_devices():
              if Id == Device:
                  PF4XPU = platform.name
                  XPU = device
                  print("CPU/GPU selected: ", device.name.lstrip())
                  HasXPU = True
              Id += 1
  
      if not HasXPU:
          print(
              "No XPU #%i found in all of %i devices, sorry..."
              % (Device, Id - 1)
          )
          sys.exit()
  
      ctx = cl.Context([XPU])
      queue = cl.CommandQueue(
          ctx, properties=cl.command_queue_properties.PROFILING_ENABLE
      )
  
      BuildOptions = "-DPHYSICS=%i -DSETTRACKPOINTS=%i " % (
          PhysicsList[Physics],
          InputCL["TrackPoints"],
      )
  
      print("My Platform is ", PF4XPU)
  
      if (
          "Intel" in PF4XPU
          or "Experimental" in PF4XPU
          or "Clover" in PF4XPU
          or "Portable" in PF4XPU
      ):
          print("No extra options for Intel and Clover!")
      else:
          BuildOptions = BuildOptions + " -cl-mad-enable"
  
      BlackHoleCL = cl.Program(ctx, BlobOpenCL).build(
          options=BuildOptions
      )
  
      # Je recupere les flag possibles pour les buffers
      mf = cl.mem_flags
  
      if Method == "TrajectoPixel" or Method == "TrajectoCircle":
          TrajectoriesCL = cl.Buffer(
              ctx,
              mf.WRITE_ONLY | mf.COPY_HOST_PTR,
              hostbuf=Trajectories,
          )
          IdLastCL = cl.Buffer(
              ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=IdLast
          )
  
      zImageCL = cl.Buffer(
          ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=zImage
      )
      fImageCL = cl.Buffer(
          ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=fImage
      )
  
      start_time = time.time()
  
      if Method == "EachPixel":
          CLLaunch = BlackHoleCL.EachPixel(
              queue,
              (zImage.shape[0], zImage.shape[1]),
              None,
              zImageCL,
              fImageCL,
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
          CLLaunch.wait()
      elif Method == "Original":
          CLLaunch = BlackHoleCL.Original(
              queue,
              (1,),
              None,
              zImageCL,
              fImageCL,
              numpy.uint32(zImage.shape[0] / 2),
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
          CLLaunch.wait()
      elif Method == "EachCircle":
          CLLaunch = BlackHoleCL.EachCircle(
              queue,
              (int(zImage.shape[0] / 2),),
              None,
              zImageCL,
              fImageCL,
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
          CLLaunch.wait()
      elif Method == "TrajectoCircle":
          CLLaunch = BlackHoleCL.Trajectory(
              queue,
              (Trajectories.shape[0],),
              None,
              TrajectoriesCL,
              IdLastCL,
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
  
          CLLaunch = BlackHoleCL.Circle(
              queue,
              (Trajectories.shape[0], int(zImage.shape[0] * 4)),
              None,
              TrajectoriesCL,
              IdLastCL,
              zImageCL,
              fImageCL,
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
          CLLaunch.wait()
      else:
          CLLaunch = BlackHoleCL.Trajectory(
              queue,
              (Trajectories.shape[0],),
              None,
              TrajectoriesCL,
              IdLastCL,
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
  
          CLLaunch = BlackHoleCL.Pixel(
              queue,
              (zImage.shape[0], zImage.shape[1]),
              None,
              zImageCL,
              fImageCL,
              TrajectoriesCL,
              IdLastCL,
              numpy.uint32(Trajectories.shape[0]),
              numpy.float32(Mass),
              numpy.float32(InternalRadius),
              numpy.float32(ExternalRadius),
              numpy.float32(Angle),
              numpy.int32(Line),
          )
          CLLaunch.wait()
  
      compute = time.time() - start_time
  
      cl.enqueue_copy(queue, zImage, zImageCL).wait()
      cl.enqueue_copy(queue, fImage, fImageCL).wait()
      if Method == "TrajectoPixel" or Method == "TrajectoCircle":
          cl.enqueue_copy(queue, Trajectories, TrajectoriesCL).wait()
          cl.enqueue_copy(queue, IdLast, IdLastCL).wait()
      elapsed = time.time() - start_time
      print("\nCompute Time : %f" % compute)
      print("Elapsed Time : %f\n" % elapsed)
  
      zMaxPosition = numpy.where(zImage[:, :] == zImage.max())
      fMaxPosition = numpy.where(fImage[:, :] == fImage.max())
      print(
          "Z max @(%f,%f) : %f"
          % (
              (
                  1.0 * zMaxPosition[1][0] / zImage.shape[1] - 0.5,
                  1.0 * zMaxPosition[0][0] / zImage.shape[0] - 0.5,
                  zImage.max(),
              )
          )
      )
      print(
          "Flux max @(%f,%f) : %f"
          % (
              (
                  1.0 * fMaxPosition[1][0] / fImage.shape[1] - 0.5,
                  1.0 * fMaxPosition[0][0] / fImage.shape[0] - 0.5,
                  fImage.max(),
              )
          )
      )
      zImageCL.release()
      fImageCL.release()
  
      if Method == "TrajectoPixel" or Method == "TrajectoCircle":
          if not NoImage:
              AngleStep = 4 * numpy.pi / TrackPoints
              Angles = numpy.arange(0.0, 4 * numpy.pi, AngleStep)
              Angles.shape = (1, TrackPoints)
  
              if TrackSave:
                  # numpy.savetxt("TrouNoirTrajectories_%s.csv" % ImageInfo,
                  #               numpy.transpose(numpy.concatenate((Angles,Trajectories),axis=0)),
                  #               delimiter=' ', fmt='%.2e')
                  numpy.savetxt(
                      "TrouNoirTrajectories.csv",
                      numpy.transpose(
                          numpy.concatenate(
                              (Angles, Trajectories), axis=0
                          )
                      ),
                      delimiter=" ",
                      fmt="%.2e",
                  )
  
          TrajectoriesCL.release()
          IdLastCL.release()
  
      return elapsed
  
file_path: pyopencl/examples/black-hole-accretion.py
imports: import pyopencl
  import numpy
  import time
  import sys
  import getopt
  from socket import gethostname
label_desc: Use image node_id 4 for calling a global function with example usage: BlackHoleCL(zImage, fImage, InputCL) and returns: elapsed