53 lines
1.2 KiB
Plaintext
53 lines
1.2 KiB
Plaintext
|
|
#include "cuda_runtime.h"
|
|
#include "device_launch_parameters.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <sys/time.h>
|
|
|
|
#include "../config.cuh"
|
|
#include "../utils.cuh"
|
|
|
|
__host__ float *compute_jacobi(int n, float init_value, float threshold, borders b, int *iterations);
|
|
|
|
__host__ int main(int argc, char* argv[]) {
|
|
int n;
|
|
float init_value, threshold;
|
|
borders b;
|
|
int config_loaded;
|
|
configuration config;
|
|
float *x;
|
|
int iterations;
|
|
struct timeval start, end;
|
|
long secs_used, micros_used;
|
|
|
|
config_loaded = load_config(&config);
|
|
if (config_loaded != 0) {
|
|
return 1;
|
|
}
|
|
n = config.n;
|
|
threshold = config.threshold;
|
|
init_value = config.init_value;
|
|
b.north = config.north;
|
|
b.south = config.south;
|
|
b.east = config.east;
|
|
b.west = config.west;
|
|
|
|
gettimeofday(&start, NULL);
|
|
x = compute_jacobi(n, init_value, threshold, b, &iterations);
|
|
gettimeofday(&end, NULL);
|
|
|
|
secs_used = (end.tv_sec - start.tv_sec);
|
|
micros_used = ((secs_used * 1000000) + end.tv_usec) - (start.tv_usec);
|
|
printf("Wall clock time: %fs\n", (float)micros_used / 1000000);
|
|
printf("Iterations: N/A\n", iterations);
|
|
if (n < 10) {
|
|
print_sa_matrix(x, n + 2, n + 2);
|
|
}
|
|
destroy_sa_matrix(x);
|
|
|
|
return 0;
|
|
}
|