Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
40db267c
Commit
40db267c
authored
Aug 24, 2021
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
making work with cuda-11.2.0 and eclipse-21-06
parent
0246d531
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
28951 deletions
+53
-28951
pom.xml
pom.xml
+47
-5
AberrationsOld.java
...in/java/com/elphel/imagej/calibration/AberrationsOld.java
+0
-14376
Aberrations_all.java
...n/java/com/elphel/imagej/calibration/Aberrations_all.java
+0
-14312
Eyesis_Correction.java
.../java/com/elphel/imagej/correction/Eyesis_Correction.java
+6
-8
JCuda_ImageJ_Example_Plugin.java
...va/com/elphel/imagej/gpu/JCuda_ImageJ_Example_Plugin.java
+0
-250
No files found.
pom.xml
View file @
40db267c
...
@@ -35,8 +35,9 @@
...
@@ -35,8 +35,9 @@
<dependency>
<dependency>
<groupId>
org.jcuda
</groupId>
<groupId>
org.jcuda
</groupId>
<artifactId>
jcuda
</artifactId>
<artifactId>
jcuda
</artifactId>
<version>
1
0.1
.0
</version>
<version>
1
1.2
.0
</version>
</dependency>
</dependency>
<!-- <version>10.1.0</version> -->
<!--
<!--
As of 2018/09/11 TF for GPU on Maven supports CUDA 9.0 (vs latest 9.2)
As of 2018/09/11 TF for GPU on Maven supports CUDA 9.0 (vs latest 9.2)
Workaround:
Workaround:
...
@@ -164,11 +165,29 @@
...
@@ -164,11 +165,29 @@
</testResources>
</testResources>
<pluginManagement>
<pluginManagement>
<plugins>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-plugin-plugin
</artifactId>
<!-- https://stackoverflow.com/questions/35511860/how-do-i-get-my-eclipse-maven-project-to-automatically-update-its-classpath-when-->
<!-- -below version fixed "mvn clean install -U -X" -->
<version>
3.5.1
</version>
<!--
<goals>
<goal>descriptor</goal>
</goals> -->
<!-- Caused by: org.apache.maven.plugin.MojoExecutionException: Error extracting plugin descriptor: 'No mojo definitions were found for plugin: com.elphel:imagej-elphel.'
-->
<configuration><skipErrorNoDescriptorsFound>
true
</skipErrorNoDescriptorsFound></configuration>
</plugin>
<plugin>
<plugin>
<groupId>
org.eclipse.m2e
</groupId>
<groupId>
org.eclipse.m2e
</groupId>
<artifactId>
lifecycle-mapping
</artifactId>
<artifactId>
lifecycle-mapping
</artifactId>
<version>
1.0.0
</version>
<version>
1.0.0
</version>
<configuration>
<configuration>
<!-- <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> -->
<lifecycleMappingMetadata>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecutions>
<pluginExecution>
<pluginExecution>
...
@@ -193,10 +212,19 @@
...
@@ -193,10 +212,19 @@
<artifactId>
<artifactId>
maven-plugin-plugin
maven-plugin-plugin
</artifactId>
</artifactId>
<versionRange>
[3.3,)
</versionRange>
<!-- <versionRange>[3.3,)</versionRange> -->
<version>
3.4
</version>
<!-- <configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration> -->
<goals>
<goals>
<goal>
descriptor
</goal>
<goal>
descriptor
</goal>
</goals>
</goals>
<!-- <extractors>
<extractor/>
</extractors> -->
</pluginExecutionFilter>
</pluginExecutionFilter>
<action>
<action>
<ignore></ignore>
<ignore></ignore>
...
@@ -245,6 +273,15 @@
...
@@ -245,6 +273,15 @@
<!-- <item>foxel-MRHM7AP</item> -->
<!-- <item>foxel-MRHM7AP</item> -->
</items>
</items>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.8.1
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</pluginManagement>
</pluginManagement>
...
@@ -281,8 +318,13 @@
...
@@ -281,8 +318,13 @@
<id>
other
</id>
<id>
other
</id>
<url>
http://mirror.elphel.com/maven-dependencies
</url>
<url>
http://mirror.elphel.com/maven-dependencies
</url>
</repository>
</repository>
<!--
<repository>
<id>mvnrepository</id>
<url>https://mvnrepository.com/artifact</url>
</repository>
-->
</repositories>
</repositories>
<scm>
<scm>
<connection>
scm:git:git://git.elphel.com/Elphel/imagej-elphel
</connection>
<connection>
scm:git:git://git.elphel.com/Elphel/imagej-elphel
</connection>
<developerConnection>
scm:git:https://git.elphel.com/Elphel/imagej-elphel
</developerConnection>
<developerConnection>
scm:git:https://git.elphel.com/Elphel/imagej-elphel
</developerConnection>
...
...
src/main/java/com/elphel/imagej/calibration/AberrationsOld.java
deleted
100644 → 0
View file @
0246d531
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/calibration/Aberrations_all.java
deleted
100644 → 0
View file @
0246d531
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/correction/Eyesis_Correction.java
View file @
40db267c
...
@@ -84,7 +84,7 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
...
@@ -84,7 +84,7 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
import
com.elphel.imagej.common.WindowTools
;
import
com.elphel.imagej.common.WindowTools
;
import
com.elphel.imagej.dct.FactorConvKernel
;
import
com.elphel.imagej.dct.FactorConvKernel
;
import
com.elphel.imagej.gpu.GPUTileProcessor
;
import
com.elphel.imagej.gpu.GPUTileProcessor
;
import
com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin
;
//
import com.elphel.imagej.gpu.JCuda_ImageJ_Example_Plugin;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
com.elphel.imagej.lwir.LwirReader
;
import
com.elphel.imagej.lwir.LwirReader
;
import
com.elphel.imagej.readers.EyesisTiff
;
import
com.elphel.imagej.readers.EyesisTiff
;
...
@@ -5214,7 +5214,7 @@ private Panel panel1,
...
@@ -5214,7 +5214,7 @@ private Panel panel1,
/* ======================================================================== */
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"JCUDA TEST"
))
{
}
else
if
(
label
.
equals
(
"JCUDA TEST"
))
{
/*
ImagePlus impl = WindowManager.getCurrentImage();
ImagePlus impl = WindowManager.getCurrentImage();
if (impl!=null) {
if (impl!=null) {
...
@@ -5222,17 +5222,15 @@ private Panel panel1,
...
@@ -5222,17 +5222,15 @@ private Panel panel1,
JCuda_ImageJ_Example_Plugin jcuda = new JCuda_ImageJ_Example_Plugin();
JCuda_ImageJ_Example_Plugin jcuda = new JCuda_ImageJ_Example_Plugin();
/*
// In a standalone test JCUDA plugin it's unknown where .setup() is called from...
* In a standalone test JCUDA plugin it's unknown where .setup() is called from...
// As well as .run(). But it works like this.
* As well as .run(). But it works like this.
*/
jcuda.setup(null,impl);
jcuda.setup(null,impl);
jcuda.run(impr);
jcuda.run(impr);
}else {
}else {
System.out.println("Missing the current image. Open one.");
System.out.println("Missing the current image. Open one.");
}
}
*/
return
;
return
;
/* ======================================================================== */
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"TF TEST"
))
{
}
else
if
(
label
.
equals
(
"TF TEST"
))
{
...
@@ -11609,7 +11607,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
...
@@ -11609,7 +11607,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
stack
.
addSlice
(
"Pr"
,
fpixels_pr
);
stack
.
addSlice
(
"Pr"
,
fpixels_pr
);
stack
.
addSlice
(
"Pb"
,
fpixels_pb
);
stack
.
addSlice
(
"Pb"
,
fpixels_pb
);
stack
.
addSlice
(
"Y"
,
fpixels_y
);
stack
.
addSlice
(
"Y"
,
fpixels_y
);
stack
.
addSlice
(
"Y0"
,
fpixels_y0
);
// not filtered by low-pass, preliminary (for com
ap
rison only)
stack
.
addSlice
(
"Y0"
,
fpixels_y0
);
// not filtered by low-pass, preliminary (for com
pa
rison only)
if
(
DEBUG_LEVEL
>
2
)
{
if
(
DEBUG_LEVEL
>
2
)
{
stack
.
addSlice
(
"Yr"
,
fpixels_yR
);
stack
.
addSlice
(
"Yr"
,
fpixels_yR
);
stack
.
addSlice
(
"Yg"
,
fpixels_yG
);
stack
.
addSlice
(
"Yg"
,
fpixels_yG
);
...
...
src/main/java/com/elphel/imagej/gpu/JCuda_ImageJ_Example_Plugin.java
deleted
100644 → 0
View file @
0246d531
package
com
.
elphel
.
imagej
.
gpu
;
/**
* ImageJ Plugin using JCuda
*
* Copyright (c) 2013-2018 Marco Hutter - http://www.jcuda.org
*/
import
static
jcuda
.
driver
.
JCudaDriver
.
cuCtxCreate
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuCtxSynchronize
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuDeviceGet
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuInit
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuLaunchKernel
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuMemAlloc
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuMemFree
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuMemcpyDtoH
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuMemcpyHtoD
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuModuleGetFunction
;
import
static
jcuda
.
driver
.
JCudaDriver
.
cuModuleLoadData
;
import
static
jcuda
.
nvrtc
.
JNvrtc
.
nvrtcCompileProgram
;
import
static
jcuda
.
nvrtc
.
JNvrtc
.
nvrtcCreateProgram
;
import
static
jcuda
.
nvrtc
.
JNvrtc
.
nvrtcDestroyProgram
;
import
static
jcuda
.
nvrtc
.
JNvrtc
.
nvrtcGetPTX
;
import
static
jcuda
.
nvrtc
.
JNvrtc
.
nvrtcGetProgramLog
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Scanner
;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.plugin.filter.PlugInFilter
;
import
ij.process.ImageProcessor
;
import
jcuda.Pointer
;
import
jcuda.Sizeof
;
import
jcuda.driver.CUcontext
;
import
jcuda.driver.CUdevice
;
import
jcuda.driver.CUdeviceptr
;
import
jcuda.driver.CUfunction
;
import
jcuda.driver.CUmodule
;
import
jcuda.driver.JCudaDriver
;
import
jcuda.nvrtc.JNvrtc
;
import
jcuda.nvrtc.nvrtcProgram
;
/**
* A simple example for an ImageJ Plugin that uses JCuda.
*/
public
class
JCuda_ImageJ_Example_Plugin
implements
PlugInFilter
{
/**
* The current image to operate on
*/
private
ImagePlus
currentImage
=
null
;
/**
* The kernel function
*/
private
CUfunction
kernelFunction
=
null
;
@Override
public
void
run
(
ImageProcessor
imageProcessor
)
{
int
[]
pixels
=
(
int
[])
imageProcessor
.
getPixels
();
int
w
=
imageProcessor
.
getWidth
();
int
h
=
imageProcessor
.
getHeight
();
execute
(
pixels
,
w
,
h
);
currentImage
.
updateAndDraw
();
}
/**
* Will execute the CUDA kernel with the given parameters
*
* @param pixels An array containing the pixels of the
* image as RGB integers
* @param w The width of the image
* @param h The height of the image
*/
void
execute
(
int
pixels
[],
int
w
,
int
h
)
{
if
(
kernelFunction
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"The kernel was not initialized"
);
return
;
}
// Allocate memory on the device, and copy the host data to the device
int
size
=
w
*
h
*
Sizeof
.
INT
;
CUdeviceptr
pointer
=
new
CUdeviceptr
();
cuMemAlloc
(
pointer
,
size
);
cuMemcpyHtoD
(
pointer
,
Pointer
.
to
(
pixels
),
size
);
// Set up the kernel parameters: A pointer to an array
// of pointers which point to the actual values.
Pointer
kernelParameters
=
Pointer
.
to
(
Pointer
.
to
(
pointer
),
Pointer
.
to
(
new
int
[]
{
w
}),
Pointer
.
to
(
new
int
[]
{
h
})
);
// Call the kernel function
int
blockSize
=
16
;
int
gridSize
=
(
Math
.
max
(
w
,
h
)
+
blockSize
-
1
)
/
blockSize
;
cuLaunchKernel
(
kernelFunction
,
gridSize
,
gridSize
,
1
,
// Grid dimension
blockSize
,
blockSize
,
1
,
// Block dimension
0
,
null
,
// Shared memory size and stream
kernelParameters
,
null
// Kernel- and extra parameters
);
cuCtxSynchronize
();
// Copy the data from the device back to the host and clean up
cuMemcpyDtoH
(
Pointer
.
to
(
pixels
),
pointer
,
size
);
cuMemFree
(
pointer
);
}
@Override
public
int
setup
(
String
arg
,
ImagePlus
imagePlus
)
{
if
(
arg
!=
null
&&
arg
.
equals
(
"about"
))
{
IJ
.
showMessage
(
"About JCuda ImageJ Plugin..."
,
"An example of an ImageJ plugin using JCuda\n"
);
return
DOES_RGB
;
}
currentImage
=
imagePlus
;
// Enable exceptions and omit all subsequent error checks
JCudaDriver
.
setExceptionsEnabled
(
true
);
JNvrtc
.
setExceptionsEnabled
(
true
);
// Initialize the driver and create a context for the first device.
cuInit
(
0
);
CUdevice
device
=
new
CUdevice
();
cuDeviceGet
(
device
,
0
);
CUcontext
context
=
new
CUcontext
();
cuCtxCreate
(
context
,
0
,
device
);
// Obtain the CUDA source code from the CUDA file
String
cuFileName
=
"JCudaImageJExampleKernel.cu"
;
String
sourceCode
=
readResourceAsString
(
cuFileName
);
if
(
sourceCode
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"Could not read the kernel source code"
);
return
DOES_RGB
;
}
// Create the kernel function
this
.
kernelFunction
=
createFunction
(
sourceCode
,
"invert"
);
return
DOES_RGB
;
}
/**
* Create the CUDA function object for the kernel function with the
* given name that is contained in the given source code
*
* @param sourceCode The source code
* @param kernelName The kernel function name
* @return
*/
private
static
CUfunction
createFunction
(
String
sourceCode
,
String
kernelName
)
{
// Use the NVRTC to create a program by compiling the source code
nvrtcProgram
program
=
new
nvrtcProgram
();
nvrtcCreateProgram
(
program
,
sourceCode
,
null
,
0
,
null
,
null
);
nvrtcCompileProgram
(
program
,
0
,
null
);
// Obtain the compilation log, and print it if it is not empty
// (for the case there are any warnings)
String
programLog
[]
=
new
String
[
1
];
nvrtcGetProgramLog
(
program
,
programLog
);
String
log
=
programLog
[
0
].
trim
();
if
(!
log
.
isEmpty
())
{
System
.
err
.
println
(
"Program compilation log:\n"
+
log
);
}
// Obtain the PTX ("CUDA Assembler") code of the compiled program
String
[]
ptx
=
new
String
[
1
];
nvrtcGetPTX
(
program
,
ptx
);
nvrtcDestroyProgram
(
program
);
// Create a CUDA module from the PTX code
CUmodule
module
=
new
CUmodule
();
cuModuleLoadData
(
module
,
ptx
[
0
]);
// Obtain the function pointer to the kernel function from the module
CUfunction
function
=
new
CUfunction
();
cuModuleGetFunction
(
function
,
module
,
kernelName
);
return
function
;
}
/**
* Read the resource with the given name, and return its contents as
* a string. Returns <code>null</code> if the resource cannot be found
* or read.
*
* @param name The name of the resource
* @return The contents of the resource
*/
private
static
String
readResourceAsString
(
String
name
)
{
InputStream
inputStream
=
JCuda_ImageJ_Example_Plugin
.
class
.
getResourceAsStream
(
name
);
if
(
inputStream
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"Resource was not found:\n"
+
name
);
return
null
;
}
try
{
return
readStreamAsString
(
inputStream
);
}
catch
(
IOException
e
)
{
IJ
.
showMessage
(
"Error"
,
"Could not read the resource:\n"
+
e
.
getMessage
());
return
null
;
}
}
/**
* Read the contents of the given input stream, and return it as a string
*
* @param inputStream The input stream
* @return The string
* @throws IOException If the input cannot be read
*/
private
static
String
readStreamAsString
(
InputStream
inputStream
)
throws
IOException
{
try
(
Scanner
s
=
new
Scanner
(
inputStream
))
{
Scanner
scanner
=
s
.
useDelimiter
(
"\\A"
);
if
(
scanner
.
hasNext
())
{
return
s
.
next
();
}
throw
new
IOException
(
"Could not read input stream"
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment