/**
   * Get the binaries of the program (one for each device, in order)
   *
   * @return map from each device the program was compiled for to the corresponding binary data
   */
  public Map<CLDevice, byte[]> getBinaries() throws CLBuildException {
    synchronized (this) {
      if (!built) build();
    }

    Memory s = infos.getMemory(getEntity(), CL_PROGRAM_BINARY_SIZES);
    int n = (int) s.getSize() / Native.SIZE_T_SIZE;
    NativeSize[] sizes = readNSArray(s, n);
    // int[] sizes = new int[n];
    // for (int i = 0; i < n; i++) {
    //	sizes[i] = s.getNativeLong(i * Native.LONG_SIZE).intValue();
    // }

    Memory[] binMems = new Memory[n];
    Memory ptrs = new Memory(n * Native.POINTER_SIZE);
    for (int i = 0; i < n; i++) {
      ptrs.setPointer(i * Native.POINTER_SIZE, binMems[i] = new Memory(sizes[i].intValue()));
    }
    error(
        infos.getInfo(
            getEntity(),
            CL_PROGRAM_BINARIES,
            toNS(ptrs.getSize() * Native.POINTER_SIZE),
            ptrs,
            null));

    Map<CLDevice, byte[]> ret = new HashMap<CLDevice, byte[]>(devices.length);
    int iBin = n == devices.length + 1 ? 1 : 0;
    for (int i = 0; i < n; i++) {
      CLDevice device = devices[i];
      Memory bytes = binMems[iBin + i];
      if (bytes != null) ret.put(device, bytes.getByteArray(0, sizes[iBin + i].intValue()));
    }
    return ret;
  }
  /** Get the source code of this program */
  public synchronized String getSource() {
    if (source == null) source = infos.getString(getEntity(), CL_PROGRAM_SOURCE);

    return source;
  }