Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Best way to output parallelized data to the window?  (Read 1145 times)

0 Members and 2 Guests are viewing this topic.

corcordp

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Best way to output parallelized data to the window?
« on: March 29, 2019, 07:54:03 pm »
--EDIT: Revised code--
(click to show/hide)



Hi guys, first time posting here...
I've been working on a mandelbrot plotting application. It works with CUDA, where each evaluated point on the complex plane is assigned an individual thread. The thread runs the mandelbrot iteration on it's assigned point.
The thread stops iterating when the iteration diverges, and a color (alpha channel format) value is assigned to the point.
These alpha values are stored in a uint8 array of size (x_resolution * y_resolution * 4).  Previously, I have used a rectangleShape and had the CPU manually plot each point, changing the fillcolor of the shape based on the data. This was very slow.
Some other people have shown that an array of uint8 can be turned into an sf::image by referring the array in the images constructor, but when I tried that I just got an error.

Here is the code for the version I am trying to get to work...

(click to show/hide)

When I compile this my IDE breaks
"Unhandled exception at 0x00007FFC5038122E (vcruntime140.dll) in debugBuild.exe: 0xC0000006: In page error reading location 0x0000000704800000 (status code 0xC0000022)."

Visual studio shows the break as occuring when I try to construct the image, on the line image.create(displayX, displayY, pixels);

displayX is the horizontal resolution. displayY is the vertical resolution. pixels is the uint8 array of alpha channels






here is the code for a version that does work (but draws to the renderwindow)
(click to show/hide)


I'm relatively new to c++ and SFML, are there any unrelated things could I be doing differently? I plan to consolidate the loose variables soon (hopefully within the settings class).

Thanks for the help,
Dan
« Last Edit: March 29, 2019, 11:49:39 pm by jppdan »

corcordp

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Best way to output parallelized data to the window?
« Reply #1 on: March 29, 2019, 08:17:31 pm »
I realized that when I allocated memory on the GPU for the uint8 array, I actually needed it to be 4*number of pixels... Now the image flashes for a brief second. Still some issues with the window scaling and the colors, but the lack of allocated memory was definitely the cause of this first issue.

 

anything