[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Condor-users] Is it Possible to Divide My Code?



Hi all,

Is it possible that using Globus Toolkit or Condor, my C/C++ code be
divided in such a way that every class in my code be submitted to
different computing nodes? Could DAGMAN can do this? Please try to look at
the comments in my code to see what I wanted to do.

I am using Condor as my scheduler and I have a Condor pool of 5 machines.

Here's my sample/testing code:

//complex.C
//main program for testing the class Complex

#include "Complex.h"
#include <iostream.h>

complex() {
	Complex A, B, C, D;
		A = Complex(1,2);
		B = Complex(2,3);
		C = Complex(1,3);

	B.Show(); //to be submitted to compute node 1

	D.Divide(A,B);
	D.Show(); //to be submitted to compute node 2

	D=A/B;
	D.Show(); //to be submitted to compute node 3

	D=Divide(A,B);
	D.Show(); //to be submitted to compute node 4

	D = ((A+B) + Multiply(B,C) - C) / (Subtract(A,C));
	D.Show(); //to be submitted to compute node 5

	gSystem->Clear(); //just ignore this,
                          //I'm using ROOT that's why
                          //have this line
	}


 I attached the header file in case you need it. :)

Thank you in advance.

Sincerely,

Leo
//Complex.cxx
//Implementation of methods for class Complex

//* (Update Record)
//*	07/12/2006	H.C.Gooc,Jr.	Original Version

class Complex

Complex::Complex(): fReal(0), fImaginary(0) {};

Complex::Complex(Complex& comp) {
		fReal = comp.fReal;
		fImaginary = comp.fImaginary;
		};

Complex::Complex(Double_t& real, Double_t& imaginary) {
		fReal = real;
		fImaginary = imaginary;
		};

void Complex::Add(Complex& A, Complex& B) {
		fReal = A.fReal*B.fImaginary + A.fImaginary*B.fReal;
		fImaginary = A.fImaginary*B.fImaginary;
		};

void Complex::Subtract(Complex& A, Complex& B) {
		fReal = A.fReal*B.fImaginary - A.fImaginary*B.fReal;
		fImaginary = A.fImaginary*B.fImaginary;
		};

void Complex::Multiply(Complex& A, Complex& B) {
		fReal = A.fReal * B.fReal;
		fImaginary = A.fImaginary * B.fImaginary;
		};

void Complex::Divide(Complex& A, Complex& B) {
		fReal = A.fReal * B.fImaginary;
		fImaginary = A.fImaginary * B.fReal;
		};

void Complex::Show() {
		cout << endl << "Real = " << fReal << endl
			     << "Imaginary = " << fImaginary << endl;
		}

//========================
//Below are not part anymore of the class Complex
//These are some implementations that uses the class Complex
//========================

Complex Add (Complex& A, Complex& B) {
	return A+B;
	};

Complex Subtract (Complex& A, Complex& B) {
	return A-B;
	};

Complex Multiply (Complex& A, Complex& B) {
	return A*B;
	};

Complex Divide (Complex& A, Complex& B) {
	return A/B;
	};
//Complex.h
//headers for ADT Complex

//* (Update Record)
//*	07/12/2006	H.C.Gooc,Jr.	Original Version

#ifndef __Complex__
#define __Complex__

#include<TMath.h>
#include "Complex.cxx"

class Complex {

public:

//constructors
	Complex();
	Complex(Complex& complex);
	Complex(Double_t& real, Double_t& imaginary);
//destructor
	virtual ~Complex() {};

private:
	Double_t fReal;
	Double_t fImaginary;
public:
	Double_t GetReal() 		{return fReal;}
	Double_t GetImaginary() 	{return fImaginary;}

	void SetReal (Double_t real) {fReal = real;}
	void SetImaginary (Double_t imaginary) {fImaginary = imaginary;}

	void Add (Complex& A, Complex& B);
	void Subtract (Complex& A, Complex& B);
	void Multiply (Complex& A, Complex& B);
	void Divide (Complex& A, Complex& B);

	void Show();	//for displaying results, just for debugging

//implement binary operators
	Complex operator=(Complex& C) {  //overrides = operator
		fReal = C.fReal;
		fImaginary = C.fImaginary;
		return *this;
		}

	Complex operator+(Complex& C) {  //performs addition
		Complex temp;
		temp.fReal = fReal + C.fReal;
		temp.fImaginary = fImaginary + C.fImaginary;
		return temp;
		}

	Complex operator-(Complex& C) {  //performs subtraction
		Complex temp;
		temp.fReal = fReal - C.fReal;
		temp.fImaginary = fImaginary - C.fImaginary;
		return temp;
		}

	Complex operator*(Complex& C) {  //performs multiplication
		Complex temp;
		temp.fReal = fReal*C.fReal - fImaginary*C.fImaginary;
		temp.fImaginary = fImaginary*C.fReal + fReal*C.fImaginary;
		return temp;
		}

	Complex operator/(Complex& C) {  //performs division
		Complex temp;
		temp.fReal = (fReal*C.fReal + fImaginary*C.fImaginary)/(C.fReal*C.fReal + C.fImaginary*C.fImaginary);
		temp.fImaginary = (fImaginary*C.fReal - fReal*C.fImaginary)/(C.fReal*C.fReal + C.fImaginary*C.fImaginary);
		return temp;
		}

};

#endif