 
   Arguments and their default values:
 
-      :context - existing CLContext or result of make-context
-      :device  - existing CLDevice, device type keyword or result of
-                 calling max-flops device for context
-      :queue   - existing CLCommandQueue or result of calling
-                 make-commandqueue for device
-      :program - optional, no default, if given must be one of:
-                 1) an input stream to the program's source code
-                 2) a vector of input stream and build option keywords
-                    (see build-options for possible values)"
-  [& {:keys [context device queue program]}]
-  (let [ctx (or context (make-context))]
+      :platform - existing CLPlatform or result of select-platform w/o args
+      :context  - existing CLContext or result of make-context w/ platform
+      :device   - existing CLDevice, device type keyword or result of
+                  calling max-flops device for context
+      :queue    - existing CLCommandQueue or result of calling
+                  make-commandqueue for device
+      :program  - optional, no default, if given must be one of:
+                  1) an input stream to the program's source code
+                  2) a vector of input stream and build option keywords
+                     (see build-options for possible values)"
+  [& {:keys [platform context device queue program]}]
+  (let [platform (or platform (select-platform))
+        ctx (or context (make-context platform))]
     (with-context ctx
       (let [device (cond (nil? device) (max-device)
-                     (keyword? device) (max-device ctx device)
-                     :default device)
+                         (keyword? device) (max-device ctx device)
+                         :default device)
             queue (or queue (make-commandqueue device))
             program (when program
                       (if (vector? program)
                         (apply make-program program)
                         (make-program program)))]
-      {:ctx ctx :device device :queue queue :program program}))))
+        {:ctx ctx :device device :queue queue :program program}))))
 
 (defn ^CLCommandQueue enqueue
   "Submits the given buffers and kernels to the current command `*queue*` for

(defn ^:private buffer-seq-generic
  [^Buffer b]
  (lazy-seq
    (when (pos? (.remaining b))
      (cons (.get b) (buffer-seq-generic b)))))

(defn buffer-seq
  "Produces a lazy-seq of the remaining values in the given NIO buffer."

     [^{:tag ~type} b# & usage#]
     (let [b#
           (if (.isDirect b#) b#
               (let [^ByteBuffer dest# (Buffers/newDirectByteBuffer (* ~size (.remaining b#)))]
                 (-> dest# (~view) (.put b#))
                 (rewind b# dest#)))]
       (.createBuffer ^CLContext *context* b#
                      (clu/args->array usage-types (or usage# [:readwrite]))))))

(as-clbuffer* ByteBuffer identity Buffers/SIZEOF_BYTE)
(as-clbuffer* FloatBuffer .asFloatBuffer Buffers/SIZEOF_FLOAT)
