semi working ver with okayish performance

parent c297970b
CFLAGS = -Wno-unused-command-line-argument -Wno-missing-field-initializers -Wall -Wextra -Wpedantic -lm -fopenmp
CFLAGS = -Wno-unused-command-line-argument -Wno-missing-field-initializers -Wall -Wextra -Wpedantic -lm
OPENMPFLAGS= -fopenmp
CLFLAGS= -D CL_TARGET_OPENCL_VERSION=100 -lOpenCL
DEBUG_CFLAGS = -g -DDEBUG -pg -O0
LDLIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
#CFLAGS := $(CFLAGS) -O3
CFLAGS := $(CFLAGS) $(DEBUG_CFLAGS)
CFLAGS := $(CFLAGS) $(DEBUG_CFLAGS) $(CLFLAGS) $(OPENMPFLAGS)
SRCDIR=src
BIULDDIR=build
......
No preview for this file type
No preview for this file type
......@@ -7,6 +7,8 @@
#include <stdio.h>
#include <SDL2/SDL.h>
#include <complex.h>
#include <CL/cl.h>
//#include <omp.h>
#include "mandelbrot.h"
#include "mouse.h"
......@@ -45,6 +47,7 @@ void
calculate_set(Array *arr, int height, int width, ViewInfo view)
{
//printf("arr size: %d, screen %d\n", arr->size, height * width);
#pragma omp parallel for schedule(guided)
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
double real = view.x_min + (x * (view.x_max - view.x_min)) / width;
......@@ -69,12 +72,12 @@ calculate_set(Array *arr, int height, int width, ViewInfo view)
}
void
render_cl(Array *arr, App *app, ViewInfo view, int start_x, int start_y) {
render_cl(Array *arr, App *app, ViewInfo view) {
SDL_SetRenderDrawColor(app->renderer, 0, 0, 50, 255);
SDL_RenderClear(app->renderer);
if (arr->size < app->win_height * app->win_width * sizeof(Color)){
if (arr->size < app->win_height * app->win_width * (int)sizeof(Color)){
arr->pointer = realloc(arr->pointer, app->win_height * app->win_width * sizeof(Color));
arr->size = app->win_height * app->win_width * sizeof(Color);
}
......@@ -129,7 +132,7 @@ render(App *app, ViewInfo view, int start_x, int end_x, int start_y, int end_y)
int
main(int argc, char *argv[])
main(void)
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
printf("error initializing SDL: %s\n", SDL_GetError());
......@@ -229,7 +232,7 @@ main(int argc, char *argv[])
//drawing happens here
SDL_SetRenderDrawColor(app.renderer, 0xff, 0xff, 0xff, 0xff);
SDL_RenderClear(app.renderer);
render_cl(&screen, &app, view, 0, 0);
render_cl(&screen, &app, view);
// render(&app,
// view,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment