Skip to content

A mini project that includes calculations related to light propagation. The following technologies are used: C ++ & CUDA & OpenMP.

Notifications You must be signed in to change notification settings

Samox1/Light-Propagation-Cpp-Cuda-OpenMP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Light Propagation using Modified Convolution Propagation Method and GPU

Project uses C++ and CUDA (and OpenMP in future)

Adapted by: Szymon Baczyński (Warsaw University of Technology)
Date: 24.10.2019

The program is briefly carried out in the following steps (paper):

  1. Creation of a two-dimensional array with BMP-defined dimensions (the array is a slide through which light will propagate).
  2. Enter the table created in step 1 to X (usually twice) as large a table (smaller table placed in the center of a larger one).
  3. The newly created table (now called the input table) is copied to the graphics card (GPU).
  4. The Fast Fourier Transform (FFT) of the input table is counted on the GPU.
  5. CPU calculates a two-dimensional impulse response table (h(z) - depending on the propagation distance z) and sends it to the GPU.
  6. GPU calculate the FFT of the impulse response and then multiply the input table transform with the impulse response transform.
  7. The result of multiplication is subjected to the Inverse Fourier Transform. After performing the IFFT, its result is copied from the GPU to the host.
  8. The resulting data table is subjected to the ROLL operation - quadrant swapping for the correct result.
  9. The final result is saved to a file (BMP - Grayscale) in the form of an amplitude.

TO DO LIST:

  • Import TXT file with "HOLE" as 0-255 Grayscale
  • Perform calculation on CPU and GPU (CUDA)
  • Export TXT file after calculations
  • Import BMP (take only Green channel)
  • Export BMP (as Grayscale)
  • Check CUDA compatible devices
  • Clean Code
  • Slice STL files

Compilation, Launch and Output of the program:

Code for calculations of Light Propagation is in: cudaOpenMP.cu
Makefile for compilation (from CUDA example): Makefile

Simple Compile Command:

/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -Xcompiler -fopenmp -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o cudaOpenMP -c cudaOpenMP.cu -lgomp -lcufft

Launch Command:

Template command: [XXX]$ ./cudaOpenMP BMP_in Multi Z_in Lambda Sampling
Example command: [XXX]$ ./cudaOpenMP Test_NTO_1024.bmp 2 500.0 633.0 10.0

BMP_in - BMP file as "HOLE"
Multi - Multiplier for temporary array (usually =2) (int)
Z_in - Propagation Distance in milimeters [mm] (double)
Lambda - Wavelength in nanometers [nm] (double)
Sampling - Space between each pixels in micrometers [microm] (double)

Output File:

Template for Output file: z_%.3lf-m_lam_%.1lf-nm_samp_%.1lf-micro.BMP
Example output file: z_0.500-m_lam_450.0-nm_samp_10.0-micro.BMP

About

A mini project that includes calculations related to light propagation. The following technologies are used: C ++ & CUDA & OpenMP.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published