Commit 8a220db7 authored by mjg226's avatar mjg226
Browse files
parents f84f3c86 6af9f248
......@@ -112,13 +112,16 @@ set(CAAPI_SOURCES)
set(CAAPI_CACOMMON)
set(CAAPI_CAHEADERS)
set(CAAPI_COMMON_FOLDER "/impls/common/")
# From common directory
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}/impls/common/*.hpp" CAAPI_HEADERS)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}/impls/common/*.cpp" CAAPI_SOURCES)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}/impls/common/*.ca" CAAPI_CACOMMON)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_COMMON_FOLDER}*.hpp" CAAPI_HEADERS)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_COMMON_FOLDER}*.cpp" CAAPI_SOURCES)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_COMMON_FOLDER}*.ca" CAAPI_CACOMMON)
# Add the needed directories into the compilation
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/impls/common/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_COMMON_FOLDER}")
########################## INSTALL ##########################
......@@ -283,6 +286,33 @@ add_custom_target(caapi_do_impl_headers ALL DEPENDS ${CAAPI_CAHEADERS} ${CAAPI_H
# Add the needed directories into the compilation
include_directories(${CAAPI_IMPL_INCLUDE_DIRS})
########################## CAPI DEVICE common files ##########################
#message(STATUS "${CAAPI_DEVICE}")
if(NOT DEFINED CAAPI_DEVICE)
message(STATUS "Device: CPU")
set(CAAPI_DEVICE_COMMON_FOLDER "${CAAPI_COMMON_FOLDER}CPU/")
elseif(CAAPI_DEVICE STREQUAL "GPU")
set(CAAPI_DEVICE_COMMON_FOLDER "${CAAPI_COMMON_FOLDER}GPU/")
message(STATUS "Device: GPU")
else()
message(STATUS "Device: UNKNOWN")
endif()
if(DEFINED CAAPI_DEVICE_COMMON_FOLDER)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_DEVICE_COMMON_FOLDER}*.hpp" CAAPI_HEADERS)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_DEVICE_COMMON_FOLDER}*.cpp" CAAPI_SOURCES)
CAAPI_add_source_dir(impls\\\\common "${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_DEVICE_COMMON_FOLDER}*.ca" CAAPI_CACOMMON)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}${CAAPI_DEVICE_COMMON_FOLDER}")
endif()
########################## CAPI APPS ##########################
......
This diff is collapsed.
/*
Copyright (c) 2013 Centre for Water Systems,
University of Exeter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _CA_OPTIONS_HPP_
#define _CA_OPTIONS_HPP_
//! \file Options.hpp
//! Contains the list of implementation specific Options
//! \author Michele Guidolin, University of Exeter,
//! contact: m.guidolin [at] exeter.ac.uk
//! \date 2012-07
#include"Common.hpp"
namespace CA {
//! Return a list of implementation specific Options
inline Options options()
{
return Options();
}
}
#endif// _CA_BASETYPES_HPP_
......@@ -106,6 +106,10 @@ namespace CA {
bool operator<=(const Coo& src) const;
//! Returns the euclidian distance to another pair of coordinates.
Real distanceTo(Coo c);
//! Return true if the coordinate is empty,i.e. not in the grid.
bool isEmty() const;
......@@ -196,6 +200,12 @@ namespace CA {
}
inline Real Coo::distanceTo(Coo c)
{
return sqrt(pow((_x - c.x()), 2) + pow((_y - c.y()), 2));
}
inline bool Coo::isEmty() const
{
return
......
/*
Copyright (c) 2013 Centre for Water Systems,
University of Exeter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _CA_OPTIONS_HPP_
#define _CA_OPTIONS_HPP_
//! \file Options.hpp
//! Contains the list of implementation specific Options
//! \author Michele Guidolin, University of Exeter,
//! contact: m.guidolin [at] exeter.ac.uk
//! \date 2012-07
#include"Common.hpp"
namespace CA {
//! Return a list of implementation specific Options
inline Options options()
{
Options options;
// Add the optional arguments. The tag start from 1000 for safety
// reason.
CA::Unsigned na = 1000;
options.push_back(new Arguments::Arg(na++,"config-file",
"Select the OpenCL config CSV file.","",true, true, false));
options.push_back(new Arguments::Arg(na++,"device-type",
"Select the OpenCL device type (CPU/GPU).","GPU",true, true, false));
options.push_back(new Arguments::Arg(na++,"device-number",
"Select the OpenCL device from many available.","0",true, true, false));
options.push_back(new Arguments::Arg(na++,"platform-name",
"Select the OpenCL specific platform","",true, true, false));
options.push_back(new Arguments::Arg(na++,"warp-size",
"Select the OpenCL warp size (32).","",true, true, false));
options.push_back(new Arguments::Arg(na++,"out-of-order",
"Uses an out of order execution.","",true, false, false));
options.push_back(new Arguments::Arg(na++,"build-info",
"Show in standard error the OpenCl buidl info","",true, false, false));
return options;
}
}
#endif// _CA_BASETYPES_HPP_
/*
Copyright (c) 2013 Centre for Water Systems,
University of Exeter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _CA_OPTIONS_HPP_
#define _CA_OPTIONS_HPP_
//! \file Options.hpp
//! Contains the list of implementation specific Options
//! \author Michele Guidolin, University of Exeter,
//! contact: m.guidolin [at] exeter.ac.uk
//! \date 2012-07
#include"Common.hpp"
namespace CA {
//! Return a list of implementation specific Options
inline Options options()
{
Options options;
// Add the optional arguments. The tag start from 1000 for safety
// reason.
CA::Unsigned na = 1000;
options.push_back(new Arguments::Arg(na++,"config-file",
"Select the OpenCL config CSV file.","",true, true, false));
options.push_back(new Arguments::Arg(na++,"device-type",
"Select the OpenCL device type (CPU/GPU).","GPU",true, true, false));
options.push_back(new Arguments::Arg(na++,"device-number",
"Select the OpenCL device from many available.","0",true, true, false));
options.push_back(new Arguments::Arg(na++,"platform-name",
"Select the OpenCL specific platform","",true, true, false));
options.push_back(new Arguments::Arg(na++,"warp-size",
"Select the OpenCL warp size (32).","",true, true, false));
options.push_back(new Arguments::Arg(na++,"out-of-order",
"Uses an out of order execution.","",true, false, false));
options.push_back(new Arguments::Arg(na++,"build-info",
"Show in standard error the OpenCl buidl info","",true, false, false));
return options;
}
}
#endif// _CA_BASETYPES_HPP_
......@@ -61,6 +61,10 @@ namespace CA {
public:
//default constructor, sets to zero's
Point();
//! Create a point in the grid.
//! \param x The X position.
//! \param y The Y position.
......@@ -142,7 +146,11 @@ namespace CA {
/// ----- Inline implementation ----- ///
inline Point::Point() :
_x(0), _y(0), _coo()
{
}
inline Point::Point(Unsigned x, Unsigned y):
_x(x), _y(y), _coo()
......
......@@ -114,6 +114,14 @@ namespace CA {
Real length() const;
//! Return the distance between two adjacent cells.
Real distance() const;
//! Returns the area of a cell.
Real area() const;
//! Return the x coordinate of the bottom-left corner.
Real xCoo() const;
......@@ -252,21 +260,15 @@ namespace CA {
// has caLevels*2 + 1 border in the X direction and caLevels*2
// border in the Y direction.
// The two diagonal edge buffers are different, due to the extra
// introduced to create a direct correspondence to a square grid.
// Both the northwest/southeast and southwest/northeast buffers
// have an irregular edge row (along the xx axis) again due to
// the extra cells.
_cagrid.eb_ns_y_border = caLevels;
_cagrid.eb_we_x_border = caLevels;
_cagrid.eb_ns_x_size = _cagrid.x_size + _cagrid.eb_ns_y_border*2;
_cagrid.eb_ns_x_size = _cagrid.x_size;
_cagrid.eb_ns_y_size = _cagrid.y_size + _cagrid.eb_we_x_border*2 + 1; // Notice the +1.
_cagrid.eb_nwse_x_size = _cagrid.x_size + _cagrid.eb_ns_y_border*2 + 1;
_cagrid.eb_nwse_y_size = _cagrid.y_size + _cagrid.eb_we_x_border*2 + 1;
_cagrid.eb_nwse_y_size = _cagrid.y_size;
_cagrid.eb_swne_x_size = _cagrid.eb_nwse_x_size;
_cagrid.eb_swne_y_size = _cagrid.eb_nwse_y_size;
......@@ -275,7 +277,8 @@ namespace CA {
// Set the starting point for the three sub-buffers in the main buffer.
_cagrid.eb_ns_start = 0; // The north/South is first.
_cagrid.eb_nwse_start = _cagrid.eb_ns_x_size * _cagrid.eb_ns_y_size;
_cagrid.eb_swne_start = _cagrid.eb_nwse_x_size * _cagrid.eb_nwse_y_size;
_cagrid.eb_swne_start = _cagrid.eb_nwse_start +
_cagrid.eb_nwse_x_size * _cagrid.eb_nwse_y_size;
_cagrid.print = false;
}
......@@ -352,6 +355,15 @@ namespace CA {
return _cagrid.length;
}
inline Real Grid::distance() const
{
return _cagrid.distance;
}
inline Real Grid::area() const
{
return _cagrid.area;
}
inline Real Grid::xCoo() const
{
......
......@@ -225,6 +225,92 @@ namespace CA {
}
//------------------------------------------------------------------------------------------------------------------------------
//! Add another ascii gri dof data to this grid of data
inline void addAsciiGrid(AsciiGrid<T>& grid2, bool print = false) {
// find how many cells between bottom left of each terrain.
int colsDiff = 0;
int rowsDiff = 0;
if (print)
std::cout << "BLAH" << std::endl;
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
}
//------------------------------------------------------------------------------------------------------------------------------
//#######################################################################################################################################
//########################################### comparitor functions ########################################################
//#######################################################################################################################################
//--------------------------------------------------------------------------------------------------------------
//! Compare the RMSE of two ascii grids, and return the errors
//! if the same cell from either grid is no data, then no comparison is made
//! note this object is considered the observation (truth) to compare to the other simulation.
inline Errors compareAsciiGrid(AsciiGrid<T>& grid2, T tolerance = 0.0, bool print = false)
{
//
//double result = 0.0;
//int count = 0;
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
// note needs checking for cell size usuage?!.............
// erros structure used, to reduce multiple loops
Errors result;
result.RMSE = 0.0;
result.RMSE_wet_both = 0.0;
result.RMSE_wet_either = 0.0;
result.meanError = 0.0;
result.meanError_wet_both = 0.0;
result.meanError_wet_either = 0.0;
result.accuracy = 0.0;
result.sensitivity = 0.0;
result.precision = 0.0;
result.precentage = 0.0;
result.nashSutcliffe = 0.0;
result.truePositive = 0;
result.falsePositive = 0;
result.trueNegative = 0;
result.falseNegative = 0;
result.thisWettedCount = 0;
result.thatWettedCount = 0;
result.combinedWettedCount = 0;
result.allDataCells = 0;
result.eitherWetted = 0;
// for nash sutcliffe we need the mean of the observed (truth), i.e. this ascii grids data
double meanObserved = 0.0;
double nashSumSquaredErrors = 0.0;
double nashSumDataVariance = 0.0;
// do a check for size mismatch here.
// due to geo-cor-ordinates, we must check only the region that overlaps
// TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NEEDS IMPLMENTING FOR HEX GRIDS
return result;
}// end of compareAsciiGridHeader
//--------------------------------------------------------------------------------------------------------------
};// end of class
......@@ -244,6 +330,8 @@ namespace CA {
template<typename T>
const std::string HexAsciiGrid<T>::file_extension = ".hasc";
}// end of namespace
......
......@@ -141,8 +141,7 @@ struct _caGrid
//! The distance between the centroid of the main cell (number 0)
//! and the centroid of the given cell in the vertical and
//! horizontal plane.
//! and the centroid of an adjacent cell.
_caReal distance;
//! The x coordinate of the bottom-left corner
......@@ -1091,6 +1090,10 @@ inline void caActivateAlarmMask(CA_GRID grid, CA_ALARMS_O alarms, CA_STATE mask,
// ---- CELL BUFFERS ----
//! Note that the odd/even neighbourhood selection methods are actually backwards.
//! CADDIES is shifting the internal (0,0) index to the (-1,-1) cell in the original
//! grid coordinates. Therefore column 0 in the original grid falls into an odd column
//! in the structures created by CADDIES.
//! Read the real value of the cell from the given buffer at the given cell number.
inline _caReal caReadCellBuffReal(CA_GRID grid, CA_CELLBUFF_REAL_I src, int cell_number)
......@@ -1106,26 +1109,26 @@ inline _caReal caReadCellBuffReal(CA_GRID grid, CA_CELLBUFF_REAL_I src, int cel
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
}
}
else //even
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
}
}
......@@ -1147,19 +1150,19 @@ inline void caReadCellBuffRealCellArray(CA_GRID grid, CA_CELLBUFF_REAL_I src, _
if(grid.main_x % 2) //odd
{
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
}
else //even
{
values[1] = src[i+1];
values[3] = src[i-1];
values[4] = src[i+x_size-1];
values[6] = src[i+x_size+1];
}
else //even
{
values[1] = src[i-x_size+1];
values[3] = src[i-x_size-1];
values[4] = src[i-1];
values[6] = src[i+1];
}
}
......@@ -1182,26 +1185,26 @@ inline _caState caReadCellBuffState(CA_GRID grid, CA_CELLBUFF_STATE_I src, int
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;
case 4: return src[i-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+1]; break;
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
}
}
else //even
{
switch(cell_number)
{
case 0: return src[i]; break;
case 1: return src[i+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-1]; break;
case 4: return src[i+x_size-1]; break;
case 5: return src[i+x_size]; break;
case 6: return src[i+x_size+1]; break;
case 0: return src[i]; break;
case 1: return src[i-x_size+1]; break;
case 2: return src[i-x_size]; break;
case 3: return src[i-x_size-1]; break;