Implemented SIMD optimizations in tricorn_simd including negative height handling which needs to be fixed in normal tricorn.c

This commit is contained in:
go38coz
2026-06-26 22:38:55 +02:00
parent ee2b6b9506
commit 791231a4f5
3 changed files with 102 additions and 35 deletions
+8 -5
View File
@@ -6,6 +6,7 @@
#include <getopt.h> // for getopt_long
#include <string.h> // for strcpy
#include "tricorn.h"
#include "tricorn_simd.h"
void save_bmp(const char *filename, unsigned char *img, size_t width, ssize_t height,_Bool color);
@@ -17,7 +18,7 @@ unsigned tests(void) {
void benchmarking(void) {
// do the benchmarking
}
// REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920 1080 -o image.bmp -C
// REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920,-1080 -o image.bmp -C
const char* help_messsage = "Help Message\n\n"
"Usage:\n"
" ./tricorn [OPTIONS]\n\n"
@@ -200,7 +201,7 @@ int main(int argc, char** argv)
unsigned char tempArr[width*height*bytesPerColour]; // if not colored, rem
printf("yashar\n");
tricorn(complexA,width,height,resolution,n,colored,tempArr);
tricorn_simd(complexA,width,height,resolution,n,colored,tempArr);
printf("yashar\n");
save_bmp(output_data,tempArr,width,height,colored);
@@ -218,14 +219,16 @@ void save_bmp(const char *filename, unsigned char *img, size_t width, ssize_t he
exit(EXIT_FAILURE);
}
size_t bytesPerColor = color ? 3 : 1;
int actual_height = (height < 0) ? -height : height; // Calculate absolute height for iteration and calculation purposes
size_t row_padding = (4 - (width) * 3 % 4) % 4; // Calculate padding for each row as .bmp is 4 bytes aligned
size_t row_width = width * 3 + row_padding; // Calculate row width with padding
size_t row_padding = (4 - (width * bytesPerColor) % 4) % 4; // Calculate padding for each row as .bmp is 4 bytes aligned
size_t row_width = width * bytesPerColor + row_padding; // Calculate row width with padding
size_t image_size = actual_height * row_width;
size_t file_size = image_size + 54; // File size = Image Size + Headers
size_t bytesPerColor = color ? 3 : 1;
// File header - contains information about the file
unsigned char file_header[14] = {