#include "check.h"
#include <stdio.h>

// 定义与主程序中 Body 结构相同的结构体
typedef struct {
    float x, y, z, vx, vy, vz;
} Body;

void checkPerformance(float* buf, float performance, int salt) {
    Body* p = (Body*)buf;
    float checksum = 0.0f;
    // 若盐值为0，则默认检查前10个物体
    int count = (salt > 0) ? salt : 10;
    for (int i = 0; i < count; i++) {
         checksum += p[i].x + p[i].y + p[i].z;
    }
    printf("Performance: %0.3f Billion Interactions/s, Checksum (first %d bodies): %f\n",
           performance, count, checksum);
}

void checkAccuracy(float* buf, int nBodies) {
    Body* p = (Body*)buf;
    float checksum = 0.0f;
    for (int i = 0; i < nBodies; i++) {
         checksum += p[i].x + p[i].y + p[i].z;
    }
    printf("Accuracy Check - Checksum (sum of positions): %f\n", checksum);
}
