amcelroy / OpenCLV

OpenCL for Labview
7 stars 7 forks source link

Memory Leak in FFT computation #37

Open mrdvorsky opened 8 years ago

mrdvorsky commented 8 years ago

When computing an FFT repeatedly in certain situations, memory usage shoots up at a very fast rate until an FFT_FAILED message pops up. This only happens to me with 2D Complex_to_Complex or 2D Hermitian_to_Real (size is single prec 100 by 81 by 90 by the way). Exact same LabView code but with 3D instead of 2D produces no memory usage increase.

Looking in "clAmdFft.cpp" under "ComputeFFT()": The issue appears to be with the temporary buffer used in the enqueueTransform function. The buffer is allocated every time the FFT is computed, but it is never deallocated.

Simplest solution is just to never allocate it and let the enqueueTransform allocate its own memory by passing a NULL instead of an allocated buffer. Otherwise it should be allocated only once during FFT plan creation, and it should be deallocated when destroying the plan.

amcelroy commented 8 years ago

Howdy,

Thanks for tracking that down! I've nulled it out for now. Also, you are now a contributor if you would like to make and commit other changes.

Thanks, Austin

mrdvorsky commented 8 years ago

Awesome Thanks!

By the way, thanks so much for making this! Not including the issue you just fixed, everything has worked perfectly! I started using it a couple weeks ago to do real-time processing for a project I'm working on, and there's no way I could have done it without your work.

Unfortunately, Labview's CUDA library lacks features, especially the ability to make custom kernels, so even though I have a NVIDIA GPU your library is a much better alternative.

Just in case you're curious what I'm using your library for, here is a video showing the project. (3D Microwave Video Camera) https://www.youtube.com/watch?v=mK_zU-GHxRA

It's 3D in that we can focus to a distance away using the data from only one frame, and we can capture 30 frames per second. Right now, as you can see in the video, only one distance distance is being calculated. The goal is to calculate and show whats in front of the camera in 3D at a higher resolution than what is currently done (calculate ~128 distances and display all of them). That's where OpenCLV comes in, since the entire process needs to be done at 30fps.

amcelroy commented 8 years ago

Thanks for the kind words.

I work in Optical Coherence Tomography at University of Texas - Austin, right down the road from NI. We often speak to their R&D department but they never seem to have an interest in doing OpenCL, just CUDA and FPGA.

That is really impressive work! Can you focus sub-surface on tissue or is water absorption an issue? What resolution can you detect? Could you image blood at high frequencies? Are there some review papers I could read about the theory behind the work?

Again, thanks for you kind words, and pay it forward!

Austin McElroy

On Tue, May 10, 2016 at 10:16 AM, mrdvorsky notifications@github.com wrote:

Awesome Thanks!

By the way, thanks so much for making this! Not including the issue you just fixed, everything has worked perfectly! I started using it a couple weeks ago to do real-time processing for a project I'm working on, and there's no way I could have done it without your work.

Unfortunately, Labview's CUDA library lacks features, especially the ability to make custom kernels, so even though I have a NVIDIA GPU your library is a much better alternative.

Just in case you're curious what I'm using your library for, here is a video showing the project. (3D Microwave Video Camera) https://www.youtube.com/watch?v=mK_zU-GHxRA

It's 3D in that we can focus to a distance away using the data from only one frame, and we can capture 30 frames per second. Right now, as you can see in the video, only one distance distance is being calculated. The goal is to calculate and show whats in front of the camera in 3D at a higher resolution than what is currently done (calculate ~128 distances and display all of them). That's where OpenCLV comes in, since the entire process needs to be done at 30fps.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/amcelroy/OpenCLV/issues/37#issuecomment-218190374

mrdvorsky commented 8 years ago

Yeah that's too bad, although I can understand why they wouldn't want to. I've looked through a few of your publications. You've sure done a lot of impressive work! I'm just an undergrad at Missouri S&T right now so I haven't done too much in the way of research, but I'm getting into it.

I came in partway through the camera project after all of the antenna design. I only did the software and the control circuit board, so I'm probably not the best person to be describing this, but I'll tell you what I know :)

Water absorption is for sure an issue looking through tissue at the frequency we're doing (20-30GHz). We could look at the surface of the tissue (for analyzing burns and such), but not underneath. The resolution depends on the axis, because of the way the elements are spaced, so on the y-axis we have about 4mm resolution, and 11mm on the x-axis. The large 11mm resolution is because of the large spacing between each of the 16 circuit boards. The depth resolution is around 10-15mm, given our 10GHz bandwidth.

Again, since we can't see through tissue at high frequencies, imaging blood through skin is not feasible, but we can evaluate water content in skin, which can be used to detect various types of cancer (Search "microwave and millimeter wave skin cancer detection" on Google Scholar).

A paper is currently in review (as of recently) to be be published in IEEE detailing the camera design and experiment results, and I'm not sure when it will be published. There are some papers that go into the theory, though:

Resolution and Spacing http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=6045337&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D6045337

Weapon Detection http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=942570&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D942570

Previous Microwave Camera http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=6058691&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D6058691

Hopefully I answered your questions well enough. Sorry it took me so long to reply, I just started an internship last week so I've been pretty busy.