Skip to content

Instantly share code, notes, and snippets.

@EntilZha
Last active December 5, 2015 01:41
Show Gist options
  • Save EntilZha/3c8261c15f2e49d50a1b to your computer and use it in GitHub Desktop.
Save EntilZha/3c8261c15f2e49d50a1b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
template <typename A>
class RDD {
public:
vector<A> sequence;
RDD(vector<A> sequence): sequence(sequence) {}
template<typename Func>
auto map(Func f) -> RDD<decltype(f(A()))> {
auto r = vector<decltype(f(A()))>{f(A())};
return RDD<decltype(f(A()))>(r);
}
};
int main() {
cout << "Hello, World!" << endl;
vector<int> data {1, 2, 3, 4};
RDD<int> rdd(data);
auto r = rdd.map([](int a) -> double {
return 1.5;
});
cout << r.sequence.front();
return 0;
}
object HelloWorld {
def main(args: Array[String]) {
println("Hello")
val d = new RDD(Seq(1, 2))
println(d.map(x => x * 2).sequence)
}
}
class RDD[A](val sequence: Seq[A]) {
def map[B](f: A => B): RDD[B] = {
return new RDD(sequence.map(f))
}
}
@EntilZha
Copy link
Author

EntilZha commented Dec 4, 2015

/Users/pedro/Documents/Code/GrappaRDD/RDD.cpp:8:6: error: prototype for 'RDD<decltype (f(A()))> RDD<A>::map(Func)' does not match any in class 'RDD<A>'
 auto RDD<A>::map(Func f) -> RDD<decltype(f(A()))> {
      ^
In file included from /Users/pedro/Documents/Code/GrappaRDD/RDD.cpp:1:0:
/Users/pedro/Documents/Code/GrappaRDD/RDD.h:22:10: error: candidate is: template<class A> template<class Func> RDD<decltype (f(A()))> RDD<A>::map(Func)
     auto map(Func f) -> RDD<decltype(f(A()))>;

@EntilZha
Copy link
Author

EntilZha commented Dec 5, 2015

[ 32%] Building C object third-party/graph500-generator/CMakeFiles/graph500-generator.dir/graph_generator.c.o
[ 32%] Building C object third-party/graph500-generator/CMakeFiles/graph500-generator.dir/make_graph.c.o
[ 35%] Building C object third-party/graph500-generator/CMakeFiles/graph500-generator.dir/splittable_mrg.c.o
[ 35%] Building C object third-party/graph500-generator/CMakeFiles/graph500-generator.dir/utils.c.o
Linking C static library libgraph500-generator.a
[ 35%] Built target graph500-generator
Scanning dependencies of target all-third-party
[ 35%] Built target all-third-party
Scanning dependencies of target Communicator
[ 37%] Building CXX object system/CMakeFiles/Communicator.dir/Communicator.cpp.o
In file included from /home/pedro/dependencies/grappa/system/Communicator.hpp:61:0,
                 from /home/pedro/dependencies/grappa/system/Communicator.cpp:47:
/home/pedro/dependencies/grappa/system/Communicator.hpp: In member function ‘void Communicator::barrier_notify()’:
/home/pedro/dependencies/grappa/system/Communicator.hpp:293:60: error: ‘MPI_Ibarrier’ was not declared in this scope
     MPI_CHECK( MPI_Ibarrier( grappa_comm, &barrier_request ) );
                                                            ^
/home/pedro/dependencies/grappa/system/common.hpp:400:20: note: in definition of macro ‘MPI_CHECK’
     if( (retval = (mpi_call)) != 0 ) {                                  \
                    ^
/home/pedro/dependencies/grappa/system/Communicator.cpp: In member function ‘void Communicator::init(int*, char***)’:
/home/pedro/dependencies/grappa/system/Communicator.cpp:141:51: error: ‘MPI_COMM_TYPE_SHARED’ was not declared in this scope
   MPI_CHECK( MPI_Comm_split_type( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &locale_comm ) );
                                                   ^
/home/pedro/dependencies/grappa/system/common.hpp:400:20: note: in definition of macro ‘MPI_CHECK’
     if( (retval = (mpi_call)) != 0 ) {                                  \
                    ^
/home/pedro/dependencies/grappa/system/Communicator.cpp:141:104: error: ‘MPI_Comm_split_type’ was not declared in this scope
   MPI_CHECK( MPI_Comm_split_type( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &locale_comm ) );
                                                                                                        ^
/home/pedro/dependencies/grappa/system/common.hpp:400:20: note: in definition of macro ‘MPI_CHECK’
     if( (retval = (mpi_call)) != 0 ) {                                  \
                    ^
make[2]: *** [system/CMakeFiles/Communicator.dir/Communicator.cpp.o] Error 1
make[1]: *** [system/CMakeFiles/Communicator.dir/all] Error 2
make: *** [all] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment