Commit 5a5ffce5 authored by Coon, Ethan's avatar Coon, Ethan
Browse files

updates utils VectorStatic and MatrixStatic to have view-like semantics,...

updates utils VectorStatic and MatrixStatic to have view-like semantics, allowing non-owning VectorStatics and passing these things by value instead of by reference.  Need to add a test to ensure that VectorStatic objects passed by value to the kernel that are then modified by the kernel stick.
parent 0eb4c2a3
......@@ -3,12 +3,12 @@ FCFLAGS += $(NETCDF_INC_FLAGS) $(ELM_INC_FLAGS)
CXXFLAGS += $(NETCDF_INC_FLAGS) $(ELM_INC_FLAGS)
# linking flags
CC_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(STD_LIB_ROOT)/lib -lstdc++ -L$(FC_LIB_ROOT) -lgfortran
#CC_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(STD_LIB_ROOT)/lib -lstdc++ -L$(MPI_LIB_ROOT)/lib -L$(FC_LIB_ROOT) -lgfortran
FC_LD_FLAGS += -L$(ELM_ROOT) -lelm -L$(NETCDF_ROOT) -lnetcdff
CXX_LD_FLAGS += -L$(ELM_ROOT) -lelm -L$(NETCDF_ROOT) -lnetcdf
#CXX_LD_FLAGS += -L$(ELM_ROOT) -lelm -L$(NETCDF_ROOT) -lnetcdf -I$(MPI_LIB_ROOT)/include -L$(MPI_LIB_ROOT)/lib -lmpi
CUDA_LD_FLAGS = -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(CUDA_LIBDIRS) -lstdc++ -lpthread -lcudart -lcublas
CC_LD_FLAGS += $(NETCDF_FLAGS) -L$(STD_LIB_ROOT)/lib -lstdc++ -L$(FC_LIB_ROOT) -lgfortran
#CC_LD_FLAGS += $(NETCDF_FLAGS) -L$(STD_LIB_ROOT)/lib -lstdc++ -L$(MPI_LIB_ROOT)/lib -L$(FC_LIB_ROOT) -lgfortran
FC_LD_FLAGS += $(NETCDF_FLAGS)f
CXX_LD_FLAGS += $(NETCDF_FLAGS)
#CXX_LD_FLAGS += $(NETCDF_FLAGS) -I$(MPI_LIB_ROOT)/include -L$(MPI_LIB_ROOT)/lib -lmpi
CUDA_LD_FLAGS = $(NETCDF_FLAGS) -L$(CUDA_LIBDIRS) -lstdc++ -lpthread -lcudart -lcublas
#
# rules
......
......@@ -10,56 +10,83 @@ namespace Utils {
template<size_t N, typename T=double>
class VectorStatic {
public:
VectorStatic() {}
VectorStatic(T t) { *this = t; }
VectorStatic() :
do_(std::shared_ptr<std::array<T,N>>(new std::array<T,N>())) {
d_ = do_.get();
}
VectorStatic(T t) :
VectorStatic()
{ *this = t; }
VectorStatic(const std::shared_ptr<std::array<T,N> >& d) :
do_(d) {
d_ = do_.get();
}
VectorStatic(std::array<T,N>* d) :
do_(nullptr),
d_(d)
{}
VectorStatic(const VectorStatic<N,T>& other) = default;
T& operator()(size_t i) { assert(0 <= i && i < N); return d_[i]; }
const T& operator()(size_t i) const { assert(0 <= i && i < N); return d_[i]; }
T& operator()(size_t i) { assert(0 <= i && i < N); return (*d_)[i]; }
const T& operator()(size_t i) const { assert(0 <= i && i < N); return (*d_)[i]; }
T& operator[](size_t i) { assert(0 <= i && i < N); return d_[i]; }
const T& operator[](size_t i) const { assert(0 <= i && i < N); return d_[i]; }
T& operator[](size_t i) { assert(0 <= i && i < N); return (*d_)[i]; }
const T& operator[](size_t i) const { assert(0 <= i && i < N); return (*d_)[i]; }
void operator=(T t) {
for (size_t i=0; i!=N; ++i) {
d_[i] = t;
(*d_)[i] = t;
}
}
double const * begin() const { return d_.begin(); }
double const * end() const { return d_.end(); }
double const * begin() const { return &((*d_)[0]); }
double const * end() const { return &((*d_)[N]); }
private:
std::array<T,N> d_;
std::array<T,N>* d_;
std::shared_ptr< std::array<T,N> > do_;
};
template<size_t ROW, size_t COL, typename T=double>
class MatrixStatic {
using Data_t = std::array<std::array<T,COL>, ROW>;
public:
MatrixStatic() {}
MatrixStatic(T t) { *this = t; }
MatrixStatic() :
d_(std::shared_ptr<Data_t>(new Data_t())) {}
MatrixStatic(T t) :
MatrixStatic()
{ *this = t; }
MatrixStatic(const MatrixStatic<ROW,COL,T>& other) = default;
T& operator()(size_t i, size_t j) { assert(0 <= i && i < ROW && 0 <= j && j < COL); return d_[i][j]; }
const T& operator()(size_t i, size_t j) const { assert(0 <= i && i < ROW && 0 <= j && j < COL); return d_[i][j]; }
T& operator()(size_t i, size_t j) { assert(0 <= i && i < ROW && 0 <= j && j < COL); return (*d_)[i][j]; }
const T& operator()(size_t i, size_t j) const { assert(0 <= i && i < ROW && 0 <= j && j < COL); return (*d_)[i][j]; }
VectorStatic<COL,T>& operator[](size_t i) { assert(0 <= i && i < ROW); return d_[i]; }
const VectorStatic<COL,T>& operator[](size_t i) const { assert(0 <= i && i < ROW); return d_[i]; }
VectorStatic<COL,T> operator[](size_t i) { assert(0 <= i && i < ROW); return &((*d_)[i]); }
const VectorStatic<COL,T> operator[](size_t i) const { assert(0 <= i && i < ROW); return &((*d_)[i]); }
void operator=(T t) {
for (size_t i=0; i!=ROW; ++i) {
for (size_t j=0; j!=COL; ++j) {
d_[i][j] = t;
(*d_)[i][j] = t;
}
}
}
double const * begin() const { return &d_[0][0]; }
double const * end() const { return &d_[ROW-1][COL-1] +1; }
double const * begin() const { return &(*d_)[0][0]; }
double const * end() const { return &(*d_)[ROW-1][COL-1] +1; }
private:
std::array<VectorStatic<COL,T>,ROW> d_;
std::shared_ptr<Data_t> d_;
};
......
......@@ -4,7 +4,7 @@
//
// The first strategy is a 2D Rect IndexSpace
//
#include <bits/stdc++.h>
#include <array>
#include <sstream>
#include <iterator>
......
......@@ -3,10 +3,11 @@ $(error LG_RT_DIR variable is not defined, aborting build)
endif
# from Makefile.config
OBJECT = ../../src/
KERNEL_LANG = cc
SRCDIR = $(OBJECT)$(KERNEL_LANG)
ELM_BASE = ../../src
KERNEL_FOLDER = cc
ELM_ROOT = $(ELM_BASE)/$(KERNEL_FOLDER)
NATURE =
# Flags for directing the runtime makefile what to include
DEBUG ?= 1 # Include debugging symbols
OUTPUT_LEVEL ?= LEVEL_DEBUG # Compile time logging level
......@@ -21,14 +22,14 @@ ALT_MAPPERS ?= 0 # Include alternative mappers (not recommended)
# You can modify these variables, some will be appended to by the runtime makefile
GEN_SRC ?= tasks.cc
INC_FLAGS ?= -I$(NETCDF_ROOT)/include -I$(SRCDIR) -I../tests_legion_c
INC_FLAGS ?= $(NETCDF_INC_FLAGS) -I$(ELM_ROOT)
CC_FLAGS= -DLEGION_SPY
NVCC_FLAGS ?=
GASNET_FLAGS ?=
#CC = mpicc
include $(OBJECT)config/Makefile.config
include $(OBJECT)config/Makefile.rules
include $(ELM_BASE)/config/Makefile.config
include $(ELM_BASE)/config/Makefile.rules
TESTS = test_CanopyHydrology_kern1_multiple \
test_CanopyHydrology_module
......@@ -56,12 +57,11 @@ default: all
echo "GEN OBJS = $(GEN_OBJS)"
all: links library $(TESTS)
all: $(TESTS)
test: $(EXEC_TESTS)
python ../compare_to_gold.py $(TESTS)
CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple
./test_CanopyHydrology_kern1_multiple > test_CanopyHydrology_kern1_multiple.stdout
# ./test_CanopyHydrology_kern1_multiple -lg:spy -logfile spy_multiple%.log
......@@ -90,31 +90,31 @@ $(SLIB_REALM) : $(REALM_OBJS)
$(AR) rc $@ $^
$(GEN_OBJS) : %.cc.o : %.cc
$(CXX) -o $@ -c $< $(CC_FLAGS) $(CPP_FLAGS) $(INC_FLAGS)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(CPP_FLAGS) $(INC_FLAGS)
$(ASM_OBJS) : %.S.o : %.S
$(CXX) -o $@ -c $< $(CC_FLAGS) $(INC_FLAGS)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC_FLAGS)
$(REALM_OBJS) : %.cc.o : %.cc
$(CXX) -o $@ -c $< $(CC_FLAGS) $(INC_FLAGS)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC_FLAGS)
$(LEGION_OBJS) : %.cc.o : %.cc
$(CXX) -o $@ -c $< $(CC_FLAGS) $(INC_FLAGS)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC_FLAGS)
$(MAPPER_OBJS) : %.cc.o : %.cc
$(CXX) -o $@ -c $< $(CC_FLAGS) $(INC_FLAGS)
$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC_FLAGS)
$(GEN_GPU_OBJS) : %.cu.o : %.cu
$(NVCC) -o $@ -c $< $(NVCC_FLAGS) $(INC_FLAGS)
$(NVCC) -o $@ -c $< $(NVCXXFLAGS) $(INC_FLAGS)
$(GPU_RUNTIME_OBJS): %.cu.o : %.cu
$(NVCC) -o $@ -c $< $(NVCC_FLAGS) $(INC_FLAGS)
$(NVCC) -o $@ -c $< $(NVCXXFLAGS) $(INC_FLAGS)
# disable gmake's default rule for building % from %.o
#% : %.o
%.cc.o : %.cc domains.hh readers.hh utils.hh
$(CXX) $(CXXFLAGS) $(NETCDF_FLAGS) $(INC_FLAGS) -c $< -o $@
$(CXX) $(CXXFLAGS) $(NETCDF_FLAGS) -c $< -o $@
clean :
$(ELM_CLEAN)
......@@ -125,8 +125,8 @@ allclean : clean
$(RM) -f $(SLIB_LEGION) $(SLIB_REALM) $(GEN_OBJS) $(GEN_GPU_OBJS) $(REALM_OBJS) $(LEGION_OBJS) $(GPU_RUNTIME_OBJS) $(MAPPER_OBJS) $(ASM_OBJS)
ifeq ($(strip $(USE_LLVM)),1)
llvmjit_internal.cc.o : CC_FLAGS += $(LLVM_CXXFLAGS)
%/llvmjit_internal.cc.o : CC_FLAGS += $(LLVM_CXXFLAGS)
llvmjit_internal.cc.o : CXXFLAGS += $(LLVM_CXXFLAGS)
%/llvmjit_internal.cc.o : CXXFLAGS += $(LLVM_CXXFLAGS)
endif
......@@ -136,5 +136,3 @@ links:
$(MAKE) -C ../links links
library:
$(MAKE) -C $(OBJECT) all
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment