-import System;
-
/*
Lonestar Benchmark Suite for irregular applications that exhibit
amorphous data-parallelism.
public static void Insert(ArrayIndexedGraph octree, ArrayIndexedNode root, OctTreeLeafNodeData b, double r) { // builds the tree
double x = 0.0, y = 0.0, z = 0.0;
-// OctTreeNodeData n = octree.getNodeData(root);
- OctTreeNodeData n = root.data;
+ OctTreeNodeData n = octree.getNodeData(root);
int i = 0;
if (n.posx < b.posx) {
i = 1;
octree.setNeighbor(root, i, newnode);
} else {
double rh = 0.5 * r;
-// OctTreeNodeData ch = octree.getNodeData(child);
- OctTreeNodeData ch = child.data;
+ OctTreeNodeData ch = octree.getNodeData(child);
if (!(ch instanceof OctTreeLeafNodeData)) {
Insert(octree, child, b, rh);
} else {
mintime =9223372036854775807L;
run = 0;
- while (((run < 3) || (Math.abs(lasttime-runtime)*64 > min(lasttime, runtime))) && (run < 7)) {
+// while (((run < 3) || (Math.abs(lasttime-runtime)*64 > min(lasttime, runtime))) && (run < 7)) {
runtime = bh.run(args);
if (runtime < mintime) mintime = runtime;
run++;
- }
+// }
System.out.println("minimum runtime: " + mintime + " ms");
System.out.println("");
}
int local_nbodies=nbodies;
int local_ntimesteps=ntimesteps;
+ long start_time = System.currentTimeMillis();
for (int step = 0; step < local_ntimesteps; step++) { // time-step the system
ComputeCenterAndDiameter();
ArrayIndexedGraph octree = new ArrayIndexedGraph(8);
// summarize subtree info in each internal node (plus restructure tree and sort bodies for performance reasons)
ComputeCenterOfMass(octree, root);
-// long id = Time.getNewTimeId();
- long start_time = System.currentTimeMillis();
for(int i=0; i < local_nbodies; i++){
-// for (OctTreeLeafNodeData n : body) {
// compute the acceleration of each body (consumes most of the total runtime)
-// n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
+ // n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
OctTreeLeafNodeData eachbody=body[i];
double di=diameter;
double it=itolsq;
double dt=dthf;
double ep=epssq;
sese parallel{
-// body[i].ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
-// eachbody.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
- eachbody.ComputeForce(octree, root, di, it, step, dt, ep);
+ eachbody.ComputeForce(octree, di, it, step, dt, ep);
}
}
- long end_time=System.currentTimeMillis();
- runtime += (end_time-start_time);
-// runtime += Time.elapsedTime(id);
- for (int i = 0; i < local_nbodies; i++) {
+
+ for (int i = 0; i < local_nbodies; i++) {
body[i].Advance(dthf, dtime); // advance the position and velocity of each body
}
+
} // end of time step
+ long end_time=System.currentTimeMillis();
+
if (isFirstRun) {
- // DecimalFormat df = new DecimalFormat("0.0000E00");
- // for (int i = 0; i < nbodies; i++) {
- // System.out.println(df.format(body[i].posx) + " " +
- // df.format(body[i].posy) + " " + df.format(body[i].posz)); // print
- // result
- // }
- for (int i = 0; i < local_nbodies; i++) {
-// System.out.println(body[i].posx + " " + body[i].posy + " " + body[i].posz); // print
- // result
- }
+ /*
+ for (int i = 0; i < local_nbodies; i++) {
+ System.out.println(body[i].posx + " " + body[i].posy + " " + body[i].posz); // print result
+ }
+ */
System.out.println("");
}
+ runtime += (end_time-start_time);
System.out.println("runtime: " + runtime + " ms");
isFirstRun = false;
velz = velhz + dvelz;
}
- void ComputeForce(ArrayIndexedGraph octree, ArrayIndexedNode root, double size, double itolsq,
+ void ComputeForce(ArrayIndexedGraph octree, double size, double itolsq,
int step, double dthf, double epssq) { // computes the acceleration and velocity of a body
double ax, ay, az;
ax = accx;
private void RecurseForce(ArrayIndexedGraph octree, ArrayIndexedNode nn, double dsq,
double epssq) { // recursively walks the tree to compute the force on a body
double drx, dry, drz, drsq, nphi, scale, idr;
-// OctTreeNodeData n = octree.getNodeData(nn);
OctTreeNodeData n = nn.data;
drx = n.posx - posx;
dry = n.posy - posy;
if (drsq < dsq) {
if (!(n instanceof OctTreeLeafNodeData)) { // n is a cell
dsq *= 0.25;
-// ArrayIndexedNode child = octree.getNeighbor(nn, 0);
ArrayIndexedNode child =nn.neighbors[0];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 1);
child =nn.neighbors[1];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 2);
child =nn.neighbors[2];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 3);
child =nn.neighbors[3];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 4);
child =nn.neighbors[4];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 5);
child =nn.neighbors[5];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 6);
child =nn.neighbors[6];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
-// child = octree.getNeighbor(nn, 7);
child =nn.neighbors[7];
if (child != null) {
RecurseForce(octree, child, dsq, epssq);
attributes = new float[numObjects][numAttributes];
KMeans.readFromFile(inputFile, kms.filename, buf, MAX_LINE_LENGTH);
System.out.println("Finished Reading from file ......");
-
+ long startT=System.currentTimeMillis();
/*
* The core of the clustering
*/
g_args); // Global arguments common to all threads
}
- System.out.println("TIME="+g_args.global_time);
+ long endT=System.currentTimeMillis();
+ System.out.println("running time="+(endT-startT));
+// System.out.println("TIME="+g_args.global_time);
System.out.println("Printing output......");
System.out.println("Best_nclusters= " + kms.best_nclusters);
/* Output: the coordinates of the cluster centres */
+ /*
{
for (int i = 0; i < kms.best_nclusters; i++) {
System.out.print(i + " ");
System.out.println("\n");
}
}
+ */
System.out.println("Finished......");
System.exit(0);