Skip to content

Commit

Permalink
PR fix: move kernel-info! into system
Browse files Browse the repository at this point in the history
  • Loading branch information
holyjak committed Jun 29, 2024
1 parent f9beec0 commit 5860dbc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ By linking the two:
* Wolframite provides the **seamless and transparent translation of native data structures** between Clojure and Wolfram. This includes high-precision numbers, matricies, N-dimensional arrays, and evaluated and unevaluated Mathematica expressions and formulae.
* Wolframite lets you **write Wolfram as if it was Clojure** by providing Clojure functions and vars for all Wolfram symbols, including docstrings and autocompletion in your favorite IDE
* [Tentative] Wolframite facilitates **the "Clojurization" of Wolfram's existing parallel-computing capabilities.** Wolfram is not designed for threads or concurrency. It has excellent support for parallel computation, but parallel evaluations are initiated from a single-threaded master kernel which blocks until all parallel evaluations return. By contrast, Wolframite includes a concurrency framework that lets multiple Clojure threads execute Wolfram expressions without blocking others. Now it is easy to run a simulation in Clojure with 1,000 independent threads asynchronously evaluating processor-intensive expressions in Wolfram. The computations will be farmed out adaptively and transparently to however many Wolfram kernels are available on any number of processor cores, either locally or across a cluster, grid, or network.
* Notice that you cannot run more Wolfram kernels than your license allows (see `wolframite/kernel-info!`)
* Notice that you cannot run more Wolfram kernels than your license allows (see `wolframite.runtime.system/kernel-info!`)

Wolframite is open-source and targeted at applications in scientific computing, computational economics, finance, and other fields that rely on the combination of parallelized simulation and high-performance number-crunching. Wolframite gives the programmer access to Clojure's most cutting-edge features--easy concurrency and multithreading, immutable persistent data structures, and software transactional memory---alongside Wolfram's easy-to-use algorithms for numerics, symbolic mathematics, optimization, statistics, visualization, and image-processing.

Expand Down
18 changes: 1 addition & 17 deletions src/wolframite/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,6 @@
```"
(promise))

(defn kernel-info!
"Fetches info about the Wolfram kernel, such as:
```clojure
{:wolfram-version 14.0
:wolfram-kernel-name \"Wolfram Language 14.0.0 Engine\"
:max-license-processes 2} ; how many concurrent kernels (=> Wolframite REPLs/processes) may we run
```
Requires [[init!]] to be called first."
[]
(zipmap
[:wolfram-version :wolfram-kernel-name :max-license-processes]
(eval '[$VersionNumber
(SystemInformation "Kernel", "ProductKernelName")
(SystemInformation "Kernel", "MaxLicenseProcesses")])))


(defn init!
"Initialize Wolframite and the underlying wolfram Kernel - required once before any eval calls."
Expand All @@ -153,7 +137,7 @@
(evaluator-init (merge {:jlink-instance jlink-inst}
opts))
(let [{:keys [wolfram-version]}
(doto (kernel-info!)
(doto (system/kernel-info!)
(->> (deliver kernel-info)))]
(when (and (number? wolfram-version)
(number? w/*wolfram-version*)
Expand Down
5 changes: 3 additions & 2 deletions src/wolframite/impl/wolfram_syms/write_ns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[wolframite.core :as core]
[wolframite.impl.wolfram-syms.intern :as intern]
[wolframite.impl.wolfram-syms.wolfram-syms :as wolfram-syms]
[wolframite.runtime.defaults :as defaults])
[wolframite.runtime.defaults :as defaults]
[wolframite.runtime.system :as system])
(:import (java.io FileNotFoundException PushbackReader)))

(comment
Expand Down Expand Up @@ -77,7 +78,7 @@
Requires that you've run `wl/init!` first."
([] (write-ns! "src/wolframite/wolfram.clj"))
([path]
(let [{:keys [wolfram-version wolfram-kernel-name]} (core/kernel-info!)]
(let [{:keys [wolfram-version wolfram-kernel-name]} (system/kernel-info!)]
(try
(spit path
(str/join "\n"
Expand Down
16 changes: 16 additions & 0 deletions src/wolframite/runtime/system.clj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@
(throw (ex-info (str "Could not find a Wolfram executable using the given base path. Are you sure that " base-path " exists?")
{:paths base-path})))))

(defn kernel-info!
"Fetches info about the Wolfram kernel, such as:
```clojure
{:wolfram-version 14.0
:wolfram-kernel-name \"Wolfram Language 14.0.0 Engine\"
:max-license-processes 2} ; how many concurrent kernels (=> Wolframite REPLs/processes) may we run
```
Requires [[init!]] to be called first."
[]
(zipmap
[:wolfram-version :wolfram-kernel-name :max-license-processes]
(eval '[$VersionNumber
(SystemInformation "Kernel", "ProductKernelName")
(SystemInformation "Kernel", "MaxLicenseProcesses")])))

(comment (defn common-path
"
The longest parental directory path that is common to both input paths.
Expand Down

0 comments on commit 5860dbc

Please sign in to comment.