So I have the following code which when run throws both a stack overflow exception and an access violation writing location ... error. Specifically at the first line in main(). When I go into the debugger, it states the value of aSize as 1741172928. It bounces between saying "exception unhandled" and "exception thrown". The exact error presented in the error list is longer than I think would be appreciated so I'll hold off on that. Thank you in advance for any help!
EDIT: The addWithCuda(...) method was confirmed working before this whole thing so I don't think it has anything to do with that. In the debugger, it can't even get that far in the first place anyways
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <math.h>
#include <stdio.h>
#include <iostream>
#define HEIGHT 800
#define WIDTH 800
#define blockLength 8
using namespace std;
int main(){
const int aSize = 5;
const int a[aSize] = { 1, 2, 3, 4, 5 };
const int b[aSize] = { 10, 20, 30, 40, 50 };
const int c[aSize] = { 0 };
// Add vectors in parallel.
cudaError_t cudaStatus = addWithCuda(c, a, b, aSize);
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "addWithCuda failed!");
return 1;
}
printf("{1,2,3,4,5} + {10,20,30,40,50} = {%d,%d,%d,%d,%d}\n",
c[0], c[1], c[2], c[3], c[4]);
//Zoom=2^zoomfactor
const double zoomFactor = 0;
const double zoom = pow(2,zoomFactor);
//Displacement of the center of the image with respect to the origin
const double delX = 0;
const double delY = 0;
const double minX = -2 / zoom + delX;
const double maxX = 2 / zoom + delX;
const double minY = -2 / zoom + delY;
const double maxY = 2 / zoom + delY;
//Maximum number of iterations
const int maxIterations = 50*(1+round(zoomFactor));
//Magnitude threshold for convergence
const int threshold = 4;
//Array to keep track of returned iteration counts
int iterationCount[HEIGHT*WIDTH];
//
// cudaDeviceReset must be called before exiting in order for profiling and
// tracing tools such as Nsight and Visual Profiler to show complete traces.
cudaStatus = cudaDeviceReset();
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "cudaDeviceReset failed!");
return 1;
}
return 0;}