Skip to content

Commit 87540d8

Browse files
authored
Merge pull request #123 from Kotlin/develop
release 0.2.0
2 parents ad39af8 + 82c36a6 commit 87540d8

File tree

200 files changed

+7939
-3700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+7939
-3700
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ _deps
6464
*.tar.gz
6565
*.rar
6666

67+
# Kotlin/JS
68+
kotlin-js-store/
69+
6770
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
6871
hs_err_pid*
6972

@@ -124,3 +127,5 @@ out/
124127

125128
# mpeltonen/sbt-idea plugin
126129
.idea_modules/
130+
131+
.DS_Store

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2000-2021 JetBrains s.r.o.
190+
Copyright 2000-2022 JetBrains s.r.o.
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

README.md

Lines changed: 95 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
[![Kotlin Alpha](https://kotl.in/badges/alpha.svg)](https://kotlinlang.org/docs/components-stability.html)
12
[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
2-
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-api)](https://mvnrepository.com/artifact/org.jetbrains.kotlinx/multik-api)
3+
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-core)](https://mvnrepository.com/artifact/org.jetbrains.kotlinx/multik-core)
34
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
45

56
# Multik
67

78
Multidimensional array library for Kotlin.
89

910
## Modules
10-
* multik-api — contains ndarrays, methods called on them and [math], [stat] and [linalg] interfaces.
11-
* multik-default — implementation including `jvm` and `native` for performance.
12-
* multik-jvm — implementation of [math], [stat] and [linalg] interfaces on JVM.
13-
* multik-native — implementation of [math], [stat] and [linalg] interfaces in native code using OpenBLAS.
11+
* `multik-core` — contains ndarrays, methods called on them and [math], [stat] and [linalg] interfaces.
12+
* `multik-default` — implementation including `multik-kotlin` and `multik-openblas` for performance.
13+
* `multik-kotlin` — implementation of [math], [stat] and [linalg] interfaces on JVM.
14+
* `multik-openblas` — implementation of [math], [stat] and [linalg] interfaces in native code using OpenBLAS.
1415

1516
## Using in your projects
17+
### Gradle
1618
In your Gradle build script:
1719
1. Add the Maven Central Repository.
18-
2. Add the `org.jetbrains.kotlinx:multik-api:$multik_version` api dependency.
20+
2. Add the `org.jetbrains.kotlinx:multik-core:$multik_version` api dependency.
1921
3. Add an implementation dependency: `org.jetbrains.kotlinx:multik-default:$multik_version`,
20-
`org.jetbrains.kotlinx:multik-jvm:$multik_version` or `org.jetbrains.kotlinx:multik-native:$multik_version`.
22+
`org.jetbrains.kotlinx:multik-kotlin:$multik_version` or `org.jetbrains.kotlinx:multik-openblas:$multik_version`.
2123

2224
`build.gradle`:
2325
```groovy
@@ -26,8 +28,8 @@ repositories {
2628
}
2729
2830
dependencies {
29-
implementation "org.jetbrains.kotlinx:multik-api:0.1.1"
30-
implementation "org.jetbrains.kotlinx:multik-default:0.1.1"
31+
implementation "org.jetbrains.kotlinx:multik-core:0.2.0"
32+
implementation "org.jetbrains.kotlinx:multik-default:0.2.0"
3133
}
3234
```
3335

@@ -38,11 +40,73 @@ repositories {
3840
}
3941

4042
dependencies {
41-
implementation("org.jetbrains.kotlinx:multik-api:0.1.1")
42-
implementation("org.jetbrains.kotlinx:multik-default:0.1.1")
43+
implementation("org.jetbrains.kotlinx:multik-core:0.2.0")
44+
implementation("org.jetbrains.kotlinx:multik-default:0.2.0")
4345
}
4446
```
4547

48+
For a multiplatform project, set the dependency in a common block:
49+
50+
```kotlin
51+
kotlin {
52+
sourceSets {
53+
val commonMain by getting {
54+
dependencies {
55+
implementation("org.jetbrains.kotlinx:multik-core:0.2.0")
56+
}
57+
}
58+
}
59+
}
60+
```
61+
62+
or in a platform-specific block:
63+
64+
```kotlin
65+
kotlin {
66+
sourceSets {
67+
val jvmName by getting {
68+
dependencies {
69+
implementation("org.jetbrains.kotlinx:multik-core-jvm:0.2.0")
70+
}
71+
}
72+
}
73+
}
74+
```
75+
76+
### Jupyter Notebook
77+
Install [Kotlin kernel](https://github.com/Kotlin/kotlin-jupyter) for
78+
[Jupyter](https://jupyter.org/)
79+
or just visit to [Datalore](https://datalore.jetbrains.com/).
80+
81+
Import stable `multik` version into notebook:
82+
```
83+
%use multik
84+
```
85+
86+
## Support platforms
87+
88+
| Platforms | `multik-core` | `multik-kotlin` | `multik-openblas` | `multik-default` |
89+
|:---------------------:|:------------------:|:------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
90+
| **JS** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
91+
| **linuxX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
92+
| **mingwX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
93+
| **macosX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
94+
| **macosArm64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
95+
| **iosArm64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
96+
| **iosX64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
97+
| **iosSimulatorArm64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
98+
| **JVM** | :white_check_mark: | :white_check_mark: | linuxX64 - :white_check_mark:<br/>mingwX64 - :white_check_mark:<br/>macosX64 - :white_check_mark:<br/>macosArm64 - :white_check_mark:<br/>androidArm64 - :white_check_mark: | linuxX64 - :white_check_mark:<br/>mingwX64 - :white_check_mark:<br/>macosX64 - :white_check_mark:<br/>macosArm64 - :white_check_mark:<br/>androidArm64 - :white_check_mark: |
99+
100+
For Kotlin/JS, we use the new [IR](https://kotlinlang.org/docs/js-ir-compiler.html).
101+
We also use the [new memory model](https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/)
102+
in Kotlin/Native. Keep this in mind when using Multik in your multiplatform projects.
103+
104+
**Note**:
105+
* on ubuntu 18.04 and older `multik-openblas` doesn't work due to older versions of _**glibc**_.
106+
* `multik-openblas` for desktop targets (_linuxX64_, _mingwX64_, _macosX64_, _macosArm64_) is experimental and unstable.
107+
We will improve stability and perfomance as _Kotlin/Native_ evolves.
108+
* JVM target `multik-openblas` for Android only supports **arm64-v8a** processors.
109+
46110
## Quickstart
47111

48112
Visit [Multik documentation](https://kotlin.github.io/multik) for a detailed feature overview.
@@ -101,7 +165,7 @@ mk.d2arrayIndices(3, 3) { i, j -> ComplexFloat(i, j) }
101165
[2.0+(0.0)i, 2.0+(1.0)i, 2.0+(2.0)i]]
102166
*/
103167

104-
mk.arange<Long>(10, 25, 5) // creare an array with elements in the interval [19, 25) with step 5
168+
mk.arange<Long>(10, 25, 5) // creare an array with elements in the interval [10, 25) with step 5
105169
/* [10, 15, 20] */
106170

107171
mk.linspace<Double>(0, 2, 9) // create an array of 9 elements in the interval [0, 2]
@@ -152,6 +216,12 @@ f * d // multiplication
152216
```
153217

154218
#### Array mathematics
219+
220+
See documentation for other methods of
221+
[mathematics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.math/index.html),
222+
[linear algebra](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.linalg/index.html),
223+
[statistics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.stat/index.html).
224+
155225
```kotlin
156226
a.sin() // element-wise sin, equivalent to mk.math.sin(a)
157227
a.cos() // element-wise cos, equivalent to mk.math.cos(a)
@@ -160,8 +230,6 @@ b.exp() // element-wise exp, equivalent to mk.math.exp(b)
160230
d dot e // dot product, equivalent to mk.linalg.dot(d, e)
161231
```
162232

163-
See [documentation](https://kotlin.github.io/multik) for other linear algebra methods.
164-
165233
#### Aggregate functions
166234
```kotlin
167235
mk.math.sum(c) // array-wise sum
@@ -229,24 +297,21 @@ a.inplace {
229297
```
230298

231299
## Building
232-
Multik uses BLAS and LAPACK for implementing algebraic operations.
233-
Therefore, you would need a C ++ compiler and gfortran.
234-
Run `./gradlew assemble` to build all modules.
235-
* To build api module run `./gradlew multik-api:assemble`.
236-
* To build jvm module run `./gradlew multik-jvm:assemble`.
237-
* To build native module run `./gradlew multik-native:assemble`.
238-
To reuse `multik-native` in the future, you must first build `multik_jni` and place the native library in
239-
`multik-native/build/libs`
240-
* To build default module run `./gradlew multik-native:assemble` then `./gradlew multik-default:assemble`.
300+
To build the entire project, you need to set up an environment for building `multik-openblas`:
301+
* JDK 1.8 or higher
302+
* _JAVA_HOME_ environment - to search for jni files
303+
* Compilers _gcc_, _g++_, _gfortran_ version 8 or higher.
304+
It is important that they are of the same version.
241305

242-
## Testing
243-
`./gradlew test`
306+
Run `./gradlew assemble` to build all modules.
307+
If you don't need to build `multik-openblas`,
308+
just disable the `cmake_build` task and build the module you need.
244309

245310
## Contributing
246311
There is an opportunity to contribute to the project:
247-
1. Implement [math](multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt),
248-
[linalg](multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt),
249-
[stat](multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/Statistics.kt) interfaces.
250-
2. Create your own engine successor from [Engine](multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt), for example - [JvmEngine](multik-jvm/src/main/kotlin/org/jetbrains/kotlinx/multik/jvm/JvmEngine.kt).
251-
3. Use [mk.addEngine](https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-api/src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L23) and [mk.setEngine](https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-api/src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L27)
312+
1. Implement [math](multik-core/src/main/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt),
313+
[linalg](multik-core/src/main/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt),
314+
[stat](multik-core/src/main/kotlin/org/jetbrains/kotlinx/multik/api/Statistics.kt) interfaces.
315+
2. Create your own engine successor from [Engine](multik-core/src/main/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt), for example - [JvmEngine](multik-kotlin/src/main/kotlin/org/jetbrains/kotlinx/multik/jvm/JvmEngine.kt).
316+
3. Use [mk.addEngine](https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-core/src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L23) and [mk.setEngine](https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-core/src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L27)
252317
to use your implementation.

build.gradle.kts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
2-
* Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4-
5-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4+
import java.time.Duration
65

76
buildscript {
87
repositories {
@@ -14,13 +13,13 @@ plugins {
1413
val kotlin_version: String by System.getProperties()
1514
val nexus_version: String by System.getProperties()
1615

17-
kotlin("jvm") version kotlin_version
18-
id("io.codearte.nexus-staging") version nexus_version
16+
kotlin("multiplatform") version kotlin_version apply false
17+
id("io.github.gradle-nexus.publish-plugin") version nexus_version
1918
}
2019

2120
val kotlin_version: String by System.getProperties()
2221
val multik_version: String by project
23-
val unpublished = listOf("multik", "multik_jni")
22+
val unpublished = listOf("multik")
2423

2524
allprojects {
2625
repositories {
@@ -30,22 +29,27 @@ allprojects {
3029
group = "org.jetbrains.kotlinx"
3130
version = multik_version
3231

33-
tasks.withType<KotlinCompile> {
34-
kotlinOptions.jvmTarget = "1.8"
35-
}
3632
}
3733

38-
subprojects {
39-
if (!this.name.contains("jni")) {
40-
apply(plugin = "kotlin")
34+
configure(subprojects.filter { it.name !in unpublished }) {
35+
apply("$rootDir/gradle/publish.gradle")
36+
}
37+
38+
val sonatypeUser: String = System.getenv("SONATYPE_USER") ?: ""
39+
val sonatypePassword: String = System.getenv("SONATYPE_PASSWORD") ?: ""
4140

42-
dependencies {
43-
testImplementation(kotlin("test"))
44-
testImplementation(kotlin("test-junit"))
41+
nexusPublishing {
42+
packageGroup.set(project.group.toString())
43+
repositories {
44+
sonatype {
45+
username.set(sonatypeUser)
46+
password.set(sonatypePassword)
47+
repositoryDescription.set("kotlinx.multik staging repository, version: $version")
4548
}
4649
}
47-
}
4850

49-
configure(subprojects.filter { it.name !in unpublished }) {
50-
apply("$rootDir/gradle/publish.gradle")
51+
transitionCheckOptions {
52+
maxRetries.set(100)
53+
delayBetween.set(Duration.ofSeconds(5))
54+
}
5155
}

gradle.properties

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
kotlin.code.style=official
2+
multik_version=0.2.0
23

3-
multik_version=0.1.1
4+
# Kotlin
5+
systemProp.kotlin_version=1.7.10
6+
group=org.jetbrains.kotlinx
47

5-
systemProp.kotlin_version=1.5.31
6-
systemProp.nexus_version=0.22.0
7-
systemProp.dokka_version=1.5.31
8-
9-
openblas_version=0.3.18
8+
# Dependencies
9+
systemProp.nexus_version=1.1.0
10+
systemProp.dokka_version=1.7.10
11+
openblas_version=0.3.19
1012
common_csv_version=1.9.0
13+
14+
# Gradle
15+
org.gradle.parallel=true
16+
org.gradle.caching=true
17+
18+
# MPP
19+
kotlin.mpp.stability.nowarn=true
20+
kotlin.mpp.enableCInteropCommonization=true
21+
22+
# Native
23+
kotlin.native.cacheKind.linuxX64=static
24+
kotlin.native.cacheKind.iosArm64=static
25+
kotlin.native.binary.memoryModel=experimental
26+
27+
# Settings
28+
kotlin.incremental.multiplatform=true
29+
kotlin.native.ignoreDisabledTargets=true
30+
31+
# JS IR backend sometimes crashes with out-of-memory
32+
# Check KT-37187
33+
org.gradle.jvmargs=-Xmx3g

0 commit comments

Comments
 (0)