#include "NBody.hpp" //---------------------- extern int numBodies; void* me; // Pointing to NBody class; FILE *snapshotsFile, *diagnosticsFile; // Represent the files that will retain the snapshots // and diagnostics; FILE *inputDataFile; // Represents the file for inputData for paricles; //---------------------- extern void startOpenGLSimulation(int argc, char * argv[]); /////////////////////////////////// MAIN Func \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // // Here starts the application // /////////////////////////////////// MAIN Func \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ int main(int argc, char * argv[]) { NBody clNBody("OpenCL NBody"); me = &clNBody; //-------------------------------- // Open file for input data if this option is // activated: if (readInputData){ inputDataFile = fopen(inputDataFileName, "r"); if(inputDataFile == NULL) { std::cout << "Error opening inputData file." << std::endl; return 1; } } //-------------------------------- // Open files for output data: snapshotsFile = fopen(snapshotFileName, "w"); if(snapshotsFile == NULL) { std::cout << "Error opening snapshots file." << std::endl; return 1; } diagnosticsFile = fopen(diagnosticFileName, "w"); if(diagnosticsFile == NULL) { std::cout << "Error opening diagnostics file." << std::endl; return 1; } //-------------------------------- // Initialize particles: if(clNBody.setupNBody()!= 0){ // SDK_SUCCESS == 0; return 1; } //-------------------------------- // Initialize OpenCL env: if(clNBody.setupCL()!= 0){ // SDK_SUCCESS == 0; return 1; } //-------------------------------- // Build CL kernel program executable: if(clNBody.setupCLProgram() != 0){ // SDK_SUCCESS == 0; return 1; } //-------------------------------- // Create kernels and set arguments to Kernels: if(clNBody.setupCLKernels()!= 0){ // SDK_SUCCESS == 0; return 1; } //-------------------------------- // Start the simulation: std::cout << std::endl; std::cout << "============================" << std::endl; std::cout << "Simulation started..." << std::endl; std::cout << std::endl; time ( &rawtime ); timeinfo = localtime ( &rawtime ); std::cout << "Start time and date: " << asctime (timeinfo) << std::endl; startOpenGLSimulation(argc, argv); //-------------------------------- // Clean memory allocation: if(clNBody.cleanup() != 0){ // SDK_SUCCESS == 0; return 1; } fclose(snapshotsFile); fclose(diagnosticsFile); return 0; }