Skip to content

Commit 3926f9f

Browse files
committed
Add Scaladoc for basic usage of gpu and cpu
1 parent c5b08e2 commit 3926f9f

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

cpu/build.sbt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
11
enablePlugins(Example)
2+
3+
import scala.meta._
4+
exampleSuperTypes := exampleSuperTypes.value.map {
5+
case ctor"_root_.org.scalatest.FreeSpec" =>
6+
ctor"_root_.org.scalatest.AsyncFreeSpec"
7+
case otherTrait =>
8+
otherTrait
9+
}
10+
11+
libraryDependencies += ("org.lwjgl" % "lwjgl" % "3.1.6" % Test).jar().classifier {
12+
import scala.util.Properties._
13+
if (isMac) {
14+
"natives-macos"
15+
} else if (isLinux) {
16+
"natives-linux"
17+
} else if (isWin) {
18+
"natives-windows"
19+
} else {
20+
throw new MessageOnlyException(s"lwjgl does not support $osName")
21+
}
22+
}
23+
24+
fork := true

cpu/src/main/scala/com/thoughtworks/compute/cpu.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ import com.thoughtworks.feature.Factory
44
import com.typesafe.scalalogging.StrictLogging
55
import org.lwjgl.opencl.CL10.CL_DEVICE_TYPE_CPU
66

7+
/** Contains N-dimensional array types on GPU.
8+
*
9+
* You may want to import [[Tensor]], which is the base type of N-dimensional arrays:
10+
*
11+
* {{{
12+
* import com.thoughtworks.compute.cpu.Tensor
13+
* }}}
14+
*
15+
* @example In Compute.scala, an N-dimensional array is typed as [[Tensor]],
16+
* which can be created from [[scala.collection.Seq]] or [[scala.Array]].
17+
*
18+
* {{{
19+
* val my2DArray: Tensor = Tensor(Array(Seq(1.0f, 2.0f), Seq(3.0f, 4.0f)))
20+
*
21+
* my2DArray.toString should be("[[1.0,2.0],[3.0,4.0]]")
22+
* }}}
23+
*
24+
*/
725
object cpu
826
extends StrictLogging
927
with Tensors.UnsafeMathOptimizations

gpu/src/main/scala/com/thoughtworks/compute/gpu.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package com.thoughtworks.compute
22

3-
import com.thoughtworks.feature.Factory
43
import com.typesafe.scalalogging.StrictLogging
5-
import org.lwjgl.opencl.CL10.CL_DEVICE_TYPE_CPU
64

5+
/** Contains N-dimensional array types on CPU.
6+
*
7+
* All the usage of this [[gpu]] object is same as [[cpu]], except the `import` statement:
8+
*
9+
* {{{
10+
* import com.thoughtworks.compute.gpu._
11+
* }}}
12+
*
13+
* @see [[cpu]] for Usage.
14+
*/
715
object gpu
816
extends StrictLogging
917
with Tensors.UnsafeMathOptimizations

0 commit comments

Comments
 (0)