/[escript]/branches/arrexp_2137_win/escript/test/escript_UnitTest.cpp
ViewVC logotype

Contents of /branches/arrexp_2137_win/escript/test/escript_UnitTest.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2212 - (show annotations)
Wed Jan 14 00:15:00 2009 UTC (10 years, 4 months ago) by jfenwick
File size: 2530 byte(s)
Executive summary:

This commit adds copy on write checks to operations involving shared data. 

Changes:

new #defines:
~~~~~~~~~~~~~
Data.cpp has ASSIGNMENT_MEANS_DEEPCOPY (defaults to undefined).
Defining this will put the data = operator back to making deep copies instead
of sharing data (now the default.)

Data:
~~~~~
. Added exclusiveWrite method to copy the underlying data if it is shared.
. Some operators which took python objects now call the c++ versions intead of duplicating code.

DataAbstract and offspring:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
. Added method to determine whether the data is currently shared.
. Added getVectorRO to children of DataReady.
. Added getTagRO.

. Operations which modify values in place (or return modifiable pointers) now use
a macro to check for sharing. In the case where a modification attempt is detected, it throws an exception. In the future, I will enable this only for debugging.

. This shold not really have been required but the compiler was not choosing the use the const version as I would have liked. Besides, this makes things explict.

. Moved (and de-inlined) getVector in DataConstant (It was virtual in a parent class).

Unit tests:
~~~~~~~~~~~
Added both python and c++ unit tests to check known cases of sharing and "inplace"
modification operations.

General:
~~~~~~~~
Removed some commented out code.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #include <iostream>
16
17 #include "DataEmptyTestCase.h"
18 #include "DataConstantTestCase.h"
19 #include "DataTaggedTestCase.h"
20 #include "DataExpandedTestCase.h"
21 #include "DataFactoryTestCase.h"
22 #include "DataBlocks2DTestCase.h"
23 #include "DataVectorTestCase.h"
24 #include "TaipanTestCase.h"
25 #include "DataCTestCase.h"
26 #include "DataAlgorithmAdapterTestCase.h"
27 #include "FunctionSpaceTestCase.h"
28 #include "DataTestCase.h"
29 #include "DataMathsTestCase.h"
30 #include "DataTypesTestCase.h"
31 #include "DataLazyTestCase.h"
32 #include "SharedDataTestCase.h"
33
34 #include "tools/CppUnitTest/TestRunner.h"
35
36 using namespace CppUnitTest;
37
38 extern "C"{
39 #include "paso/Paso_MPI.h"
40 }
41
42 int main(int argc, char* argv[])
43 {
44 #ifdef PASO_MPI
45 int status = MPI_Init(&argc, &argv);
46 if (status != MPI_SUCCESS) {
47 std::cerr << argv[0] << ": MPI_Init failed, exiting." << std::endl;
48 return status;
49 }
50 #endif
51 //
52 // object which runs all of the tests
53 TestRunner runner;
54 //
55 // add the RangeTestCase suite of tests to the runner
56 runner.addTest ("SharedData", SharedDataTestCase::suite());
57 runner.addTest ("DataTypes", DataTypesTestCase::suite());
58 runner.addTest ("DataMaths", DataMathsTestCase::suite());
59 runner.addTest ("DataEmpty", DataEmptyTestCase::suite());
60 runner.addTest ("DataConstant", DataConstantTestCase::suite());
61 runner.addTest ("DataTagged", DataTaggedTestCase::suite());
62 runner.addTest ("DataExpanded", DataExpandedTestCase::suite());
63 runner.addTest ("DataFactory", DataFactoryTestCase::suite());
64 runner.addTest ("DataBlocks2D", DataBlocks2DTestCase::suite());
65 runner.addTest ("DataVector", DataVectorTestCase::suite());
66 runner.addTest ("Taipan", TaipanTestCase::suite());
67 runner.addTest ("DataC", DataCTestCase::suite());
68 runner.addTest ("DataAlgorithmAdapter", DataAlgorithmAdapterTestCase::suite());
69 runner.addTest ("FunctionSpace", FunctionSpaceTestCase::suite());
70 runner.addTest ("Data", DataTestCase::suite());
71 runner.addTest ("DataLazy",DataLazyTestCase::suite());
72
73 // actually run the unit tests.
74 runner.run (argc, argv);
75
76 #ifdef PASO_MPI
77 MPI_Finalize();
78 #endif
79
80 return 0;
81 }
82
83

  ViewVC Help
Powered by ViewVC 1.1.26