#include #include #include #include #include #define SIMD_SIZE 8 typedef struct { double x; double y; } point; double sqr(double x) { return x*x; } double dist(point cities[], int i, int j) { return sqrt(sqr(cities[i].x-cities[j].x)+ sqr(cities[i].y-cities[j].y)); } double DistSqrd(point cities[], int i, int j) { return (sqr(cities[i].x-cities[j].x)+ sqr(cities[i].y-cities[j].y)); } void swap(point *p, point *q) { point tmp=*p; *p = *q; *q = tmp; } void tsp(point cities[], point tour[], int ncities) { int i,j,k,l; int ClosePt=0; double CloseDist; double closedist[SIMD_SIZE]; double dist[SIMD_SIZE]; double *tourx=alloca((ncities+SIMD_SIZE)*sizeof(double)); double *toury=alloca((ncities+SIMD_SIZE)*sizeof(double)); for (i=1; i", argv[0]); exit(1); } ncities = atoi(argv[1]); cities = alloca(ncities*sizeof(point)); tour = alloca(ncities*sizeof(point)); for (i=0; i