1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
5
// BOINC is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Lesser General Public License
7
// as published by the Free Software Foundation,
8
// either version 3 of the License, or (at your option) any later version.
10
// BOINC is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
// See http://boinc.berkeley.edu/trac/wiki/GPUApp for any compiling issues
19
// Contributor: Tuan Le (tuanle86@berkeley.edu)
25
#include "boinc_win.h"
40
#include "boinc_api.h"
42
#include "graphics2.h"
43
#include "cuda_config.h"
45
#define CHECKPOINT_FILE "matrix_inversion_state"
46
#define INPUT_FILENAME "input"
47
#define OUTPUT_FILENAME "output"
48
#define MATRIX_SIZE 10
49
#define NUM_ITERATIONS 501 // execute the kernel NUM_ITERATIONS times
57
// graphics app sets this to 5 repeatedly,
58
// main program decrements it once/sec.
59
// If it's zero, don't bother updating shmem
62
/*** BOINC FUNCTION DECLARATIONS ***/
64
/* Do a billion floating-point ops */
65
static double do_a_giga_flop(int foo);
67
/* Save the computation state into checkpoint file */
68
int do_checkpoint(MFILE& mf, int n, REAL *h_idata, int dimension);
74
// always do this; otherwise a graphics app will immediately
75
// assume we're not alive
76
shmem->update_time = dtime();
78
// Check whether a graphics app is running,
79
// and don't bother updating shmem if so.
80
// This doesn't matter here,
81
// but may be worth doing if updating shmem is expensive.
83
if (shmem->countdown > 0) {
84
// the graphics app sets this to 5 every time it renders a frame
89
shmem->fraction_done = boinc_get_fraction_done();
90
shmem->cpu_time = boinc_worker_thread_cpu_time();;
91
boinc_get_status(&shmem->status);
95
/*** FUNCTION DECLARATIONS ***/
98
* Parse the input file and determine the size of the matrix.
99
* This is an nxn matrix. Note: if width <> height, the matrix is
102
int get_matrix_dimension(FILE *infile);
104
/* Create an input file filled with random data of type cl_float. */
105
void generate_random_input_file(int n);
107
/* Read the REAL values from input file into host array. */
108
void fetch_elements_into_host_memory(FILE *infile, REAL *h_idata);
110
/* Write the result to output file */
111
void print_to_file(MFILE *out, float *h_odata, int dimension);
113
/* invert the given matrix A */
114
extern void invert(REAL * A, int n);
116
#endif /* #ifndef CUDA_H_ */
b'\\ No newline at end of file'