From: <dgr...@us...> - 2009-10-27 14:57:50
|
Revision: 11771 http://x10.svn.sourceforge.net/x10/?rev=11771&view=rev Author: dgrove-oss Date: 2009-10-27 14:57:28 +0000 (Tue, 27 Oct 2009) Log Message: ----------- XRX compiles with C++ backend. Summary of fixes: change deserialization templates to use Ref instead of Object. generate typeName method for sturcts define typeName on Ref. misc Object ==> Ref changes in handwritten code bug fix in numParents computation in codegen for initRTT Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime/src-cpp/x10/lang/Box.h trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10/lang/Ref.cc trunk/x10.runtime/src-cpp/x10/lang/Ref.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-cpp/x10/lang/Value.cc trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10aux/static_init.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-10-27 14:57:28 UTC (rev 11771) @@ -602,21 +602,21 @@ void printRTTDefn(X10ClassType ct, CodeWriter h) { X10TypeSystem_c xts = (X10TypeSystem_c) ct.typeSystem(); String x10name = ct.fullName().toString(); - int num_parents = 1 + ct.interfaces().size(); - // ADJUST FOR ANY. - if (ct.superClass() == null || xts.isAny(ct.superClass())) { - num_parents--; - } else if (ct.interfaces().size() > 0) { - num_parents--; // IGNORE ANY, which shows up everywhere. + int numParents = 0; + if (ct.superClass() != null && !xts.isAny(ct.superClass())) { + numParents++; } + for (Type iface: ct.interfaces()) { + if (!xts.isAny(iface)) numParents++; + } if (ct.typeArguments().isEmpty()) { boolean first = true; h.write("x10aux::RuntimeType "+translateType(ct)+"::rtt;"); h.newline(); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("rtt.canonical = &rtt;"); h.newline(); - if (num_parents > 0) { - h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); + if (numParents > 0) { + h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); if (ct.superClass() != null && !xts.isAny(ct.superClass())) { h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); first = false; @@ -631,7 +631,7 @@ } else { h.write("const x10aux::RuntimeType** parents = NULL; "); h.newline(); } - h.write("rtt.init(&rtt, \""+ct.fullName()+"\", "+num_parents+ ", parents, 0, NULL, NULL);"); h.end(); h.newline(); + h.write("rtt.init(&rtt, \""+ct.fullName()+"\", "+numParents+ ", parents, 0, NULL, NULL);"); h.end(); h.newline(); h.write("}"); h.newline(); } else { boolean first = true; @@ -642,8 +642,8 @@ printTemplateSignature(ct.typeArguments(), h); h.write("void "+translateType(ct)+"::_initRTT() {"); h.newline(4); h.begin(0); h.write("rtt.canonical = &rtt;"); h.newline(); - if (num_parents > 0) { - h.write("const x10aux::RuntimeType* parents["+num_parents+"] = { "); + if (numParents > 0) { + h.write("const x10aux::RuntimeType* parents["+numParents+"] = { "); if (ct.superClass() != null && !xts.isAny(ct.superClass())) { h.write("x10aux::getRTT" + chevrons(translateType(ct.superClass())) + "()"); first = false; @@ -695,7 +695,7 @@ h.write(", params["+i+"]->name()"); h.newline(); } h.write(");") ; h.end(); h.newline(); - h.write("rtt.init(canonical, name, "+num_parents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); + h.write("rtt.init(canonical, name, "+numParents+", parents, "+numTypeParams+", params, variances);"); h.end(); h.newline(); h.write("}"); h.newline(); } h.newline(); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 14:57:28 UTC (rev 11771) @@ -1532,8 +1532,15 @@ sw.writeln("}"); sw.forceNewline(); } + // define typeName + sh.writeln("x10aux::ref<x10::lang::String> typeName();"); sh.forceNewline(); + emitter.printTemplateSignature(currentClass.typeArguments(), sw); + sw.write("x10aux::ref<x10::lang::String> "+ Emitter.translateType(currentClass, false)+ "::typeName() {"); + sw.newline(4); sw.begin(0); + sw.writeln("return x10aux::type_name(*this);"); sw.end(); sw.newline(); + sw.writeln("}"); sw.forceNewline(); } private void generateITablesForClass(X10ClassType currentClass, Modified: trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/io/FileReader__FileInputStream.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -15,7 +15,7 @@ } const x10aux::serialization_id_t FileReader__FileInputStream::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(FileReader__FileInputStream::_deserializer<x10::lang::Object>); + x10aux::DeserializationDispatcher::addDeserializer(FileReader__FileInputStream::_deserializer<x10::lang::Ref>); void FileReader__FileInputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { InputStreamReader__InputStream::_serialize_body(buf, m); Modified: trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/io/FileWriter__FileOutputStream.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -18,7 +18,7 @@ } const x10aux::serialization_id_t FileWriter__FileOutputStream::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(FileWriter__FileOutputStream::_deserializer<x10::lang::Object>); + x10aux::DeserializationDispatcher::addDeserializer(FileWriter__FileOutputStream::_deserializer<x10::lang::Ref>); void FileWriter__FileOutputStream::_serialize_body(x10aux::serialization_buffer& buf, x10aux::addr_map& m) { OutputStreamWriter__OutputStream::_serialize_body(buf, m); Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -29,7 +29,7 @@ } const x10aux::serialization_id_t File__NativeFile::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(File__NativeFile::_deserializer<Ref>); RTT_CC_DECLS1(File__NativeFile, "x10.io.File.NativeFile", Ref) Modified: trunk/x10.runtime/src-cpp/x10/lang/Box.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Box.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -59,7 +59,7 @@ }; template<class T> const x10aux::serialization_id_t Box<T>::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(Box<T>::template _deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(Box<T>::template _deserializer<Ref>); template<class T> void Box<T>::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { this->x10::lang::Ref::_serialize_body(buf, m); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -552,7 +552,7 @@ template<class T> const x10aux::serialization_id_t Rail<T>::_serialization_id = x10aux::DeserializationDispatcher - ::addDeserializer(Rail<T>::template _deserializer<Object>); + ::addDeserializer(Rail<T>::template _deserializer<Ref>); // Specialized serialization template <class T> void Rail<T>::_serialize(x10aux::ref<Rail<T> > this_, Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -29,8 +29,12 @@ return String::Lit(alloc_printf("%s@%p",this->_type()->name(),(void*)this)); } +x10aux::ref<x10::lang::String> x10::lang::Ref::typeName() { + return x10::lang::String::Lit(_type()->name()); +} + const serialization_id_t Ref::_serialization_id = - DeserializationDispatcher::addDeserializer(Ref::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(Ref::_deserializer<Ref>); void Ref::_serialize(ref<Ref> this_, serialization_buffer &buf, addr_map &m) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Ref.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -86,6 +86,8 @@ return location == o->location; } + virtual x10aux::ref<x10::lang::String> typeName(); + // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { if (other == x10aux::ref<Ref>(this)) return true; Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -165,7 +165,7 @@ } // TODO: DG: itables: refactor to share the code. -ref<String> String::format(ref<String> format, ref<ValRail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<ValRail<ref<Ref> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -223,7 +223,7 @@ return String::Lit(ss.str().c_str()); } -ref<String> String::format(ref<String> format, ref<Rail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<Rail<ref<Ref> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -290,7 +290,7 @@ } const serialization_id_t String::_serialization_id = - DeserializationDispatcher::addDeserializer(String::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(String::_deserializer<Ref>); // Specialized serialization void String::_serialize(x10aux::ref<String> this_, x10aux::serialization_buffer &buf, x10aux::addr_map &m) { Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -114,10 +114,10 @@ virtual void _destructor(); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<ValRail<x10aux::ref<Object> > > parms); + x10aux::ref<ValRail<x10aux::ref<Ref> > > parms); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<Rail<x10aux::ref<Object> > > parms); + x10aux::ref<Rail<x10aux::ref<Ref> > > parms); virtual x10_boolean equals(x10aux::ref<x10::lang::Object> p0); Modified: trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Throwable.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -32,7 +32,7 @@ using namespace x10aux; const serialization_id_t Throwable::_serialization_id = - DeserializationDispatcher::addDeserializer(Throwable::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(Throwable::_deserializer<Ref>); void Throwable::_serialize_body(x10aux::serialization_buffer &buf, x10aux::addr_map &m) { Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -98,7 +98,7 @@ template<class T> const x10aux::serialization_id_t ValRail<T>::_serialization_id = x10aux::DeserializationDispatcher - ::addDeserializer(ValRail<T>::template _deserializer<Object>); + ::addDeserializer(ValRail<T>::template _deserializer<Ref>); template<class T> void ValRail<T>::_initRTT() { rtt.canonical = &rtt; Modified: trunk/x10.runtime/src-cpp/x10/lang/Value.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/lang/Value.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -10,7 +10,7 @@ using namespace x10aux; const serialization_id_t Value::_serialization_id = - DeserializationDispatcher::addDeserializer(Value::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(Value::_deserializer<Ref>); void Value::_serialize(x10aux::ref<Value> this_, x10aux::serialization_buffer &buf, Modified: trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/runtime/Deque.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -37,7 +37,7 @@ } const serialization_id_t Deque::_serialization_id = - DeserializationDispatcher::addDeserializer(Deque::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(Deque::_deserializer<Ref>); void Deque::growQueue() { Slots *oldQ = queue; Modified: trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/runtime/Thread.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -83,7 +83,7 @@ } const serialization_id_t Thread::_serialization_id = - DeserializationDispatcher::addDeserializer(Thread::_deserializer<Object>); + DeserializationDispatcher::addDeserializer(Thread::_deserializer<Ref>); // Helper method to initialize a Thread object. Modified: trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/util/GrowableRail.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -197,7 +197,7 @@ } template<class T> const x10aux::serialization_id_t GrowableRail<T>::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(GrowableRail<T>::template _deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(GrowableRail<T>::template _deserializer<Ref>); template<> class GrowableRail<void> { public: Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -32,7 +32,7 @@ } const x10aux::serialization_id_t AtomicBoolean::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(AtomicBoolean::_deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(AtomicBoolean::_deserializer<Ref>); RTT_CC_DECLS1(AtomicBoolean, "x10.util.concurrent.atomic.AtomicBoolean", Ref) Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicInteger.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -32,7 +32,7 @@ } const x10aux::serialization_id_t AtomicInteger::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(AtomicInteger::_deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(AtomicInteger::_deserializer<Ref>); RTT_CC_DECLS1(AtomicInteger, "x10.util.concurrent.atomic.AtomicInteger", Ref) Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicLong.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -32,7 +32,7 @@ } const x10aux::serialization_id_t AtomicLong::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(AtomicLong::_deserializer<Object>); + x10aux::DeserializationDispatcher::addDeserializer(AtomicLong::_deserializer<Ref>); RTT_CC_DECLS1(AtomicLong, "x10.util.concurrent.atomic.AtomicLong", Ref) Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -140,12 +140,12 @@ } -ref<Object> DeserializationDispatcher::create_(deserialization_buffer &buf, serialization_id_t id) { +ref<Ref> DeserializationDispatcher::create_(deserialization_buffer &buf, serialization_id_t id) { _S_("Dispatching deserialisation using id: "<<id); return deser_v[id](buf); } -ref<Object> DeserializationDispatcher::create_(deserialization_buffer &buf) { +ref<Ref> DeserializationDispatcher::create_(deserialization_buffer &buf) { serialization_id_t id = buf.read<serialization_id_t>(); return create_(buf, id); } Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -5,13 +5,13 @@ #include <x10aux/ref.h> -namespace x10 { namespace lang { class Object; } } +namespace x10 { namespace lang { class Ref; } } namespace x10aux { class deserialization_buffer; - typedef ref<x10::lang::Object> (*Deserializer)(deserialization_buffer &buf); + typedef ref<x10::lang::Ref> (*Deserializer)(deserialization_buffer &buf); template<> inline const char *typeName<Deserializer>() { return "Deserializer"; } typedef void *(*BufferFinder)(deserialization_buffer &buf, x10_int len); @@ -57,8 +57,8 @@ template<class T> static ref<T> create(deserialization_buffer &buf, serialization_id_t id); - ref<x10::lang::Object> create_(deserialization_buffer &buf); - ref<x10::lang::Object> create_(deserialization_buffer &buf, serialization_id_t id); + ref<x10::lang::Ref> create_(deserialization_buffer &buf); + ref<x10::lang::Ref> create_(deserialization_buffer &buf, serialization_id_t id); static serialization_id_t addDeserializer(Deserializer deser, bool is_async=false); serialization_id_t addDeserializer_(Deserializer deser, bool is_async); Modified: trunk/x10.runtime/src-cpp/x10aux/static_init.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.cc 2009-10-27 14:57:28 UTC (rev 11771) @@ -20,7 +20,7 @@ return it->addDeserializer_(init, false); } -ref<Object> StaticInitBroadcastDispatcher::dispatch(deserialization_buffer &buf) { +ref<Ref> StaticInitBroadcastDispatcher::dispatch(deserialization_buffer &buf) { assert (NULL != it); serialization_id_t init_id = buf.read<serialization_id_t>(); return it->create_(buf, init_id); Modified: trunk/x10.runtime/src-cpp/x10aux/static_init.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/static_init.h 2009-10-27 11:41:48 UTC (rev 11770) +++ trunk/x10.runtime/src-cpp/x10aux/static_init.h 2009-10-27 14:57:28 UTC (rev 11771) @@ -17,7 +17,7 @@ public: static serialization_id_t addRoutine(Deserializer init); - static ref<x10::lang::Object> dispatch(deserialization_buffer& buf); + static ref<x10::lang::Ref> dispatch(deserialization_buffer& buf); template<class C> static void broadcastStaticField(C f, serialization_id_t id); static void await(); static void notify(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2009-10-27 20:18:03
|
Revision: 11784 http://x10.svn.sourceforge.net/x10/?rev=11784&view=rev Author: dgrove-oss Date: 2009-10-27 20:17:50 +0000 (Tue, 27 Oct 2009) Log Message: ----------- Both Java and C++ codegen working again. Most of this is a patch from Igor with a few tweaks. C++ multi-place execution still broken. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.dist/build.xml trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/lang/Any.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-27 20:17:50 UTC (rev 11784) @@ -652,13 +652,13 @@ return cd; } - X10ClassDef ANY_DEF = null; - public X10ClassDef AnyDef() { - if (ANY_DEF == null) { - ANY_DEF = makeAnyDef(); - } - return ANY_DEF; - } +// X10ClassDef ANY_DEF = null; +// public X10ClassDef AnyDef() { +// if (ANY_DEF == null) { +// ANY_DEF = makeAnyDef(); +// } +// return ANY_DEF; +// } public X10ClassDef makeAnyDef() { @@ -1751,9 +1751,12 @@ return CLASS_ = load("x10.lang.Class"); } - + Type ANY_ = null; public Type Any() { - return AnyDef().asType(); + if (ANY_ != null) + return ANY_; + return ANY_ = load("x10.lang.Any"); +// return AnyDef().asType(); } Type STRUCT_ = null; Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2009-10-27 20:17:50 UTC (rev 11784) @@ -549,13 +549,16 @@ List<TypeNode> interfaces = new ArrayList<TypeNode>(); for (TypeNode tn: n.interfaces()) { - Type sup = tn.type(); - X10TypeSystem ts = (X10TypeSystem) tr.typeSystem(); - if (! ts.typeBaseEquals(sup, ts.Object(), tr.context())) - interfaces.add(tn); + if (!xts.isAny(tn.type())) { + interfaces.add(tn); + } } + if (n.flags().flags().isInterface() && interfaces.isEmpty()) { + X10TypeSystem ts = (X10TypeSystem) tr.typeSystem(); + interfaces.add(tr.nodeFactory().CanonicalTypeNode(n.position(), ts.Any())); + } - if (! interfaces.isEmpty()) { + if (!interfaces.isEmpty()) { w.allowBreak(2); if (flags.isInterface()) { w.write("extends "); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-10-27 20:17:50 UTC (rev 11784) @@ -632,6 +632,12 @@ // emit no c++ code as this is a native rep class return; } + + if (xts.isAny(def.asType())) { + // HACK: We don't need Any in the C++ backend, but we do in the Java backend. + // So, here we want to ignore the class decl for x10.lang.Any + return; + } assert (!def.isNested()) : ("Nested class alert!"); Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.dist/build.xml 2009-10-27 20:17:50 UTC (rev 11784) @@ -73,14 +73,9 @@ </target> <target name="dist-java" depends="init,build,common-jar,constraints-jar,compiler-jar,runtime-java"/> -<!-- HACK: DG: Break dependency on dist-java for dist-cpp while working on getting C++ codegen working for 2.0 - Restore these two lines once Java codegen is working again <target name="dist-cpp" depends="dist-java,runtime-cpp"/> <target name="dist" depends="dist-java,dist-cpp"/> ---> - <target name="dist-cpp" depends="init,build,common-jar,constraints-jar,compiler-jar,runtime-cpp"/> - <target name="dist" depends="dist-cpp"/> -<!-- END HACK --> + <target name="lpg-jar" depends="init,lpg-local-jar" unless="local.lpg.jar"> <mkdir dir="${lib}"/> <get usetimestamp="true" ignoreerrors="true" src="${lpg.jar.url}" dest="${lib}/lpg-plugin.jar"/> Modified: trunk/x10.runtime/src-java/x10/core/Ref.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Ref.java 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.runtime/src-java/x10/core/Ref.java 2009-10-27 20:17:50 UTC (rev 11784) @@ -14,7 +14,7 @@ // Base class of all X10 ref objects -- should be generated, but we need this class to get Box to compile. -public class Ref { +public class Ref implements Any { public final int location; public Ref() { @@ -84,4 +84,12 @@ } } } + + public static int location(Object obj) { + if (obj instanceof Ref) { + return ((Ref)obj).location(); + } else { + return Thread.currentThread().location(); + } + } } Added: trunk/x10.runtime/src-x10/x10/lang/Any.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Any.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/lang/Any.x10 2009-10-27 20:17:50 UTC (rev 11784) @@ -0,0 +1,32 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.lang; + +import x10.compiler.Native; +import x10.compiler.NativeRep; + +@NativeRep("java", "x10.core.Any", null, null) +//@NativeRep("c++", "ERROR!", "ERROR!", null) +public interface Any { + @Native("java", "#0.getClass().toString()") + //@Native("c++", "x10aux::to_string(#0)") + public global def typeName(): String; + + @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") + //@Native("c++", "ERROR: loc!") + property global def loc():Place; + + @Native("java", "x10.core.Ref.at(#0, #1.id)") + //@Native("c++", "ERROR: at(Place)!") + property global def at(p:Place):Boolean; + + @Native("java", "x10.core.Ref.at(#0, #1)") + //@Native("c++", "ERROR: at(Object)!") + property global def at(r:Object):Boolean; +} Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-27 20:17:50 UTC (rev 11784) @@ -14,10 +14,10 @@ /** * The base class for all reference classes. */ -@NativeRep("java", "x10.core.Ref", null, null) +@NativeRep("java", "java.lang.Object", null, null) @NativeRep("c++", "x10aux::ref<x10::lang::Ref>", "x10::lang::Ref", null) public class Object ( - @Native("java", "x10.lang.Place.place(#0.location())") + @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") @Native("c++", "x10::lang::Place_methods::place((#0)->location)") location: Place) // implements Equals @@ -47,7 +47,7 @@ @Native("c++", "x10aux::type_name(#0)") public global native def typeName() : String; - @Native("java", "#0.location()") + @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") @Native("c++", "x10::lang::Place_methods::place((#0)->location)") public property def loc() = location; @@ -55,7 +55,7 @@ @Native("c++", "((#0)->location == (#1)->FMGL(id))") public property def at(p:Place) = location==p; - @Native("java", "#0.at(#1)") + @Native("java", "x10.core.Ref.at(#0, #1)") @Native("c++", "((#0)->location == (#1)->location)") public property def at(r:Object) = location==r.location; Modified: trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 2009-10-27 19:23:05 UTC (rev 11783) +++ trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 2009-10-27 20:17:50 UTC (rev 11784) @@ -51,7 +51,9 @@ @Native("java", "#0.toString()") public native def toString():String; - public def typeName()="x10.runtime.PlaceLocalHandle"; + @Native("c++", "(#0)->typeName()") + @Native("java", "#0.typeName()") + public native def typeName():String; // Only to be used by create methods in PlaceLocalStorage @Native("c++", "(#0)->set(#1)") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-10-28 03:49:10
|
Revision: 11811 http://x10.svn.sourceforge.net/x10/?rev=11811&view=rev Author: ipeshansky Date: 2009-10-28 03:49:02 +0000 (Wed, 28 Oct 2009) Log Message: ----------- Dave Cunningham's support for finish specialization. Currently only supporting @Immediate finishes rewritten into x10rt_remote_op_fence. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-x10/x10/runtime/RemoteOperation.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-10-28 03:23:23 UTC (rev 11810) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-10-28 03:49:02 UTC (rev 11811) @@ -275,6 +275,7 @@ } private static final Name XOR = Name.make("xor"); + private static final Name FENCE = Name.make("fence"); private static final QName IMMEDIATE = QName.make("x10.compiler.Immediate"); private static final QName REMOTE_OPERATION = QName.make("x10.runtime.RemoteOperation"); @@ -442,11 +443,24 @@ private Expr call(Position pos, Name name, Type returnType) throws SemanticException { return synth.makeStaticCall(pos, xts.Runtime(), name, returnType, xContext()); } + + private Stmt specializeFinish(Finish f) throws SemanticException { + if (!hasAnnotation(f, QName.make("x10.compiler.Immediate"))) + return null; + Position pos = f.position(); + ClassType target = (ClassType) xts.typeForName(REMOTE_OPERATION); + List<Expr> args = new ArrayList<Expr>(); + return xnf.Block(pos, f.body(), xnf.Eval(pos, synth.makeStaticCall(pos, target, FENCE, args, xts.Void(), xContext()))); + } private Stmt visitFinish(Finish f) throws SemanticException { Position pos = f.position(); Name tmp = getTmp(); - + + Stmt specializedFinish = specializeFinish(f); + if (specializedFinish != null) + return specializedFinish; + // TODO: merge with the call() function MethodInstance mi = xts.findMethod(xts.Runtime(), xts.MethodMatcher(xts.Runtime(), PUSH_EXCEPTION, Collections.singletonList(xts.Throwable()), context)); Modified: trunk/x10.runtime/src-x10/x10/runtime/RemoteOperation.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RemoteOperation.x10 2009-10-28 03:23:23 UTC (rev 11810) +++ trunk/x10.runtime/src-x10/x10/runtime/RemoteOperation.x10 2009-10-28 03:49:02 UTC (rev 11811) @@ -21,4 +21,7 @@ (r as Rail[Long]!)(i) ^= v; } } + + @Native("c++", "x10rt_remote_op_fence()") + public static def fence() { } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-02 13:31:33
|
Revision: 11880 http://x10.svn.sourceforge.net/x10/?rev=11880&view=rev Author: vj0 Date: 2009-11-02 13:31:18 +0000 (Mon, 02 Nov 2009) Log Message: ----------- Removed x10.lang.Struct and x10.lang.Any. The code for these units is created automatically inside X10TypeSystem. typeName() is now synthesized automatically by the frontend. It is an error for this method to be defined in user code. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Byte.x10 trunk/x10.runtime/src-x10/x10/lang/Char.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/Double.x10 trunk/x10.runtime/src-x10/x10/lang/Float.x10 trunk/x10.runtime/src-x10/x10/lang/Int.x10 trunk/x10.runtime/src-x10/x10/lang/Long.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Short.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/UByte.x10 trunk/x10.runtime/src-x10/x10/lang/UInt.x10 trunk/x10.runtime/src-x10/x10/lang/ULong.x10 trunk/x10.runtime/src-x10/x10/lang/UShort.x10 trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/runtime/RID.x10 trunk/x10.runtime/src-x10/x10/util/Pair.x10 Added Paths: ----------- trunk/x10.runtime/src-java/x10/core/Struct.java Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/lang/Struct.x10 Property Changed: ---------------- trunk/x10.compiler/src/x10/parser/ Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -34,6 +34,7 @@ import polyglot.ast.NodeFactory; import polyglot.ast.PackageNode; import polyglot.ast.SourceFile; +import polyglot.ast.Stmt; import polyglot.ast.Term; import polyglot.ast.TopLevelDecl; import polyglot.ast.TypeNode; @@ -63,10 +64,12 @@ import polyglot.types.Ref_c; import polyglot.types.ReferenceType; import polyglot.types.SemanticException; +import polyglot.types.StructType; import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; import polyglot.types.UnknownType; +import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.TypedList; import polyglot.visit.CFGBuilder; @@ -209,6 +212,7 @@ if (thisType.fullName().equals(QName.make("x10.lang.Object"))) { thisType.superType(null); } else if (thisType.fullName().equals(QName.make("x10.lang.Struct"))) { + assert false; thisType.superType(null); } else if (flags().flags().isInterface()) { @@ -607,6 +611,28 @@ return n; } + + public static MethodDecl makeTypeNameMethod(Id name, X10NodeFactory nf) { + // Cannot use the type system. This code is called during parsing. + // e.g. cannot say nf.CanonicalTypeNode(pos, ts.String()) + // since that will cause String to get loaded, and we get a stack overflow. + Position pos = Position.COMPILER_GENERATED; + + Stmt s = nf.Return(pos, nf.StringLit(pos, name.toString())); + Block b = nf.Block(pos, s); + + MethodDecl tnMethod = nf.MethodDecl(pos, + nf.FlagsNode(pos, X10Flags.toX10Flags(Flags.PUBLIC).Global()), + nf.AmbTypeNode(pos, nf.PrefixFromQualifiedName(pos, QName.make("x10.lang")), nf.Id(pos, "String")), + nf.Id(pos, Name.make("typeName")), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + b + ); + return tnMethod; + + } + public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10ClassDecl_c n = this; @@ -684,20 +710,22 @@ if (t != null) { if (!t.typeEquals(ct, tc.context())) { String kind = ct.flags().isInterface() ? "interface" : "class"; - throw new SemanticException("Cannot extend different instantiations of the same " + kind + "; " + type + " extends both " + t + " and " + throw new SemanticException("Cannot extend different instantiations of the same " + kind + ";\n" + + type + " extends both " + t + " and " + ct + ".", position()); } } map.put(ct.x10Def(), ct); } + n = (X10ClassDecl_c) n.adjustAbstractMethods(oldtc); if (X10Flags.toX10Flags(flags().flags()).isStruct()) { n.checkStructMethods(parent, tc); } - + return n; } @@ -905,7 +933,8 @@ if (job != null) { Source s = job.source(); if (! s.name().startsWith(type.name() + ".")) { - throw new SemanticException("Public type " + type.fullName() + " must be declared in " + type.name() + ".x10.", result.position()); + throw new SemanticException("Public type " + type.fullName() + + " must be declared in " + type.name() + ".x10.", result.position()); } } } @@ -929,7 +958,8 @@ if (fi instanceof X10FieldInstance) { X10FieldInstance xfi = (X10FieldInstance) fi; if (xfi.isProperty()) - ex = new SemanticException("Class " + type + " cannot override property " + fi.name() + " of superclass " + Types.get(fi.def().container()) + "."); + ex = new SemanticException("Class " + type + " cannot override property " + + fi.name() + " of superclass " + Types.get(fi.def().container()) + "."); } } catch (SemanticException e) { Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -360,11 +360,18 @@ return (X10ClassDecl) ClassDecl(pos, flags, name, typeParameters, properties, superClass, interfaces, body, ci); } - private ClassDecl ClassDecl(Position pos, FlagsNode flags, Id name, List<TypeParamNode> typeParameters, List<PropertyDecl> properties, TypeNode superClass, List<TypeNode> interfaces, ClassBody body, DepParameterExpr tci) { + private ClassDecl ClassDecl(Position pos, FlagsNode flags, Id name, List<TypeParamNode> typeParameters, List<PropertyDecl> properties, + TypeNode superClass, List<TypeNode> interfaces, ClassBody body, DepParameterExpr tci) { boolean isInterface = flags.flags().isInterface(); - body = flags.flags().isInterface() - ? PropertyDecl_c.addAbstractGetters(properties, body, this) - : PropertyDecl_c.addPropertyGetters(properties, body, this); + if (flags.flags().isInterface()) { + body = PropertyDecl_c.addAbstractGetters(properties, body, this); + } else { + body = PropertyDecl_c.addPropertyGetters(properties, body, this); + if (! name.toString().equals("Struct")) { + body = body.addMember(X10ClassDecl_c.makeTypeNameMethod(name, this)); + } + } + ClassDecl n = new X10ClassDecl_c(pos, flags, name, typeParameters, properties, tci, superClass, interfaces, body); n = (ClassDecl)n.ext(extFactory().extClassDecl()); Property changes on: trunk/x10.compiler/src/x10/parser ___________________________________________________________________ Modified: svn:ignore - *.l + *.l *.patch Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -124,6 +124,8 @@ Type Object(); Type Any(); + Type NativeType(); + Type NativeRep(); XLit FALSE(); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -79,6 +79,7 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.TypeBuilder; import x10.ast.X10NodeFactory; +import x10.ast.X10StringLit_c; import x10.constraint.XConstrainedTerm; import x10.constraint.XConstraint; import x10.constraint.XConstraint_c; @@ -503,14 +504,8 @@ return cd; } - X10ClassDef STRUCT_DEF = null; - public X10ClassDef StructDef() { - if (STRUCT_DEF == null) { - STRUCT_DEF = makeStructDef(); - } - return STRUCT_DEF; - } - public X10ClassDef makeStructDef() { + + private X10ClassDef StructDef() { final X10TypeSystem xts = this; final Position pos = Position.COMPILER_GENERATED; @@ -541,26 +536,19 @@ cd.superType(null); // base class has no superclass // Functions implement the Any interface. //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract())); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); // NOTE: don't call cd.asType() until after the type parameters are // added. X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - // xts.systemResolver().install(fullName, ct); + xts.systemResolver().install(fullName, ct); String fullNameWithThis = fullName + "#this"; //String fullNameWithThis = "this"; XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); XRoot thisVar = XTerms.makeLocal(thisName); - /*public strct Struct { - public native def toString():String; - public native def typeName():String; - property def loc()=here; - property def at(p:Place)=true; - property def at(r:Object)=true; - }*/ final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); PLACE.setResolver(new Runnable() { public void run() { @@ -579,34 +567,25 @@ BOOLEAN.update((X10ParsedClassType) xts.Boolean()); } }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + X10ConstructorDef ci = (X10ConstructorDef) constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST); + cd.addConstructor(ci); + + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; - X10MethodDef mi = methodDef(pos, Types.ref(ct), - Flags.PUBLIC.Native(), STRING, - Name.make("toString"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - cd.addMethod(mi); + // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") + // property def loc():Place mi = methodDef(pos, Types.ref(ct), - Flags.PUBLIC.Native(), STRING, - Name.make("typeName"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - cd.addMethod(mi); - - mi = methodDef(pos, Types.ref(ct), - Flags.PUBLIC.Abstract(), PLACE, + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global(), PLACE, Name.make("loc"), Collections.EMPTY_LIST, Collections.EMPTY_LIST, @@ -616,13 +595,21 @@ null, Collections.EMPTY_LIST, null); - cd.addMethod(mi); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); } }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); mi = methodDef(pos, Types.ref(ct), X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, @@ -635,7 +622,21 @@ null, Collections.EMPTY_LIST, null); + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); mi = methodDef(pos, Types.ref(ct), X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, @@ -648,23 +649,43 @@ null, Collections.EMPTY_LIST, null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); cd.addMethod(mi); - + + //@NativeRep("java", "x10.core.Struct", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Struct")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); return cd; } -// X10ClassDef ANY_DEF = null; -// public X10ClassDef AnyDef() { -// if (ANY_DEF == null) { -// ANY_DEF = makeAnyDef(); -// } -// return ANY_DEF; -// } - - - public X10ClassDef makeAnyDef() { + + private X10ClassDef AnyDef() { final X10TypeSystem xts = this; final Position pos = Position.COMPILER_GENERATED; + String name = "Any"; X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { @@ -679,22 +700,23 @@ }; cd.position(pos); + // interface Any .... cd.name(Name.make(name)); + // package x10.lang; try { cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); } catch (SemanticException e) { assert false; } - QName fullName = QName.make("x10.lang", name); + cd.kind(ClassDef.TOP_LEVEL); cd.superType(null); // interfaces have no superclass // Functions implement the Any interface. //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); - // NOTE: don't call cd.asType() until after the type parameters are // added. X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); @@ -705,14 +727,6 @@ XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); XRoot thisVar = XTerms.makeLocal(thisName); - /*public interface Any { - - def toString():String; - def typeName():String; - property def loc():Place; - property def at(p:Place):boolean; - property def at(r:Object):boolean; -}*/ final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); PLACE.setResolver(new Runnable() { public void run() { @@ -731,33 +745,21 @@ BOOLEAN.update((X10ParsedClassType) xts.Boolean()); } }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + - X10MethodDef mi = methodDef(pos, Types.ref(ct), - Flags.PUBLIC.Abstract(), STRING, - Name.make("toString"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - cd.addMethod(mi); + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; + + // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") + // property def loc():Place mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Global(), STRING, - Name.make("typeName"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - cd.addMethod(mi); - - mi = methodDef(pos, Types.ref(ct), X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property().Global(), PLACE, Name.make("loc"), Collections.EMPTY_LIST, @@ -768,13 +770,21 @@ null, Collections.EMPTY_LIST, null); - cd.addMethod(mi); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); } }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); mi = methodDef(pos, Types.ref(ct), X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, @@ -787,8 +797,22 @@ null, Collections.EMPTY_LIST, null); + + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); cd.addMethod(mi); - + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); mi = methodDef(pos, Types.ref(ct), X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, @@ -801,10 +825,38 @@ null, Collections.EMPTY_LIST, null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); cd.addMethod(mi); - + + //@NativeRep("java", "x10.core.Any", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Any")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); return cd; } + public List<LocalDef> dummyLocalDefs(List<Ref<? extends Type>> types) { List<LocalDef> list = new ArrayList<LocalDef>(); for (int i = 0; i < types.size(); i++) { @@ -1755,16 +1807,14 @@ public Type Any() { if (ANY_ != null) return ANY_; - return ANY_ = load("x10.lang.Any"); -// return AnyDef().asType(); + return ANY_ = AnyDef().asType(); } Type STRUCT_ = null; public Type Struct() { - if (STRUCT_ == null) { - STRUCT_ = load("x10.lang.Struct"); - } - return STRUCT_; + if (STRUCT_ != null) + return STRUCT_; + return STRUCT_ = StructDef().asType(); } public Type String() { if (STRING_ != null) @@ -1834,6 +1884,18 @@ return iterableType_; } + protected ClassType nativeRepType_; + public Type NativeRep() { + if (nativeRepType_ == null) + nativeRepType_ = load("x10.compiler.NativeRep"); + return nativeRepType_; + } + protected ClassType nativeType_; + public Type NativeType() { + if (nativeType_ == null) + nativeType_ = load("x10.compiler.Native"); + return nativeType_; + } public Type Iterable(Type index) { return X10TypeMixin.instantiate(Iterable(), index); } @@ -2565,6 +2627,7 @@ o.setDefAnnotations(newATs); } + public boolean clausesConsistent(x10.constraint.XConstraint c1, x10.constraint.XConstraint c2, Context context) { X10TypeEnv env = env(context); Modified: trunk/x10.compiler/src/x10/util/Synthesizer.java =================================================================== --- trunk/x10.compiler/src/x10/util/Synthesizer.java 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.compiler/src/x10/util/Synthesizer.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -103,8 +103,18 @@ public X10ClassDecl_c addSyntheticMethod(X10ClassDecl_c ct, Flags flags, Name name, List<LocalDef> fmls, Type returnType, List<Type> trow, Block block) { - assert ct.classDef() != null; + assert ct.classDef() != null; + MethodDecl result = makeSyntheticMethod(ct, flags, name,fmls, returnType, trow, block); + ClassBody b = ct.body(); + b = b.addMember(result); + ct.classDef().addMethod(result.methodDef()); + return (X10ClassDecl_c) ct.body(b); + } + public MethodDecl makeSyntheticMethod(X10ClassDecl_c ct, Flags flags, + Name name, List<LocalDef> fmls, + Type returnType, List<Type> trow, Block block) { + Position CG = Position.COMPILER_GENERATED; List<Expr> args = new ArrayList<Expr>(); List<Ref<? extends Type>> argTypes = new ArrayList<Ref<? extends Type>>(); @@ -142,12 +152,9 @@ MethodDef rmi = xts.methodDef(CG, Types.ref(ct.classDef().asType()), newFlags.flags(), rt.typeRef(), name, argTypes, throwTypes); - ct.classDef().addMethod(rmi); + result = result.methodDef(rmi); - - ClassBody b = ct.body(); - b = b.addMember(result); - return (X10ClassDecl_c) ct.body(b); + return result; } public static XTerm makeProperty(Type type, XVar receiver, String name) { Added: trunk/x10.runtime/src-java/x10/core/Struct.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Struct.java (rev 0) +++ trunk/x10.runtime/src-java/x10/core/Struct.java 2009-11-02 13:31:18 UTC (rev 11880) @@ -0,0 +1,25 @@ +package x10.core; + +import x10.types.RuntimeType; +import x10.types.Type; + +// Base class for all X10 structs +public abstract class Struct { + + public static class RTT extends RuntimeType<Struct> { + public static final RTT it = new RTT(); + + public RTT() { + super(Struct.class); + } + + @Override + public boolean instanceof$(Object o) { + return o instanceof Struct; + } + + } + + public Struct() {} + +} Deleted: trunk/x10.runtime/src-x10/x10/lang/Any.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Any.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Any.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -1,32 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.lang; - -import x10.compiler.Native; -import x10.compiler.NativeRep; - -@NativeRep("java", "x10.core.Any", null, null) -//@NativeRep("c++", "ERROR!", "ERROR!", null) -public interface Any { - @Native("java", "#0.getClass().toString()") - //@Native("c++", "x10aux::to_string(#0)") - property global def typeName(): String; - - @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") - //@Native("c++", "ERROR: loc!") - property global def loc():Place; - - @Native("java", "x10.core.Ref.at(#0, #1.id)") - //@Native("c++", "ERROR: at(Place)!") - property global def at(p:Place):Boolean; - - @Native("java", "x10.core.Ref.at(#0, #1)") - //@Native("c++", "ERROR: at(Object)!") - property global def at(r:Object):Boolean; -} Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -44,10 +44,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Boolean.parseBoolean(#1)") @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") public native static def parseBoolean(String): Boolean; Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -147,10 +147,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Byte.parseByte(#1, #2)") @Native("c++", "x10aux::byte_utils::parseByte(#1, #2)") public native static def parseByte(String, radix: Int): Byte throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Char.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Char.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -63,10 +63,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - // Duplicate the methods from java.lang.Character, changing static methods to non-static. // We'll ignore the code point methods for now and just include the isXXX ones. Modified: trunk/x10.runtime/src-x10/x10/lang/Complex.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -187,6 +187,5 @@ public def toString():String { return (re + " + " + im + "i"); } - public def typeName() = "x10.lang.Complex"; } Modified: trunk/x10.runtime/src-x10/x10/lang/Double.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Double.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -107,9 +107,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; @Native("java", "java.lang.Double.parseDouble(#1)") @Native("c++", "x10aux::double_utils::parseDouble(#1)") Modified: trunk/x10.runtime/src-x10/x10/lang/Float.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Float.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -109,9 +109,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; @Native("java", "java.lang.Float.parseFloat(#1)") @Native("c++", "x10aux::float_utils::parseFloat(#1)") Modified: trunk/x10.runtime/src-x10/x10/lang/Int.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Int.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -137,10 +137,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Integer.toString(#0, #1)") @Native("c++", "x10aux::int_utils::toString(#0, #1)") public native def toString(radix: Int): String; Modified: trunk/x10.runtime/src-x10/x10/lang/Long.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Long.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -147,10 +147,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Long.parseLong(#1, #2)") @Native("c++", "x10aux::long_utils::parseLong(#1, #2)") public native static def parseLong(String, radix: Int): Long throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -43,10 +43,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString() : String; - @Native("java", "#0.getClass().getName()") - @Native("c++", "x10aux::type_name(#0)") - public global native def typeName() : String; - @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") @Native("c++", "x10::lang::Place_methods::place((#0)->location)") public property def loc() = location; Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -42,5 +42,4 @@ public def isLast(): boolean = id == MAX_PLACES - 1; public def toString() = "(Place " + id + ")"; - public def typeName() = "x10.lang.Place"; } Modified: trunk/x10.runtime/src-x10/x10/lang/Short.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Short.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -147,10 +147,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Short.parseShort(#1, #2)") @Native("c++", "x10aux::short_utils::parseShort(#1, #2)") public native static def parseShort(String, radix: Int): Short throws NumberFormatException; Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -30,10 +30,6 @@ @Native("c++", "x10aux::to_string(#0)") public native global def toString(): String; - @Native("java", "\"x10.lang.String\"") - @Native("c++", "x10::lang::String::Lit((#0)->_type()->name())") - public native global def typeName():String; - @Native("java", "#0.length()") @Native("c++", "#0->length()") public native global def length(): Int; Deleted: trunk/x10.runtime/src-x10/x10/lang/Struct.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Struct.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/Struct.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -1,11 +0,0 @@ -package x10.lang; - -public abstract struct Struct { - - public def this() {} - //public native def toString():String; - //public native def typeName():String; - public global property def loc():Place=here; - public global property def at(p:Place):Boolean=true; - public global property def at(o:Object):Boolean=true; -} Modified: trunk/x10.runtime/src-x10/x10/lang/UByte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/UByte.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -133,9 +133,6 @@ @Native("c++", "0xffU") public const MAX_VALUE = 0xff; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; @Native("java", "java.lang.Integer.toString(#0 & 0xff)") @Native("c++", "x10aux::to_string(#0)") Modified: trunk/x10.runtime/src-x10/x10/lang/UInt.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/UInt.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -144,10 +144,6 @@ @Native("c++", "0xffffffffU") public const MAX_VALUE = 0xffffffff; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Long.toString(#0 & 0xffffffffL)") @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; Modified: trunk/x10.runtime/src-x10/x10/lang/ULong.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/ULong.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -140,9 +140,6 @@ @Native("c++", "x10aux::to_string(#0)") public native def toString(): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; @Native("java", "java.lang.Long.toString(#0 & 0xffffffffffffffffL, #1)") @Native("c++", "x10aux::int_utils::toString(#0, #1)") Modified: trunk/x10.runtime/src-x10/x10/lang/UShort.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/lang/UShort.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -143,10 +143,6 @@ @Native("c++", "x10aux::int_utils::toString(#0, #1)") public native def toString(radix: Int): String; - @Native("java", "#0.getClass().toString()") - @Native("c++", "x10aux::type_name(#0)") - public native def typeName(): String; - @Native("java", "java.lang.Integer.toHexString(#0)") @Native("c++", "x10aux::int_utils::toHexString(#0)") public native def toHexString(): String; Modified: trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/runtime/PlaceLocalHandle.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -51,10 +51,6 @@ @Native("java", "#0.toString()") public native def toString():String; - @Native("c++", "(#0)->typeName()") - @Native("java", "#0.typeName()") - public native def typeName():String; - // Only to be used by create methods in PlaceLocalStorage @Native("c++", "(#0)->set(#1)") @Native("java", "#0.set(#1)") Modified: trunk/x10.runtime/src-x10/x10/runtime/RID.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -5,5 +5,5 @@ public def hashCode():Int = id; public incomplete def toString():String; - public def typeName()="x10.lang.RID"; + } Modified: trunk/x10.runtime/src-x10/x10/util/Pair.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Pair.x10 2009-10-31 13:12:10 UTC (rev 11879) +++ trunk/x10.runtime/src-x10/x10/util/Pair.x10 2009-11-02 13:31:18 UTC (rev 11880) @@ -23,5 +23,5 @@ public def toString():String { return "(" + first + ", " + second + ")"; } - public def typeName():String = "x10.util.Pair"; + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-03 01:39:08
|
Revision: 11887 http://x10.svn.sourceforge.net/x10/?rev=11887&view=rev Author: ipeshansky Date: 2009-11-03 01:38:59 +0000 (Tue, 03 Nov 2009) Log Message: ----------- Handle synthetic x10.lang.Struct in the C++ backend. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.runtime/src-cpp/Makefile Added Paths: ----------- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc trunk/x10.runtime/src-cpp/x10/lang/Struct.h trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-11-02 21:19:10 UTC (rev 11886) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2009-11-03 01:38:59 UTC (rev 11887) @@ -222,6 +222,8 @@ boolean isSettable(Type me); boolean isAny(Type me); + + boolean isStruct(Type me); boolean isClock(Type me); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-11-02 21:19:10 UTC (rev 11886) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-11-03 01:38:59 UTC (rev 11887) @@ -677,7 +677,26 @@ } }); - cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); + //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) + final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); + NATIVE_REP_CPP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "c++")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP_CPP.update(ann); + } + }); + + List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); + cd_ann.add(NATIVE_REP); + cd_ann.add(NATIVE_REP_CPP); + cd.setDefAnnotations(cd_ann); +// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); return cd; } @@ -2186,6 +2205,10 @@ return typeEquals(me, Any(), emptyContext()); } + public boolean isStruct(Type me) { + return typeEquals(me, Struct(), emptyContext()); + } + public boolean isClock(Type me) { return isSubtype(me, Clock(), emptyContext()); } Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-11-02 21:19:10 UTC (rev 11886) +++ trunk/x10.runtime/src-cpp/Makefile 2009-11-03 01:38:59 UTC (rev 11887) @@ -213,6 +213,7 @@ x10/lang/RailIterator.o \ x10/lang/Ref.o \ x10/lang/String.o \ + x10/lang/Struct.o \ x10/lang/Throwable.o \ x10/lang/Value.o \ x10/lang/ValRail.o \ Added: trunk/x10.runtime/src-cpp/x10/lang/Struct.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.cc 2009-11-03 01:38:59 UTC (rev 11887) @@ -0,0 +1,33 @@ +#include <x10/lang/Struct.h> + +using namespace x10aux; +using namespace x10::lang; + +void Struct_methods::_instance_init(Struct *this_) { + _I_("Doing initialisation for class: x10::lang::Struct"); +} + +void Struct_methods::_constructor(Struct *this_) { +} + +x10_boolean Struct::_struct_equals(Struct that) { + return true; +} + +void Struct::_serialize(Struct this_, serialization_buffer& buf, addr_map& m) { +} + +void Struct::_deserialize_body(deserialization_buffer& buf) { +} + +x10_int Struct::hashCode() { + return 0; +} + +RuntimeType Struct::rtt; +void Struct::_initRTT() { + rtt.canonical = &rtt; + rtt.init(&rtt, "x10.lang.Struct", 0, NULL, 0, NULL, NULL); +} + +// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 Added: trunk/x10.runtime/src-cpp/x10/lang/Struct.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.h 2009-11-03 01:38:59 UTC (rev 11887) @@ -0,0 +1,25 @@ +#ifndef __X10_LANG_STRUCT_H +#define __X10_LANG_STRUCT_H + +#include <x10rt17.h> + +namespace x10 { + namespace lang { + + class Struct_methods { + public: + static void _instance_init(x10::lang::Struct *this_); + static void _constructor(x10::lang::Struct *this_); + }; + + } +} +#endif // X10_LANG_STRUCT_H + +namespace x10 { + namespace lang { + class Struct; + } +} + +// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 Added: trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h (rev 0) +++ trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h 2009-11-03 01:38:59 UTC (rev 11887) @@ -0,0 +1,34 @@ +#ifndef __X10_LANG_STRUCT_STRUCT_H +#define __X10_LANG_STRUCT_STRUCT_H + +#include <x10aux/config.h> +#include <x10aux/ref.h> +#include <x10aux/RTT.h> +#include <x10aux/serialization.h> + +namespace x10 { + + namespace lang { + + class String; + + class Struct { + public: + RTT_H_DECLS_STRUCT + + x10_boolean _struct_equals(x10::lang::Struct that); + + static void _serialize(x10::lang::Struct this_, x10aux::serialization_buffer& buf, x10aux::addr_map& m); + + void _deserialize_body(x10aux::deserialization_buffer& buf); + + x10aux::ref<x10::lang::String> toString(); + + x10_int hashCode(); + + x10aux::ref<x10::lang::String> typeName(); + }; + } +} +#endif // X10_LANG_STRUCT_STRUCT_H +// vim:tabstop=4:shiftwidth=4:expandtab:textwidth=100 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-04 00:39:42
|
Revision: 11910 http://x10.svn.sourceforge.net/x10/?rev=11910&view=rev Author: vj0 Date: 2009-11-04 00:39:30 +0000 (Wed, 04 Nov 2009) Log Message: ----------- Moved the java code generating Any and Struct into separate classes in x10.util. typeName is now defined on Struct and Object and has a native annotation in Java redirecting to x10.core.Ref.typeName. (Similar annotation may be needed for C++. See x10.lang.Object and Struct.java. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-x10/x10/lang/Dist.x10 trunk/x10.runtime/src-x10/x10/lang/Object.x10 trunk/x10.tests/examples/Constructs/Distribution/PolyDistAlgebra1.x10 trunk/x10.tests/examples/Constructs/Instanceof/X10InterfaceOne.x10 trunk/x10.tests/examples/Constructs/PlaceCast/PlaceCast.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/util/Any.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 Removed Paths: ------------- trunk/x10.tests/examples/Issues/XTENLANG_298.x10 Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -87,6 +87,7 @@ import x10.constraint.XTerm; import x10.extension.X10Del; import x10.extension.X10Del_c; +import x10.extension.X10Ext; import x10.types.MacroType; import x10.types.ParameterType; import x10.types.TypeConstraint; @@ -100,6 +101,7 @@ import x10.types.X10Flags; import x10.types.X10MethodDef; import x10.types.X10MethodInstance; +import x10.types.X10ParsedClassType; import x10.types.X10Type; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; @@ -612,27 +614,7 @@ } - public static MethodDecl makeTypeNameMethod(Id name, X10NodeFactory nf) { - // Cannot use the type system. This code is called during parsing. - // e.g. cannot say nf.CanonicalTypeNode(pos, ts.String()) - // since that will cause String to get loaded, and we get a stack overflow. - Position pos = Position.COMPILER_GENERATED; - Stmt s = nf.Return(pos, nf.StringLit(pos, name.toString())); - Block b = nf.Block(pos, s); - - MethodDecl tnMethod = nf.MethodDecl(pos, - nf.FlagsNode(pos, X10Flags.toX10Flags(Flags.PUBLIC).Global()), - nf.AmbTypeNode(pos, nf.PrefixFromQualifiedName(pos, QName.make("x10.lang")), nf.Id(pos, "String")), - nf.Id(pos, Name.make("typeName")), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - b - ); - return tnMethod; - - } - public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10ClassDecl_c n = this; Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -86,6 +86,7 @@ import x10.ast.X10Cast.ConversionType; import x10.types.ParameterType; import x10.types.X10ConstructorDef; +import x10.types.X10Flags; /** * NodeFactory for X10 extension. @@ -367,9 +368,6 @@ body = PropertyDecl_c.addAbstractGetters(properties, body, this); } else { body = PropertyDecl_c.addPropertyGetters(properties, body, this); - if (! name.toString().equals("Struct")) { - body = body.addMember(X10ClassDecl_c.makeTypeNameMethod(name, this)); - } } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -505,377 +505,10 @@ } - private X10ClassDef StructDef() { - final X10TypeSystem xts = this; - final Position pos = Position.COMPILER_GENERATED; - - String name = "Struct"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; - - cd.position(pos); - cd.name(Name.make(name)); - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } - - QName fullName = QName.make("x10.lang", name); - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // base class has no superclass - // Functions implement the Any interface. - //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); - - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - X10ConstructorDef ci = (X10ConstructorDef) constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST); - cd.addConstructor(ci); - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; - - // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") - // property def loc():Place - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global(), PLACE, - Name.make("loc"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1.id)") - // property def at(p:Place):boolean; - parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Struct", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Struct")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) - final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); - NATIVE_REP_CPP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "c++")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(new X10StringLit_c(pos, "x10::lang::Struct")); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP_CPP.update(ann); - } - }); - - List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); - cd_ann.add(NATIVE_REP); - cd_ann.add(NATIVE_REP_CPP); - cd.setDefAnnotations(cd_ann); -// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; - } + - private X10ClassDef AnyDef() { - final X10TypeSystem xts = this; - final Position pos = Position.COMPILER_GENERATED; - - - String name = "Any"; - X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(this, null) { - - @Override - public ClassType asType() { - if (asType == null) { - X10ClassDef cd = this; - asType = new X10ParsedClassType_c(this); - } - return asType; - } - }; - - cd.position(pos); - // interface Any .... - cd.name(Name.make(name)); - // package x10.lang; - try { - cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); - } - catch (SemanticException e) { - assert false; - } - QName fullName = QName.make("x10.lang", name); - - cd.kind(ClassDef.TOP_LEVEL); - cd.superType(null); // interfaces have no superclass - // Functions implement the Any interface. - //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); - cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); - - // NOTE: don't call cd.asType() until after the type parameters are - // added. - X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); - xts.systemResolver().install(fullName, ct); - - String fullNameWithThis = fullName + "#this"; - //String fullNameWithThis = "this"; - XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); - XRoot thisVar = XTerms.makeLocal(thisName); - - final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); - PLACE.setResolver(new Runnable() { - public void run() { - PLACE.update((X10ParsedClassType) xts.Place()); - } - }); - final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); - STRING.setResolver(new Runnable() { - public void run() { - STRING.update((X10ParsedClassType) xts.String()); - } - }); - final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); - BOOLEAN.setResolver(new Runnable() { - public void run() { - BOOLEAN.update((X10ParsedClassType) xts.Boolean()); - } - }); - final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); - OBJECT.setResolver(new Runnable() { - public void run() { - OBJECT.update((X10ParsedClassType) xts.Object()); - } - }); - - - X10MethodDef mi; - List<Expr> list; - X10ClassType ann; - - // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") - // property def loc():Place - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property().Global(), PLACE, - Name.make("loc"), - Collections.EMPTY_LIST, - Collections.EMPTY_LIST, - thisVar, - Collections.EMPTY_LIST, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); - NATIVE_LOC.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_LOC.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1)") - // property def at(p:Object):boolean; - List<LocalDef> parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(OBJECT), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - - final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); - NATIVE_AT_1.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_AT_1.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); - cd.addMethod(mi); - - // @Native("java", "x10.core.Ref.at(#0, #1.id)") - // property def at(p:Place):boolean; - parameters = dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); - mi = methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, - Name.make("at"), - Collections.EMPTY_LIST, - Collections.<Ref<? extends Type>> singletonList(PLACE), - thisVar, - parameters, - null, - null, - Collections.EMPTY_LIST, - null); - final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); - NATIVE_AT_2.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(2); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); - X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) NativeType()).propertyInitializers(list); - NATIVE_AT_2.update(ann); - } - }); - mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); - cd.addMethod(mi); - - //@NativeRep("java", "x10.core.Any", null, null) - final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); - NATIVE_REP.setResolver(new Runnable() { - public void run() { - List<Expr> list = new ArrayList<Expr>(4); - list.add(new X10StringLit_c(pos, "java")); - list.add(new X10StringLit_c(pos, "x10.core.Any")); - list.add(null); - list.add(null); - X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); - - NATIVE_REP.update(ann); - } - }); - - cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); - return cd; - } + public List<LocalDef> dummyLocalDefs(List<Ref<? extends Type>> types) { List<LocalDef> list = new ArrayList<LocalDef>(); for (int i = 0; i < types.size(); i++) { @@ -1826,14 +1459,14 @@ public Type Any() { if (ANY_ != null) return ANY_; - return ANY_ = AnyDef().asType(); + return ANY_ = x10.util.Any.makeDef(this).asType(); } Type STRUCT_ = null; public Type Struct() { if (STRUCT_ != null) return STRUCT_; - return STRUCT_ = StructDef().asType(); + return STRUCT_ = x10.util.Struct.makeDef(this).asType(); } public Type String() { if (STRING_ != null) Added: trunk/x10.compiler/src/x10/util/Any.java =================================================================== --- trunk/x10.compiler/src/x10/util/Any.java (rev 0) +++ trunk/x10.compiler/src/x10/util/Any.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -0,0 +1,212 @@ +package x10.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.LazyRef; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.Ref; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Position; +import x10.ast.X10StringLit_c; +import x10.constraint.XName; +import x10.constraint.XNameWrapper; +import x10.constraint.XRoot; +import x10.constraint.XTerms; +import x10.types.X10ClassDef; +import x10.types.X10ClassDef_c; +import x10.types.X10ClassType; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10ParsedClassType; +import x10.types.X10ParsedClassType_c; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +public class Any { + + public static X10ClassDef makeDef(final X10TypeSystem_c xts) { + + final Position pos = Position.COMPILER_GENERATED; + + + String name = "Any"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + cd.position(pos); + // interface Any .... + cd.name(Name.make(name)); + // package x10.lang; + try { + cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); + } + catch (SemanticException e) { + assert false; + } + QName fullName = QName.make("x10.lang", name); + + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // interfaces have no superclass + // Functions implement the Any interface. + //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract().Interface())); + + // NOTE: don't call cd.asType() until after the type parameters are + // added. + X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); + xts.systemResolver().install(fullName, ct); + + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); + + final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); + PLACE.setResolver(new Runnable() { + public void run() { + PLACE.update((X10ParsedClassType) xts.Place()); + } + }); + final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); + STRING.setResolver(new Runnable() { + public void run() { + STRING.update((X10ParsedClassType) xts.String()); + } + }); + final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); + BOOLEAN.setResolver(new Runnable() { + public void run() { + BOOLEAN.update((X10ParsedClassType) xts.Boolean()); + } + }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + + + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; + + // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") + // property def loc():Place + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property().Global(), PLACE, + Name.make("loc"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; + List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; + parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); + cd.addMethod(mi); + + //@NativeRep("java", "x10.core.Any", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Any")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); + return cd; + } +} Added: trunk/x10.compiler/src/x10/util/Struct.java =================================================================== --- trunk/x10.compiler/src/x10/util/Struct.java (rev 0) +++ trunk/x10.compiler/src/x10/util/Struct.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -0,0 +1,267 @@ +package x10.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.MethodDecl; +import polyglot.ast.TypeNode; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.LazyRef; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.Ref; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Position; +import x10.ast.AnnotationNode; +import x10.ast.X10StringLit_c; +import x10.constraint.XName; +import x10.constraint.XNameWrapper; +import x10.constraint.XRoot; +import x10.constraint.XTerms; +import x10.extension.X10Ext; +import x10.types.X10ClassDef; +import x10.types.X10ClassDef_c; +import x10.types.X10ClassType; +import x10.types.X10ConstructorDef; +import x10.types.X10Flags; +import x10.types.X10MethodDef; +import x10.types.X10ParsedClassType; +import x10.types.X10ParsedClassType_c; +import x10.types.X10TypeSystem; +import x10.types.X10TypeSystem_c; + +public class Struct { + public static X10ClassDef makeDef(final X10TypeSystem_c xts) { + + final Position pos = Position.COMPILER_GENERATED; + + String name = "Struct"; + X10ClassDef cd = (X10ClassDef) new X10ClassDef_c(xts, null) { + + @Override + public ClassType asType() { + if (asType == null) { + X10ClassDef cd = this; + asType = new X10ParsedClassType_c(this); + } + return asType; + } + }; + + cd.position(pos); + cd.name(Name.make(name)); + try { + cd.setPackage(Types.ref(xts.packageForName(QName.make("x10.lang")))); + } + catch (SemanticException e) { + assert false; + } + + QName fullName = QName.make("x10.lang", name); + cd.kind(ClassDef.TOP_LEVEL); + cd.superType(null); // base class has no superclass + // Functions implement the Any interface. + //cd.setInterfaces(Collections.<Ref<? extends Type>> singletonList(Types.ref(Any()))); + cd.flags(X10Flags.toX10Flags(Flags.PUBLIC.Abstract()).Struct()); + + + // NOTE: don't call cd.asType() until after the type parameters are + // added. + X10ParsedClassType ct = (X10ParsedClassType) cd.asType(); + xts.systemResolver().install(fullName, ct); + + String fullNameWithThis = fullName + "#this"; + //String fullNameWithThis = "this"; + XName thisName = new XNameWrapper<Object>(new Object(), fullNameWithThis); + XRoot thisVar = XTerms.makeLocal(thisName); + + final LazyRef<X10ParsedClassType> PLACE = Types.lazyRef(null); + PLACE.setResolver(new Runnable() { + public void run() { + PLACE.update((X10ParsedClassType) xts.Place()); + } + }); + final LazyRef<X10ParsedClassType> STRING = Types.lazyRef(null); + STRING.setResolver(new Runnable() { + public void run() { + STRING.update((X10ParsedClassType) xts.String()); + } + }); + final LazyRef<X10ParsedClassType> BOOLEAN = Types.lazyRef(null); + BOOLEAN.setResolver(new Runnable() { + public void run() { + BOOLEAN.update((X10ParsedClassType) xts.Boolean()); + } + }); + final LazyRef<X10ParsedClassType> OBJECT = Types.lazyRef(null); + OBJECT.setResolver(new Runnable() { + public void run() { + OBJECT.update((X10ParsedClassType) xts.Object()); + } + }); + X10ConstructorDef ci = (X10ConstructorDef) xts.constructorDef(pos, Types.ref(ct), Flags.PUBLIC.Native(), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST); + cd.addConstructor(ci); + + X10MethodDef mi; + List<Expr> list; + X10ClassType ann; + + // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") + // property def loc():Place + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global(), PLACE, + Name.make("loc"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_LOC = Types.lazyRef(null); + NATIVE_LOC.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.lang.Place.place(x10.core.Ref.location(#0))")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_LOC.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_LOC)); + cd.addMethod(mi); + + // @Native("java", "x10.core.Ref.at(#0, #1)") + // property def at(p:Object):boolean; + List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(OBJECT), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_1 = Types.lazyRef(null); + NATIVE_AT_1.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1.id)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_1.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_1)); + cd.addMethod(mi); + + mi = xts.methodDef(pos, + Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global(), + STRING, + Name.make("typeName"), + Collections.EMPTY_LIST, + Collections.EMPTY_LIST, + thisVar, + Collections.EMPTY_LIST, + null, + null, + Collections.EMPTY_LIST, + null + ); + final LazyRef<X10ParsedClassType> NATIVE_TYPE_NAME = Types.lazyRef(null); + NATIVE_TYPE_NAME.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.typeName(#0)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_TYPE_NAME.update(ann); + } + }); + + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_TYPE_NAME)); + cd.addMethod(mi); + + + + // @Native("java", "x10.core.Ref.at(#0, #1.id)") + // property def at(p:Place):boolean; + parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); + mi = xts.methodDef(pos, Types.ref(ct), + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + Name.make("at"), + Collections.EMPTY_LIST, + Collections.<Ref<? extends Type>> singletonList(PLACE), + thisVar, + parameters, + null, + null, + Collections.EMPTY_LIST, + null); + final LazyRef<X10ParsedClassType> NATIVE_AT_2 = Types.lazyRef(null); + NATIVE_AT_2.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(2); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Ref.at(#0, #1)")); + X10ParsedClassType ann= (X10ParsedClassType) ((X10ParsedClassType) xts.NativeType()).propertyInitializers(list); + NATIVE_AT_2.update(ann); + } + }); + mi.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_AT_2)); + cd.addMethod(mi); + + //@NativeRep("java", "x10.core.Struct", null, null) + final LazyRef<X10ParsedClassType> NATIVE_REP = Types.lazyRef(null); + NATIVE_REP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "java")); + list.add(new X10StringLit_c(pos, "x10.core.Struct")); + list.add(null); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP.update(ann); + } + }); + + + //@NativeRep("c++", "x10::lang::Struct", "x10::lang::Struct", null) + final LazyRef<X10ParsedClassType> NATIVE_REP_CPP = Types.lazyRef(null); + NATIVE_REP_CPP.setResolver(new Runnable() { + public void run() { + List<Expr> list = new ArrayList<Expr>(4); + list.add(new X10StringLit_c(pos, "c++")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(new X10StringLit_c(pos, "x10::lang::Struct")); + list.add(null); + X10ParsedClassType ann = (X10ParsedClassType) ((X10ParsedClassType) xts.NativeRep()).propertyInitializers(list); + + NATIVE_REP_CPP.update(ann); + } + }); + + List<Ref<? extends Type>> cd_ann = new ArrayList<Ref<? extends Type>>(); + cd_ann.add(NATIVE_REP); + cd_ann.add(NATIVE_REP_CPP); + cd.setDefAnnotations(cd_ann); +// cd.setDefAnnotations(Collections.<Ref<? extends Type>> singletonList(NATIVE_REP)); + return cd; + } + +} Modified: trunk/x10.runtime/src-java/x10/core/Ref.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Ref.java 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.runtime/src-java/x10/core/Ref.java 2009-11-04 00:39:30 UTC (rev 11910) @@ -92,4 +92,7 @@ return Thread.currentThread().location(); } } + public static String typeName(Object obj) { + return obj.getClass().toString(); + } } Modified: trunk/x10.runtime/src-x10/x10/lang/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -335,6 +335,7 @@ public global operator this && (d: Dist(rank)): Dist(rank) = intersection(d); public global operator this || (d: Dist(rank)): Dist(rank) = union(d); public global operator this - (d: Dist(rank)): Dist(rank) = difference(d); + public global operator this - (r: Region(rank)): Dist(rank) = difference(r); // Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -54,5 +54,10 @@ @Native("java", "x10.core.Ref.at(#0, #1)") @Native("c++", "((#0)->location == (#1)->location)") public property def at(r:Object) = location==r.location; + + @Native("java", "x10.core.Ref.typeName(#0)") + public native global final def typeName():String; + + } Modified: trunk/x10.tests/examples/Constructs/Distribution/PolyDistAlgebra1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Distribution/PolyDistAlgebra1.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.tests/examples/Constructs/Distribution/PolyDistAlgebra1.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -17,7 +17,7 @@ //Check range restriction to a place for (var k: int = 0; k<Place.MAX_PLACES; k++) { var p: Place = Place.place(k); - var dp: Dist(2) = d.$bar(p); + var dp: Dist(2) = d | p; prDist(name + "|" + s(p), dp); } } @@ -33,16 +33,16 @@ val r3 = r(0,7,4,5); prArray("r3", r3); - val r12 = r1.$or(r2); + val r12 = r1 || (r2); pr("r12" + r12); - val r12a3 = r12.$and(r3); + val r12a3 = r12 && (r3); pr("r12a3" + r12a3); - val r123 = r1.$or(r2).$or(r3); + val r123 = r1 || (r2) || (r3); pr("r123" + r123); - val r12m3 = r12.$minus(r3); + val r12m3 = r12 - (r3); pr("r12m3" + r12m3); val d123x0 = Dist.makeCyclic(r123, 0); @@ -55,16 +55,16 @@ // dist op region // - val d123x0r12a3 = d123x0.$bar(r12a3); + val d123x0r12a3 = d123x0 - (r12a3); prDist("d123x0r12a3", d123x0r12a3); - val d123x1r12a3 = d123x1.$bar(r12a3); + val d123x1r12a3 = d123x1 - (r12a3); prDist("d123x1r12a3", d123x1r12a3); - val d123x0r12m3 = d123x0.$bar(r12m3); + val d123x0r12m3 = d123x0 | (r12m3); prDist("d123x0r12m3", d123x0r12m3); - val d123x1r12m3 = d123x1.$bar(r12m3); + val d123x1r12m3 = d123x1 | (r12m3); prDist("d123x1r12m3", d123x1r12m3); @@ -72,15 +72,15 @@ // dist - dist // - val d1 = d123x0.$minus(d123x0r12m3); + val d1 = d123x0 - (d123x0r12m3); prDist("d1 = d123x0 - d123x0r12m3", d1); - val d3 = d123x0.$bar(r3); + val d3 = d123x0 | (r3); prDist("d3 = d123x0 | r3", d3); pr("d1.equals(d3) checks " + d1.equals(d3)); pr("d1.isSubdistribution(d123x0) checks " + d1.isSubdistribution(d123x0)); pr("!d123x0.isSubdistribution(d1) checks " + !d123x0.isSubdistribution(d1)); - val d1x = d123x0.$minus(d123x1r12m3); + val d1x = d123x0 - (d123x1r12m3); prDist("d1x = d123x0 - d123x1r12m3", d1x); pr("d1x.isSubdistribution(d123x0) checks " + d1x.isSubdistribution(d123x0)); pr("!d123x0.isSubdistribution(d1x) checks " + !d123x0.isSubdistribution(d1x)); @@ -90,11 +90,11 @@ // dist && dist // - val d2 = d123x0r12m3.$and(d123x0); + val d2 = d123x0r12m3 && (d123x0); prDist("d2 = d123x0r12m3 && d123x0", d2); pr("d2.equals(d123x0r12m3) checks " + d2.equals(d123x0r12m3)); - val d2x = d123x0r12m3.$and(d123x1); + val d2x = d123x0r12m3 && (d123x1); prDist("d2x = d123x0r12m3 && d123x1", d2x); @@ -102,14 +102,14 @@ // dist overlay dist // - val d5 = d123x0.$bar(r12); + val d5 = d123x0 | (r12); prDist("d5 = d123x0 | r12", d5); val d4 = d5.overlay(d3); prDist("d4 = d5.overlay(d3)", d4); pr("d4.equals(d123x0) checks " + d4.equals(d123x0)); - val d5x = d123x1.$bar(r12); + val d5x = d123x1 | (r12); prDist("d5x = d123x1 | r12", d5); val d4x = d5x.overlay(d3); prDist("d4x = d5x.overlay(d3)", d4x); @@ -119,17 +119,17 @@ // dist union dist // - val d6 = d123x0r12a3.$or(d123x0r12m3); + val d6 = d123x0r12a3 || (d123x0r12m3); prDist("d6 = d123x0r12a3 || d123x0r12m3", d6); pr("d6.equals(d5) checks " + d6.equals(d5)); - new E("d6x = d123x0 || d123x1") { + /* new E("d6x = d123x0 || d123x1") { def run(): void = { val d6x = d123x0.$or(d123x1); prDist("d6x = d123x0 || d123x1", d6x); } - }; + };*/ return status(); } Modified: trunk/x10.tests/examples/Constructs/Instanceof/X10InterfaceOne.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Instanceof/X10InterfaceOne.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.tests/examples/Constructs/Instanceof/X10InterfaceOne.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -9,5 +9,5 @@ public interface X10InterfaceOne { - public public def interfaceMethod(): void; + def interfaceMethod(): void; } Modified: trunk/x10.tests/examples/Constructs/PlaceCast/PlaceCast.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/PlaceCast/PlaceCast.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.tests/examples/Constructs/PlaceCast/PlaceCast.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -15,17 +15,18 @@ public def run(): boolean = { val d: Dist = Dist.makeUnique(Place.places); x10.io.Console.OUT.println("num places = " + Place.MAX_PLACES); - val disagree: Array[BoxedBoolean]{distribution==d} = new Array[BoxedBoolean](d, ((p): Point): BoxedBoolean => { + val disagree: Array[BoxedBoolean]{dist==d} + = Array.makeVar[BoxedBoolean](d, ((p): Point): BoxedBoolean => { x10.io.Console.OUT.println("The currentplace is:" + here); return new BoxedBoolean(); }); - finish ateach (val (p): Point in d) { + finish ateach ((p) in d) { // remember if here and d[p] disagree // at any activity at any place try { val q: Place = d(p).next(); var x: BoxedBoolean = disagree(p) as (BoxedBoolean!q); - async(this.location) { atomic { nplaces++; } } + at (this) { atomic { nplaces++; } } } catch (var x: BadPlaceException) { x10.io.Console.OUT.println("Caught bad place exception for " + p); } Deleted: trunk/x10.tests/examples/Issues/XTENLANG_298.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_298.x10 2009-11-03 18:48:24 UTC (rev 11909) +++ trunk/x10.tests/examples/Issues/XTENLANG_298.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -1,28 +0,0 @@ -// (C) Copyright IBM Corporation 2008 -// This file is part of X10 Test. * - -import harness.x10Test; - -/** - * @author bdlucas 12/2008 - */ - -class XTENLANG_298 extends x10Test { - - - static class C(p:int) { - val q = p; - def this(p:int) = property(p); - } - - public def run(): boolean { - val c = new C(1); - x10.io.Console.OUT.println("c.p " + c.p); - x10.io.Console.OUT.println("c.q " + c.q); - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_298().execute(); - } -} Added: trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_298_MustFailCompile.x10 2009-11-04 00:39:30 UTC (rev 11910) @@ -0,0 +1,32 @@ +// (C) Copyright IBM Corporation 2008 +// This file is part of X10 Test. * + +import harness.x10Test; + +/** + * @author bdlucas 12/2008 + */ + +class XTENLANG_298_MustFailCompile extends x10Test { + + + static class C(p:int) { + // The field declaration must fail compilation because p will not be + // initialized at this access. + val q=p; + def this(p:int) { + property(p); + } + } + + public def run(): boolean { + val c = new C(1); + x10.io.Console.OUT.println("c.p " + c.p); + x10.io.Console.OUT.println("c.q " + c.q); + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_298().execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-04 11:55:17
|
Revision: 11913 http://x10.svn.sourceforge.net/x10/?rev=11913&view=rev Author: vj0 Date: 2009-11-04 11:55:08 +0000 (Wed, 04 Nov 2009) Log Message: ----------- Fixed XTENLANG-407. The following now compiles: public class TestRegionRail { val R:Region{rail} = 0..10; } Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/RegionMaker_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.runtime/src-x10/x10/lang/Region.x10 Modified: trunk/x10.compiler/src/x10/ast/RegionMaker_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/RegionMaker_c.java 2009-11-04 03:45:51 UTC (rev 11912) +++ trunk/x10.compiler/src/x10/ast/RegionMaker_c.java 2009-11-04 11:55:08 UTC (rev 11913) @@ -20,7 +20,11 @@ import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.util.Position; +import polyglot.visit.ContextVisitor; import polyglot.visit.TypeChecker; +import x10.constraint.XTerms; +import x10.constraint.XVar; +import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; /** @@ -40,27 +44,20 @@ super(pos, target, name, Collections.EMPTY_LIST, arguments); } - public Node typeCheck(TypeChecker tc) throws SemanticException { - return super.typeCheck(tc); + public Node typeCheck(ContextVisitor tc) throws SemanticException { + X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); + RegionMaker_c n = (RegionMaker_c) super.typeCheck(tc); + Expr left = (Expr) n.arguments.get(0); + Type type = n.type(); + Type lType = left.type(); + if (X10TypeMixin.entails(lType, X10TypeMixin.self(lType), xts.ZERO())) { + XVar self = X10TypeMixin.self(type); + type = X10TypeMixin.addTerm(type, X10TypeMixin.makeZeroBased(type)); + n= (RegionMaker_c) n.type(type); + } + + return n; + } -// -// public node typecheck(typechecker tc) throws semanticexception { -// x10typesystem xts = (x10typesystem) tc.typesystem(); -// regionmaker_c n = (regionmaker_c) super.typecheck(tc); -// expr left = (expr) n.arguments.get(0); -// -// type type = n.type(); -// type = x10arraysmixin.setrank(type, xts.one()); -// type = x10arraysmixin.setrect(type); -// // vj: also may wish to check for the type being int(:self==0). -// object leftval = left.constantvalue(); -// if ((leftval instanceof integer && ((integer) leftval).intvalue()==0)) { -// type = x10arraysmixin.setzerobased(type); -// } -// -// regionmaker result = (regionmaker) n.type(type); -// //report.report(1, "regionmaker_c: type of |" + result + "| is " + result.type()); -// return result; -// } } Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2009-11-04 03:45:51 UTC (rev 11912) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2009-11-04 11:55:08 UTC (rev 11913) @@ -626,7 +626,19 @@ } } } + + public static boolean entails(Type t, XTerm t1, XTerm t2) { + try { + XConstraint c = realX(t); + if (c==null) + c = new XConstraint_c(); + return c.entails(t1, t2); + } catch (XFailure z) { + return false; + } + } + protected static boolean amIProperty(Type t, Name propName, X10Context context) { X10TypeSystem xts = (X10TypeSystem) t.typeSystem(); XConstraint r = realX(t); @@ -685,7 +697,32 @@ public static XTerm region(Type t) { return findProperty(t, Name.make("region")); } - + public static XTerm zeroBased(Type t) { + return findProperty(t, Name.make("zeroBased")); + } + public static XTerm makeZeroBased(Type t) { + return makeProperty(t, "zeroBased"); + } + + public static XTerm makeProperty(Type t, String propStr) { + Name propName = Name.make(propStr); + XConstraint c = realX(t); + if (c != null) { + // build the synthetic term. + XTerm var = selfVar(c); + if (var !=null) { + X10FieldInstance fi = getProperty(t, propName); + if (fi != null) { + + X10TypeSystem xts = (X10TypeSystem) t.typeSystem(); + XTerm val = xts.xtypeTranslator().trans(c, var, fi); + return val; + } + } + } + return null; + + } public static XTerm find(Type t, Name propName) { XTerm val = findProperty(t, propName); Modified: trunk/x10.runtime/src-x10/x10/lang/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Region.x10 2009-11-04 03:45:51 UTC (rev 11912) +++ trunk/x10.runtime/src-x10/x10/lang/Region.x10 2009-11-04 11:55:08 UTC (rev 11913) @@ -79,7 +79,9 @@ */ // XTENLANG-109 prevents zeroBased==(min==0) - public static def makeRectangular(min: int, max: int): Region{self.rank==1 && /*self.zeroBased==(min==0) &&*/ self.rect} + // Changed RegionMaker_c to add clause explicitly. + public static def makeRectangular(min: int, max: int) + : Region{self.rank==1 && /*self.zeroBased==(min==0) &&*/ self.rect} = BaseRegion.makeRectangular1(min, max); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-04 13:22:28
|
Revision: 11915 http://x10.svn.sourceforge.net/x10/?rev=11915&view=rev Author: vj0 Date: 2009-11-04 13:22:16 +0000 (Wed, 04 Nov 2009) Log Message: ----------- Redefine the leastCommonAncestor of two types to also take the leastUpperBound of the associated constraints. Fixes XTENLANG-550. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XConstraint_c.java Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-04 13:13:12 UTC (rev 11914) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-04 13:22:16 UTC (rev 11915) @@ -1429,6 +1429,20 @@ public Type leastCommonAncestor(Type type1, Type type2) throws SemanticException { + Type t = leastCommonAncestorBase(X10TypeMixin.baseType(type1), + X10TypeMixin.baseType(type2)); + + XConstraint c1 = X10TypeMixin.realX(type1), c2 = X10TypeMixin.realX(type2); + XConstraint c = c1.leastUpperBound(c2); + if (! c.valid()) + t = X10TypeMixin.addConstraint(t, c); + return t; + + } + + public Type leastCommonAncestorBase(Type type1, Type type2) + throws SemanticException + { try { if (typeEquals(type1, type2)) { return type1; Modified: trunk/x10.constraints/src/x10/constraint/XConstraint.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XConstraint.java 2009-11-04 13:13:12 UTC (rev 11914) +++ trunk/x10.constraints/src/x10/constraint/XConstraint.java 2009-11-04 13:22:16 UTC (rev 11915) @@ -316,4 +316,12 @@ */ XConstraint instantiateSelf(XTerm newSelf); + /** + * Return the least upper bound of this and other. That is, the resulting constraint has precisely + * the constraints entailed by both this and other. + * @param other + * @return + */ + XConstraint leastUpperBound(XConstraint other); + } Modified: trunk/x10.constraints/src/x10/constraint/XConstraint_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XConstraint_c.java 2009-11-04 13:13:12 UTC (rev 11914) +++ trunk/x10.constraints/src/x10/constraint/XConstraint_c.java 2009-11-04 13:22:16 UTC (rev 11915) @@ -537,24 +537,21 @@ return true; } - List<XTerm> subst = new ArrayList<XTerm>(conjuncts.size()); - for (XTerm term : conjuncts) { - XTerm t = term.subst(me.self(), self); - subst.add(t); - } -// Set<XTerm> visited = new HashSet<XTerm>(); -// for (XTerm term : subst) { -// term.saturate(me, visited); -// } -// visited = null; // free up for gc - for (XTerm term : subst) { - if (! me.entails(term, (XConstraint) null)) + for (XTerm term : conjuncts) { + if (! me.entails(term, self, (XConstraint) null)) return false; } return true; } + private boolean entails(XTerm term, XRoot self, final XConstraint sigma) throws XFailure { + XTerm subst = term.subst(self(), self); + return entails(subst, (XConstraint) null); + } + + + /** Traverse the terms in the constraint, adding in their self constraints. */ // public XConstraint_c saturate() throws XFailure { // XConstraint_c c = (XConstraint_c) copy(); @@ -1140,5 +1137,23 @@ XEQV result = new XEQV_c(name, hidden); return result; } + public XConstraint leastUpperBound(XConstraint other) { + XRoot otherSelf = other.self(); + + XConstraint result = new XConstraint_c(); + XRoot resultSelf = result.self(); + XConstraint sigma = new XConstraint_c(); + for (XTerm term : other.constraints()) { + try { + if (entails(term, otherSelf, sigma)) { + term = term.subst(resultSelf, otherSelf); + result.addTerm(term); + } + } catch (XFailure z) { + } + } + return result; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-09 14:10:06
|
Revision: 11964 http://x10.svn.sourceforge.net/x10/?rev=11964&view=rev Author: vj0 Date: 2009-11-09 14:09:55 +0000 (Mon, 09 Nov 2009) Log Message: ----------- Fix bugs with the implementation of T!q types. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/util/Any.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-x10/x10/lang/Object.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-11-09 13:40:57 UTC (rev 11963) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2009-11-09 14:09:55 UTC (rev 11964) @@ -488,14 +488,9 @@ try { if (name == Name.make("equals") && argTypes.size() == 1 && typeArgs.size() == 0 && xts.isParameterType(targetType) && xts.isParameterType(argTypes.get(0))) { - // Check that both equals(Ref) and equals(Value) are present + mi = (X10MethodInstance) xts.findMethod(targetType, xts.MethodMatcher(targetType, name, typeArgs, Collections.singletonList(xts.Object()), c)); - //mi = null; - /* - mi = (X10MethodInstance) xts.findMethod(targetType, - xts.MethodMatcher(targetType, name, typeArgs, Collections.singletonList(xts.Value()), c)); - */ mi = (X10MethodInstance) mi.formalTypes(Collections.singletonList(X10TypeMixin.baseType(targetType))); LocalInstance d = mi.formalNames().get(0); mi = (X10MethodInstance) mi.formalNames(Collections.singletonList(d.type(X10TypeMixin.baseType(targetType)))); Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-11-09 13:40:57 UTC (rev 11963) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2009-11-09 14:09:55 UTC (rev 11964) @@ -1939,20 +1939,6 @@ } // - // Rule 56: PlaceType ::= PlaceExpression - // - case 56: { - //#line 1288 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1286 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - Expr PlaceExpression = (Expr) getRhsSym(1); - //#line 1288 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(nf.Binary(pos(), - nf.Field(pos(), nf.This(pos()), nf.Id(pos(), "loc")), Binary.EQ, - PlaceExpression)); - break; - } - - // // Rule 57: NamedType ::= Primary . Identifier TypeArgumentsopt Argumentsopt DepParametersopt // case 57: { @@ -3218,23 +3204,9 @@ } // - // Rule 186: CastExpression ::= ConditionalExpression ! Expression + // Rule 187: TypeParamWithVarianceList ::= TypeParamWithVariance // - case 186: { - //#line 1995 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1993 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - Expr ConditionalExpression = (Expr) getRhsSym(1); - //#line 1993 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(3); - //#line 1995 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(nf.PlaceCast(pos(), Expression, ConditionalExpression)); - break; - } - - // - // Rule 188: TypeParamWithVarianceList ::= TypeParamWithVariance - // - case 188: { + case 187: { //#line 2004 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2002 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeParamNode TypeParamWithVariance = (TypeParamNode) getRhsSym(1); @@ -3246,9 +3218,9 @@ } // - // Rule 189: TypeParamWithVarianceList ::= TypeParamWithVarianceList , TypeParamWithVariance + // Rule 188: TypeParamWithVarianceList ::= TypeParamWithVarianceList , TypeParamWithVariance // - case 189: { + case 188: { //#line 2011 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2009 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParamWithVarianceList = (List) getRhsSym(1); @@ -3261,9 +3233,9 @@ } // - // Rule 190: TypeParameterList ::= TypeParameter + // Rule 189: TypeParameterList ::= TypeParameter // - case 190: { + case 189: { //#line 2018 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2016 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeParamNode TypeParameter = (TypeParamNode) getRhsSym(1); @@ -3275,9 +3247,9 @@ } // - // Rule 191: TypeParameterList ::= TypeParameterList , TypeParameter + // Rule 190: TypeParameterList ::= TypeParameterList , TypeParameter // - case 191: { + case 190: { //#line 2025 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2023 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeParameterList = (List) getRhsSym(1); @@ -3290,9 +3262,9 @@ } // - // Rule 192: TypeParamWithVariance ::= Identifier + // Rule 191: TypeParamWithVariance ::= Identifier // - case 192: { + case 191: { //#line 2032 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2030 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3302,9 +3274,9 @@ } // - // Rule 193: TypeParamWithVariance ::= + Identifier + // Rule 192: TypeParamWithVariance ::= + Identifier // - case 193: { + case 192: { //#line 2037 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2035 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); @@ -3314,9 +3286,9 @@ } // - // Rule 194: TypeParamWithVariance ::= - Identifier + // Rule 193: TypeParamWithVariance ::= - Identifier // - case 194: { + case 193: { //#line 2042 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2040 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); @@ -3326,9 +3298,9 @@ } // - // Rule 195: TypeParameter ::= Identifier + // Rule 194: TypeParameter ::= Identifier // - case 195: { + case 194: { //#line 2048 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2046 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3338,9 +3310,9 @@ } // - // Rule 196: Primary ::= here + // Rule 195: Primary ::= here // - case 196: { + case 195: { //#line 2054 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2054 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3349,9 +3321,9 @@ } // - // Rule 198: RegionExpressionList ::= RegionExpression + // Rule 197: RegionExpressionList ::= RegionExpression // - case 198: { + case 197: { //#line 2062 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2060 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr RegionExpression = (Expr) getRhsSym(1); @@ -3363,9 +3335,9 @@ } // - // Rule 199: RegionExpressionList ::= RegionExpressionList , RegionExpression + // Rule 198: RegionExpressionList ::= RegionExpressionList , RegionExpression // - case 199: { + case 198: { //#line 2069 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2067 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List RegionExpressionList = (List) getRhsSym(1); @@ -3378,9 +3350,9 @@ } // - // Rule 200: Primary ::= [ ArgumentListopt ] + // Rule 199: Primary ::= [ ArgumentListopt ] // - case 200: { + case 199: { //#line 2076 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2074 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ArgumentListopt = (List) getRhsSym(2); @@ -3391,9 +3363,9 @@ } // - // Rule 201: AssignmentExpression ::= Expression$expr1 -> Expression$expr2 + // Rule 200: AssignmentExpression ::= Expression$expr1 -> Expression$expr2 // - case 201: { + case 200: { //#line 2083 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2081 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr expr1 = (Expr) getRhsSym(1); @@ -3406,9 +3378,9 @@ } // - // Rule 202: ClosureExpression ::= FormalParameters WhereClauseopt ResultTypeopt Throwsopt => ClosureBody + // Rule 201: ClosureExpression ::= FormalParameters WhereClauseopt ResultTypeopt Throwsopt => ClosureBody // - case 202: { + case 201: { //#line 2089 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2087 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameters = (List) getRhsSym(1); @@ -3427,9 +3399,9 @@ } // - // Rule 203: LastExpression ::= Expression + // Rule 202: LastExpression ::= Expression // - case 203: { + case 202: { //#line 2096 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2094 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(1); @@ -3439,9 +3411,9 @@ } // - // Rule 204: ClosureBody ::= CastExpression + // Rule 203: ClosureBody ::= CastExpression // - case 204: { + case 203: { //#line 2102 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2100 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr CastExpression = (Expr) getRhsSym(1); @@ -3451,9 +3423,9 @@ } // - // Rule 205: ClosureBody ::= Annotationsopt { BlockStatementsopt LastExpression } + // Rule 204: ClosureBody ::= Annotationsopt { BlockStatementsopt LastExpression } // - case 205: { + case 204: { //#line 2107 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2105 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Annotationsopt = (List) getRhsSym(1); @@ -3472,9 +3444,9 @@ } // - // Rule 206: ClosureBody ::= Annotationsopt Block + // Rule 205: ClosureBody ::= Annotationsopt Block // - case 206: { + case 205: { //#line 2117 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2115 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Annotationsopt = (List) getRhsSym(1); @@ -3488,9 +3460,9 @@ } // - // Rule 207: AtExpression ::= at PlaceExpressionSingleList ClosureBody + // Rule 206: AtExpression ::= at PlaceExpressionSingleList ClosureBody // - case 207: { + case 206: { //#line 2126 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2124 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceExpressionSingleList = (Expr) getRhsSym(2); @@ -3502,9 +3474,9 @@ } // - // Rule 208: AsyncExpression ::= async ClosureBody + // Rule 207: AsyncExpression ::= async ClosureBody // - case 208: { + case 207: { //#line 2132 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2130 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Block ClosureBody = (Block) getRhsSym(2); @@ -3514,9 +3486,9 @@ } // - // Rule 209: AsyncExpression ::= async PlaceExpressionSingleList ClosureBody + // Rule 208: AsyncExpression ::= async PlaceExpressionSingleList ClosureBody // - case 209: { + case 208: { //#line 2137 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2135 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceExpressionSingleList = (Expr) getRhsSym(2); @@ -3528,9 +3500,9 @@ } // - // Rule 210: AsyncExpression ::= async [ Type ] ClosureBody + // Rule 209: AsyncExpression ::= async [ Type ] ClosureBody // - case 210: { + case 209: { //#line 2142 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2140 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(3); @@ -3542,9 +3514,9 @@ } // - // Rule 211: AsyncExpression ::= async [ Type ] PlaceExpressionSingleList ClosureBody + // Rule 210: AsyncExpression ::= async [ Type ] PlaceExpressionSingleList ClosureBody // - case 211: { + case 210: { //#line 2147 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2145 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(3); @@ -3558,9 +3530,9 @@ } // - // Rule 212: FutureExpression ::= future ClosureBody + // Rule 211: FutureExpression ::= future ClosureBody // - case 212: { + case 211: { //#line 2153 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2151 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Block ClosureBody = (Block) getRhsSym(2); @@ -3570,9 +3542,9 @@ } // - // Rule 213: FutureExpression ::= future PlaceExpressionSingleList ClosureBody + // Rule 212: FutureExpression ::= future PlaceExpressionSingleList ClosureBody // - case 213: { + case 212: { //#line 2158 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2156 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Expr PlaceExpressionSingleList = (Expr) getRhsSym(2); @@ -3584,9 +3556,9 @@ } // - // Rule 214: FutureExpression ::= future [ Type ] ClosureBody + // Rule 213: FutureExpression ::= future [ Type ] ClosureBody // - case 214: { + case 213: { //#line 2163 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2161 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(3); @@ -3598,9 +3570,9 @@ } // - // Rule 215: FutureExpression ::= future [ Type ] PlaceExpressionSingleList ClosureBody + // Rule 214: FutureExpression ::= future [ Type ] PlaceExpressionSingleList ClosureBody // - case 215: { + case 214: { //#line 2168 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2166 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(3); @@ -3614,16 +3586,16 @@ } // - // Rule 216: DepParametersopt ::= $Empty + // Rule 215: DepParametersopt ::= $Empty // - case 216: + case 215: setResult(null); break; // - // Rule 218: PropertyListopt ::= $Empty + // Rule 217: PropertyListopt ::= $Empty // - case 218: { + case 217: { //#line 2179 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2179 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3632,23 +3604,23 @@ } // - // Rule 220: WhereClauseopt ::= $Empty + // Rule 219: WhereClauseopt ::= $Empty // - case 220: + case 219: setResult(null); break; // - // Rule 222: PlaceExpressionSingleListopt ::= $Empty + // Rule 221: PlaceExpressionSingleListopt ::= $Empty // - case 222: + case 221: setResult(null); break; // - // Rule 224: ClassModifiersopt ::= $Empty + // Rule 223: ClassModifiersopt ::= $Empty // - case 224: { + case 223: { //#line 2194 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2194 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3656,9 +3628,9 @@ break; } // - // Rule 226: TypeDefModifiersopt ::= $Empty + // Rule 225: TypeDefModifiersopt ::= $Empty // - case 226: { + case 225: { //#line 2200 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2200 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3666,16 +3638,16 @@ break; } // - // Rule 228: Unsafeopt ::= $Empty + // Rule 227: Unsafeopt ::= $Empty // - case 228: + case 227: setResult(null); break; // - // Rule 229: Unsafeopt ::= unsafe + // Rule 228: Unsafeopt ::= unsafe // - case 229: { + case 228: { //#line 2208 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2208 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3685,9 +3657,9 @@ } // - // Rule 230: ClockedClauseopt ::= $Empty + // Rule 229: ClockedClauseopt ::= $Empty // - case 230: { + case 229: { //#line 2215 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2215 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -3696,9 +3668,9 @@ } // - // Rule 232: identifier ::= IDENTIFIER$ident + // Rule 231: identifier ::= IDENTIFIER$ident // - case 232: { + case 231: { //#line 2226 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2224 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" IToken ident = (IToken) getRhsIToken(1); @@ -3709,9 +3681,9 @@ } // - // Rule 233: TypeName ::= Identifier + // Rule 232: TypeName ::= Identifier // - case 233: { + case 232: { //#line 2233 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2231 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3721,9 +3693,9 @@ } // - // Rule 234: TypeName ::= TypeName . Identifier + // Rule 233: TypeName ::= TypeName . Identifier // - case 234: { + case 233: { //#line 2238 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2236 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(1); @@ -3739,9 +3711,9 @@ } // - // Rule 236: TypeArguments ::= [ TypeArgumentList ] + // Rule 235: TypeArguments ::= [ TypeArgumentList ] // - case 236: { + case 235: { //#line 2250 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2248 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeArgumentList = (List) getRhsSym(2); @@ -3751,9 +3723,9 @@ } // - // Rule 237: TypeArgumentList ::= Type + // Rule 236: TypeArgumentList ::= Type // - case 237: { + case 236: { //#line 2257 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2255 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); @@ -3765,9 +3737,9 @@ } // - // Rule 238: TypeArgumentList ::= TypeArgumentList , Type + // Rule 237: TypeArgumentList ::= TypeArgumentList , Type // - case 238: { + case 237: { //#line 2264 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2262 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeArgumentList = (List) getRhsSym(1); @@ -3779,9 +3751,9 @@ } // - // Rule 239: PackageName ::= Identifier + // Rule 238: PackageName ::= Identifier // - case 239: { + case 238: { //#line 2274 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2272 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3791,9 +3763,9 @@ } // - // Rule 240: PackageName ::= PackageName . Identifier + // Rule 239: PackageName ::= PackageName . Identifier // - case 240: { + case 239: { //#line 2279 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2277 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName PackageName = (ParsedName) getRhsSym(1); @@ -3809,9 +3781,9 @@ } // - // Rule 241: ExpressionName ::= Identifier + // Rule 240: ExpressionName ::= Identifier // - case 241: { + case 240: { //#line 2295 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2293 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3821,9 +3793,9 @@ } // - // Rule 242: ExpressionName ::= AmbiguousName . Identifier + // Rule 241: ExpressionName ::= AmbiguousName . Identifier // - case 242: { + case 241: { //#line 2300 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2298 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -3839,9 +3811,9 @@ } // - // Rule 243: MethodName ::= Identifier + // Rule 242: MethodName ::= Identifier // - case 243: { + case 242: { //#line 2310 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2308 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3851,9 +3823,9 @@ } // - // Rule 244: MethodName ::= AmbiguousName . Identifier + // Rule 243: MethodName ::= AmbiguousName . Identifier // - case 244: { + case 243: { //#line 2315 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2313 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -3869,9 +3841,9 @@ } // - // Rule 245: PackageOrTypeName ::= Identifier + // Rule 244: PackageOrTypeName ::= Identifier // - case 245: { + case 244: { //#line 2325 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2323 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3881,9 +3853,9 @@ } // - // Rule 246: PackageOrTypeName ::= PackageOrTypeName . Identifier + // Rule 245: PackageOrTypeName ::= PackageOrTypeName . Identifier // - case 246: { + case 245: { //#line 2330 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2328 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); @@ -3899,9 +3871,9 @@ } // - // Rule 247: AmbiguousName ::= Identifier + // Rule 246: AmbiguousName ::= Identifier // - case 247: { + case 246: { //#line 2340 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2338 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3911,9 +3883,9 @@ } // - // Rule 248: AmbiguousName ::= AmbiguousName . Identifier + // Rule 247: AmbiguousName ::= AmbiguousName . Identifier // - case 248: { + case 247: { //#line 2345 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2343 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -3929,9 +3901,9 @@ } // - // Rule 249: CompilationUnit ::= PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt + // Rule 248: CompilationUnit ::= PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt // - case 249: { + case 248: { //#line 2357 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2355 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" PackageNode PackageDeclarationopt = (PackageNode) getRhsSym(1); @@ -3955,9 +3927,9 @@ } // - // Rule 250: ImportDeclarations ::= ImportDeclaration + // Rule 249: ImportDeclarations ::= ImportDeclaration // - case 250: { + case 249: { //#line 2373 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2371 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Import ImportDeclaration = (Import) getRhsSym(1); @@ -3969,9 +3941,9 @@ } // - // Rule 251: ImportDeclarations ::= ImportDeclarations ImportDeclaration + // Rule 250: ImportDeclarations ::= ImportDeclarations ImportDeclaration // - case 251: { + case 250: { //#line 2380 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2378 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ImportDeclarations = (List) getRhsSym(1); @@ -3985,9 +3957,9 @@ } // - // Rule 252: TypeDeclarations ::= TypeDeclaration + // Rule 251: TypeDeclarations ::= TypeDeclaration // - case 252: { + case 251: { //#line 2388 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2386 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TopLevelDecl TypeDeclaration = (TopLevelDecl) getRhsSym(1); @@ -4000,9 +3972,9 @@ } // - // Rule 253: TypeDeclarations ::= TypeDeclarations TypeDeclaration + // Rule 252: TypeDeclarations ::= TypeDeclarations TypeDeclaration // - case 253: { + case 252: { //#line 2396 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2394 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeDeclarations = (List) getRhsSym(1); @@ -4016,9 +3988,9 @@ } // - // Rule 254: PackageDeclaration ::= Annotationsopt package PackageName ; + // Rule 253: PackageDeclaration ::= Annotationsopt package PackageName ; // - case 254: { + case 253: { //#line 2404 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2402 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List Annotationsopt = (List) getRhsSym(1); @@ -4032,9 +4004,9 @@ } // - // Rule 257: SingleTypeImportDeclaration ::= import TypeName ; + // Rule 256: SingleTypeImportDeclaration ::= import TypeName ; // - case 257: { + case 256: { //#line 2418 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2416 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(2); @@ -4044,9 +4016,9 @@ } // - // Rule 258: TypeImportOnDemandDeclaration ::= import PackageOrTypeName . * ; + // Rule 257: TypeImportOnDemandDeclaration ::= import PackageOrTypeName . * ; // - case 258: { + case 257: { //#line 2424 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2422 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(2); @@ -4056,9 +4028,9 @@ } // - // Rule 262: TypeDeclaration ::= ; + // Rule 261: TypeDeclaration ::= ; // - case 262: { + case 261: { //#line 2439 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2439 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4067,9 +4039,9 @@ } // - // Rule 263: ClassModifiers ::= ClassModifier + // Rule 262: ClassModifiers ::= ClassModifier // - case 263: { + case 262: { //#line 2447 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2445 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassModifier = (List) getRhsSym(1); @@ -4081,9 +4053,9 @@ } // - // Rule 264: ClassModifiers ::= ClassModifiers ClassModifier + // Rule 263: ClassModifiers ::= ClassModifiers ClassModifier // - case 264: { + case 263: { //#line 2454 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2452 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassModifiers = (List) getRhsSym(1); @@ -4095,9 +4067,9 @@ } // - // Rule 265: ClassModifier ::= Annotation + // Rule 264: ClassModifier ::= Annotation // - case 265: { + case 264: { //#line 2460 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2458 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); @@ -4107,9 +4079,9 @@ } // - // Rule 266: ClassModifier ::= public + // Rule 265: ClassModifier ::= public // - case 266: { + case 265: { //#line 2465 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2465 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4118,9 +4090,9 @@ } // - // Rule 267: ClassModifier ::= protected + // Rule 266: ClassModifier ::= protected // - case 267: { + case 266: { //#line 2470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2470 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4129,9 +4101,9 @@ } // - // Rule 268: ClassModifier ::= private + // Rule 267: ClassModifier ::= private // - case 268: { + case 267: { //#line 2475 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2475 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4140,9 +4112,9 @@ } // - // Rule 269: ClassModifier ::= abstract + // Rule 268: ClassModifier ::= abstract // - case 269: { + case 268: { //#line 2480 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2480 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4151,9 +4123,9 @@ } // - // Rule 270: ClassModifier ::= static + // Rule 269: ClassModifier ::= static // - case 270: { + case 269: { //#line 2485 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2485 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4162,9 +4134,9 @@ } // - // Rule 271: ClassModifier ::= final + // Rule 270: ClassModifier ::= final // - case 271: { + case 270: { //#line 2490 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2490 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4173,9 +4145,9 @@ } // - // Rule 272: ClassModifier ::= strictfp + // Rule 271: ClassModifier ::= strictfp // - case 272: { + case 271: { //#line 2495 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2495 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4184,9 +4156,9 @@ } // - // Rule 273: ClassModifier ::= safe + // Rule 272: ClassModifier ::= safe // - case 273: { + case 272: { //#line 2500 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2500 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4195,9 +4167,9 @@ } // - // Rule 274: TypeDefModifiers ::= TypeDefModifier + // Rule 273: TypeDefModifiers ::= TypeDefModifier // - case 274: { + case 273: { //#line 2506 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2504 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeDefModifier = (List) getRhsSym(1); @@ -4209,9 +4181,9 @@ } // - // Rule 275: TypeDefModifiers ::= TypeDefModifiers TypeDefModifier + // Rule 274: TypeDefModifiers ::= TypeDefModifiers TypeDefModifier // - case 275: { + case 274: { //#line 2513 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2511 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List TypeDefModifiers = (List) getRhsSym(1); @@ -4223,9 +4195,9 @@ } // - // Rule 276: TypeDefModifier ::= Annotation + // Rule 275: TypeDefModifier ::= Annotation // - case 276: { + case 275: { //#line 2519 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2517 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); @@ -4235,9 +4207,9 @@ } // - // Rule 277: TypeDefModifier ::= public + // Rule 276: TypeDefModifier ::= public // - case 277: { + case 276: { //#line 2524 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2524 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4246,9 +4218,9 @@ } // - // Rule 278: TypeDefModifier ::= protected + // Rule 277: TypeDefModifier ::= protected // - case 278: { + case 277: { //#line 2529 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2529 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4257,9 +4229,9 @@ } // - // Rule 279: TypeDefModifier ::= private + // Rule 278: TypeDefModifier ::= private // - case 279: { + case 278: { //#line 2534 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2534 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4268,9 +4240,9 @@ } // - // Rule 280: TypeDefModifier ::= abstract + // Rule 279: TypeDefModifier ::= abstract // - case 280: { + case 279: { //#line 2539 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2539 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4279,9 +4251,9 @@ } // - // Rule 281: TypeDefModifier ::= static + // Rule 280: TypeDefModifier ::= static // - case 281: { + case 280: { //#line 2544 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2544 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4290,9 +4262,9 @@ } // - // Rule 282: TypeDefModifier ::= final + // Rule 281: TypeDefModifier ::= final // - case 282: { + case 281: { //#line 2549 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2549 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4301,9 +4273,9 @@ } // - // Rule 283: Interfaces ::= implements InterfaceTypeList + // Rule 282: Interfaces ::= implements InterfaceTypeList // - case 283: { + case 282: { //#line 2558 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2556 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List InterfaceTypeList = (List) getRhsSym(2); @@ -4313,9 +4285,9 @@ } // - // Rule 284: InterfaceTypeList ::= Type + // Rule 283: InterfaceTypeList ::= Type // - case 284: { + case 283: { //#line 2564 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2562 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); @@ -4327,9 +4299,9 @@ } // - // Rule 285: InterfaceTypeList ::= InterfaceTypeList , Type + // Rule 284: InterfaceTypeList ::= InterfaceTypeList , Type // - case 285: { + case 284: { //#line 2571 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2569 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List InterfaceTypeList = (List) getRhsSym(1); @@ -4342,9 +4314,9 @@ } // - // Rule 286: ClassBody ::= { ClassBodyDeclarationsopt } + // Rule 285: ClassBody ::= { ClassBodyDeclarationsopt } // - case 286: { + case 285: { //#line 2581 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2579 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassBodyDeclarationsopt = (List) getRhsSym(2); @@ -4354,9 +4326,9 @@ } // - // Rule 288: ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration + // Rule 287: ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration // - case 288: { + case 287: { //#line 2588 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2586 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List ClassBodyDeclarations = (List) getRhsSym(1); @@ -4369,9 +4341,9 @@ } // - // Rule 290: ClassBodyDeclaration ::= ConstructorDeclaration + // Rule 289: ClassBodyDeclaration ::= ConstructorDeclaration // - case 290: { + case 289: { //#line 2610 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2608 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ConstructorDecl ConstructorDeclaration = (ConstructorDecl) getRhsSym(1); @@ -4383,9 +4355,9 @@ } // - // Rule 292: ClassMemberDeclaration ::= MethodDeclaration + // Rule 291: ClassMemberDeclaration ::= MethodDeclaration // - case 292: { + case 291: { //#line 2619 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2617 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassMember MethodDeclaration = (ClassMember) getRhsSym(1); @@ -4397,9 +4369,9 @@ } // - // Rule 293: ClassMemberDeclaration ::= PropertyMethodDeclaration + // Rule 292: ClassMemberDeclaration ::= PropertyMethodDeclaration // - case 293: { + case 292: { //#line 2626 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2624 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassMember PropertyMethodDeclaration = (ClassMember) getRhsSym(1); @@ -4411,9 +4383,9 @@ } // - // Rule 294: ClassMemberDeclaration ::= TypeDefDeclaration + // Rule 293: ClassMemberDeclaration ::= TypeDefDeclaration // - case 294: { + case 293: { //#line 2633 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2631 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeDecl TypeDefDeclaration = (TypeDecl) getRhsSym(1); @@ -4425,9 +4397,9 @@ } // - // Rule 295: ClassMemberDeclaration ::= ClassDeclaration + // Rule 294: ClassMemberDeclaration ::= ClassDeclaration // - case 295: { + case 294: { //#line 2640 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2638 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassDecl ClassDeclaration = (ClassDecl) getRhsSym(1); @@ -4439,9 +4411,9 @@ } // - // Rule 296: ClassMemberDeclaration ::= InterfaceDeclaration + // Rule 295: ClassMemberDeclaration ::= InterfaceDeclaration // - case 296: { + case 295: { //#line 2647 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2645 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" ClassDecl InterfaceDeclaration = (ClassDecl) getRhsSym(1); @@ -4453,9 +4425,9 @@ } // - // Rule 297: ClassMemberDeclaration ::= ; + // Rule 296: ClassMemberDeclaration ::= ; // - case 297: { + case 296: { //#line 2654 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2654 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4465,9 +4437,9 @@ } // - // Rule 298: FormalDeclarators ::= FormalDeclarator + // Rule 297: FormalDeclarators ::= FormalDeclarator // - case 298: { + case 297: { //#line 2661 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2659 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Object[] FormalDeclarator = (Object[]) getRhsSym(1); @@ -4479,9 +4451,9 @@ } // - // Rule 299: FormalDeclarators ::= FormalDeclarators , FormalDeclarator + // Rule 298: FormalDeclarators ::= FormalDeclarators , FormalDeclarator // - case 299: { + case 298: { //#line 2668 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2666 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalDeclarators = (List) getRhsSym(1); @@ -4493,9 +4465,9 @@ } // - // Rule 300: FieldDeclarators ::= FieldDeclarator + // Rule 299: FieldDeclarators ::= FieldDeclarator // - case 300: { + case 299: { //#line 2675 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2673 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Object[] FieldDeclarator = (Object[]) getRhsSym(1); @@ -4507,9 +4479,9 @@ } // - // Rule 301: FieldDeclarators ::= FieldDeclarators , FieldDeclarator + // Rule 300: FieldDeclarators ::= FieldDeclarators , FieldDeclarator // - case 301: { + case 300: { //#line 2682 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2680 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldDeclarators = (List) getRhsSym(1); @@ -4522,9 +4494,9 @@ } // - // Rule 302: VariableDeclaratorsWithType ::= VariableDeclaratorWithType + // Rule 301: VariableDeclaratorsWithType ::= VariableDeclaratorWithType // - case 302: { + case 301: { //#line 2690 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2688 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Object[] VariableDeclaratorWithType = (Object[]) getRhsSym(1); @@ -4536,9 +4508,9 @@ } // - // Rule 303: VariableDeclaratorsWithType ::= VariableDeclaratorsWithType , VariableDeclaratorWithType + // Rule 302: VariableDeclaratorsWithType ::= VariableDeclaratorsWithType , VariableDeclaratorWithType // - case 303: { + case 302: { //#line 2697 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2695 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List VariableDeclaratorsWithType = (List) getRhsSym(1); @@ -4551,9 +4523,9 @@ } // - // Rule 304: VariableDeclarators ::= VariableDeclarator + // Rule 303: VariableDeclarators ::= VariableDeclarator // - case 304: { + case 303: { //#line 2704 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2702 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" Object[] VariableDeclarator = (Object[]) getRhsSym(1); @@ -4565,9 +4537,9 @@ } // - // Rule 305: VariableDeclarators ::= VariableDeclarators , VariableDeclarator + // Rule 304: VariableDeclarators ::= VariableDeclarators , VariableDeclarator // - case 305: { + case 304: { //#line 2711 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2709 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List VariableDeclarators = (List) getRhsSym(1); @@ -4580,9 +4552,9 @@ } // - // Rule 307: FieldModifiers ::= FieldModifier + // Rule 306: FieldModifiers ::= FieldModifier // - case 307: { + case 306: { //#line 2720 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2718 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldModifier = (List) getRhsSym(1); @@ -4594,9 +4566,9 @@ } // - // Rule 308: FieldModifiers ::= FieldModifiers FieldModifier + // Rule 307: FieldModifiers ::= FieldModifiers FieldModifier // - case 308: { + case 307: { //#line 2727 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2725 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FieldModifiers = (List) getRhsSym(1); @@ -4608,9 +4580,9 @@ } // - // Rule 309: FieldModifier ::= Annotation + // Rule 308: FieldModifier ::= Annotation // - case 309: { + case 308: { //#line 2733 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2731 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); @@ -4620,9 +4592,9 @@ } // - // Rule 310: FieldModifier ::= public + // Rule 309: FieldModifier ::= public // - case 310: { + case 309: { //#line 2738 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2738 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4631,9 +4603,9 @@ } // - // Rule 311: FieldModifier ::= protected + // Rule 310: FieldModifier ::= protected // - case 311: { + case 310: { //#line 2743 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2743 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4642,9 +4614,9 @@ } // - // Rule 312: FieldModifier ::= private + // Rule 311: FieldModifier ::= private // - case 312: { + case 311: { //#line 2748 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2748 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4653,9 +4625,9 @@ } // - // Rule 313: FieldModifier ::= static + // Rule 312: FieldModifier ::= static // - case 313: { + case 312: { //#line 2753 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2753 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4664,9 +4636,9 @@ } // - // Rule 314: FieldModifier ::= transient + // Rule 313: FieldModifier ::= transient // - case 314: { + case 313: { //#line 2758 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2758 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4675,9 +4647,9 @@ } // - // Rule 315: FieldModifier ::= volatile + // Rule 314: FieldModifier ::= volatile // - case 315: { + case 314: { //#line 2763 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2763 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4686,9 +4658,9 @@ } // - // Rule 316: FieldModifier ::= global + // Rule 315: FieldModifier ::= global // - case 316: { + case 315: { //#line 2768 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2768 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" @@ -4697,9 +4669,9 @@ } // - // Rule 317: ResultType ::= : Type + // Rule 316: ResultType ::= : Type // - case 317: { + case 316: { //#line 2774 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2772 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(2); @@ -4709,9 +4681,9 @@ } // - // Rule 318: FormalParameters ::= ( FormalParameterList ) + // Rule 317: FormalParameters ::= ( FormalParameterList ) // - case 318: { + case 317: { //#line 2780 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2778 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameterList = (List) getRhsSym(2); @@ -4721,9 +4693,9 @@ } // - // Rule 319: FormalParameterList ::= FormalParameter + // Rule 318: FormalParameterList ::= FormalParameter // - case 319: { + case 318: { //#line 2786 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2784 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(1); @@ -4735,9 +4707,9 @@ } // - // Rule 320: FormalParameterList ::= FormalParameterList , FormalParameter + // Rule 319: FormalParameterList ::= FormalParameterList , FormalParameter // - case 320: { + case 319: { //#line 2793 "C:/eclipsews/v9/lpg.generator/templates/java/btParserTemplateF.gi" //#line 2791 "C:/eclipsews/v9/x10.compiler/src/x10/parser/x10.g" List FormalParameterList = (List) getRhsSym(1); @@ -4749,9 +4721,9 @@ } // - // Rule 321: LoopIndexDeclarator ::= Identifier ResultTypeopt + // Rule 320: LoopIndexDeclarator ::= Identifier ResultTypeopt // - case 321: { + case 320: { //#line 2799... [truncated message content] |
From: <ipe...@us...> - 2009-11-09 16:25:01
|
Revision: 11967 http://x10.svn.sourceforge.net/x10/?rev=11967&view=rev Author: ipeshansky Date: 2009-11-09 16:24:52 +0000 (Mon, 09 Nov 2009) Log Message: ----------- Enable GC on Cygwin: it passes all self tests, and GCSpheres works. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java trunk/x10.runtime/build.xml Modified: trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java 2009-11-09 16:22:46 UTC (rev 11966) +++ trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java 2009-11-09 16:24:52 UTC (rev 11967) @@ -14,7 +14,7 @@ assert (CXXCommandBuilder.PLATFORM.startsWith("win32_")); } - protected boolean gcEnabled() { return false; } + protected boolean gcEnabled() { return true; } protected String defaultPostCompiler() { return "g++-3"; Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2009-11-09 16:22:46 UTC (rev 11966) +++ trunk/x10.runtime/build.xml 2009-11-09 16:24:52 UTC (rev 11967) @@ -72,6 +72,7 @@ <or> <os family="unix" name="linux"/> <os family="mac"/> + <os family="windows"/> </or> </and> </condition> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2009-11-10 02:37:27
|
Revision: 11971 http://x10.svn.sourceforge.net/x10/?rev=11971&view=rev Author: vj0 Date: 2009-11-10 02:37:15 +0000 (Tue, 10 Nov 2009) Log Message: ----------- Fix breakage due to introduction of safe on methods in Any. (Implementing methods in Struct and Object must also be safe.) Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.runtime/src-x10/x10/lang/Object.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-10 00:58:57 UTC (rev 11970) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2009-11-10 02:37:15 UTC (rev 11971) @@ -179,9 +179,9 @@ if (Report.should_report(Report.types, 3)) Report.report(3, mi.flags() + " is more liberal than " + mj.flags()); - throw new SemanticException(mi.signature() + " in " + mi.container() + + throw new SemanticException(mi.flags() + " " + mi.signature() + " in " + mi.container() + " cannot override " + - mj.signature() + " in " + mj.container() + + mj.flags() + " " + mj.signature() + " in " + mj.container() + "; attempting to assign weaker " + "behavioral annotations", mi.position()); @@ -1835,9 +1835,9 @@ if (Report.should_report(Report.types, 3)) Report.report(3, mi.flags() + " is more liberal than " + mj.flags()); - throw new SemanticException(mi.signature() + " in " + mi.container() + + throw new SemanticException(mi.flags() + " " + mi.signature() + " in " + mi.container() + " cannot override " + - mj.signature() + " in " + mj.container() + + mj.flags() + " " + mj.signature() + " in " + mj.container() + "; attempting to assign weaker " + "behavioral annotations", mi.position()); Modified: trunk/x10.compiler/src/x10/util/Struct.java =================================================================== --- trunk/x10.compiler/src/x10/util/Struct.java 2009-11-10 00:58:57 UTC (rev 11970) +++ trunk/x10.compiler/src/x10/util/Struct.java 2009-11-10 02:37:15 UTC (rev 11971) @@ -118,7 +118,8 @@ // @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") // property def loc():Place mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global(), PLACE, + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Global().Safe(), + PLACE, Name.make("loc"), Collections.EMPTY_LIST, Collections.EMPTY_LIST, @@ -145,7 +146,8 @@ // property def at(p:Object):boolean; List<LocalDef> parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(OBJECT)); mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, Name.make("at"), Collections.EMPTY_LIST, Collections.<Ref<? extends Type>> singletonList(OBJECT), @@ -170,7 +172,7 @@ mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global(), + X10Flags.toX10Flags(Flags.PUBLIC.Native().Final()).Global().Safe(), STRING, Name.make("typeName"), Collections.EMPTY_LIST, @@ -202,7 +204,8 @@ // property def at(p:Place):boolean; parameters = xts.dummyLocalDefs(Collections.<Ref<? extends Type>> singletonList(PLACE)); mi = xts.methodDef(pos, Types.ref(ct), - X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property(), BOOLEAN, + X10Flags.toX10Flags(Flags.PUBLIC.Native()).Property().Safe(), + BOOLEAN, Name.make("at"), Collections.EMPTY_LIST, Collections.<Ref<? extends Type>> singletonList(PLACE), Modified: trunk/x10.runtime/src-x10/x10/lang/Object.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-11-10 00:58:57 UTC (rev 11970) +++ trunk/x10.runtime/src-x10/x10/lang/Object.x10 2009-11-10 02:37:15 UTC (rev 11971) @@ -45,15 +45,15 @@ @Native("java", "x10.lang.Place.place(x10.core.Ref.location(#0))") @Native("c++", "x10::lang::Place_methods::place((#0)->location)") - public property def loc() = location; + public property safe def loc() = location; @Native("java", "x10.core.Ref.at(#0, #1.id)") @Native("c++", "((#0)->location == (#1)->FMGL(id))") - public property def at(p:Place) = location==p; + public property safe def at(p:Place) = location==p; @Native("java", "x10.core.Ref.at(#0, #1)") @Native("c++", "((#0)->location == (#1)->location)") - public property def at(r:Object) = location==r.location; + public property safe def at(r:Object) = location==r.location; @Native("java", "x10.core.Ref.typeName(#0)") public native global final def typeName():String; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-10 19:03:12
|
Revision: 11975 http://x10.svn.sourceforge.net/x10/?rev=11975&view=rev Author: sparksparkspark Date: 2009-11-10 19:03:03 +0000 (Tue, 10 Nov 2009) Log Message: ----------- use properties files Modified Paths: -------------- trunk/x10.compiler/.classpath trunk/x10.compiler/src/x10cpp/postcompiler/AIX_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/Linux_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java trunk/x10.dist/bin/x10c++ trunk/x10.dist/bin/x10c.in trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10rt/Makefile Added Paths: ----------- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_lapi.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_sockets.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_lapi.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_sockets.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/bgp/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/bgp/x10rt_pgas_bgp.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/cygwin/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/cygwin/x10rt_pgas_sockets.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/darwin/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/darwin/x10rt_pgas_sockets.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_lapi.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_sockets.properties trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/sunos/ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/sunos/x10rt_pgas_sockets.properties Modified: trunk/x10.compiler/.classpath =================================================================== --- trunk/x10.compiler/.classpath 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/.classpath 2009-11-10 19:03:03 UTC (rev 11975) @@ -1,12 +1,9 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry excluding="src/" including="data/**" kind="src" path=""/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry combineaccessrules="false" kind="src" path="/polyglot3"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.common"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.constraints"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.runtime"/> - <classpathentry kind="output" path="classes"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry excluding="src/" including="data/**" kind="src" path=""/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry combineaccessrules="false" kind="src" path="/x10.runtime"/> + <classpathentry kind="output" path="classes"/> +</classpath> Modified: trunk/x10.compiler/src/x10cpp/postcompiler/AIX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/AIX_CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/AIX_CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -6,23 +6,20 @@ import java.util.ArrayList; import polyglot.main.Options; +import polyglot.util.ErrorQueue; public class AIX_CXXCommandBuilder extends CXXCommandBuilder { //"mpCC_r -q64 -qrtti=all -qarch=pwr5 -O3 -qtune=pwr5 -qhot -qinline" //"mpCC_r -q64 -qrtti=all" public static final String XLC_EXTRA_FLAGS = System.getenv("XLC_EXTRA_FLAGS"); - public AIX_CXXCommandBuilder(Options options) { - super(options); + public AIX_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options, eq); assert (CXXCommandBuilder.PLATFORM.startsWith("aix_")); } protected boolean gcEnabled() { return false; } - protected String defaultPostCompiler() { - return USE_XLC ? "mpCC_r" : "g++"; - } - protected void addPreArgs(ArrayList<String> cxxCmd) { super.addPreArgs(cxxCmd); @@ -49,13 +46,6 @@ } else { cxxCmd.add("-Wl,-bbigtoc"); cxxCmd.add("-Wl,-lptools_ptr"); - if (x10rt == X10RT_Impl.PGAS_LAPI) { - cxxCmd.add("-Wl,-binitfini:poe_remote_main"); - cxxCmd.add("-L/usr/lpp/ppe.poe/lib"); - cxxCmd.add("-lmpi_r"); - cxxCmd.add("-lvtd_r"); - cxxCmd.add("-llapi_r"); - } } } } Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -5,12 +5,15 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.util.Arrays; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.Properties; import polyglot.main.Options; import polyglot.util.ErrorInfo; @@ -20,41 +23,51 @@ import x10cpp.X10CPPCompilerOptions; public class CXXCommandBuilder { - protected static enum X10RT_Impl { - PGAS_LAPI("xlpgas_lapi"), - PGAS_SOCKETS("xlpgas_sockets"), - PGAS_BGP("xlpgas_bgp"), - MPI("x10rt_mpi"), - STANDALONE("x10rt_standalone"); + + protected class X10RTPostCompileOptions { - private final String libName; + public final String cxx; + public final Collection<? extends String> cxxFlags; + public final Collection<? extends String> libs; + public final Collection<? extends String> ldFlags; - X10RT_Impl(String libName) { - this.libName = libName; + private Collection<? extends String> split(String s) { + ArrayList<String> l = new ArrayList<String>(); + if (s==null) return l; + QuotedStringTokenizer q = new QuotedStringTokenizer(s); + while (q.hasMoreTokens()) l.add(q.nextToken()); + return l; } - String libName() { return libName; } - }; + public X10RTPostCompileOptions (ErrorQueue eq, String filename) { + Properties properties = new Properties(); + try { + properties.load(new FileInputStream(filename)); + } catch(IOException e) { + eq.enqueue(ErrorInfo.IO_ERROR, "Error finding X10RT properties file: "+ e.getMessage()); + } + cxx = properties.getProperty("CXX"); + String regex = " +"; + cxxFlags = split(properties.getProperty("CXXFLAGS")); + libs = split(properties.getProperty("LDLIBS")); + ldFlags = split(properties.getProperty("LDFLAGS")); + } + } - public static final String PLATFORM = System.getenv("X10_PLATFORM")==null?"unknown":System.getenv("X10_PLATFORM"); - public static final String X10LANG = System.getenv("X10LANG")==null?"../../../x10.runtime/src-cpp":System.getenv("X10LANG").replace(File.separatorChar, '/'); - public static final String X10DIST = System.getenv("X10DIST")==null?"../../../x10.dist":System.getenv("X10DIST").replace(File.separatorChar, '/'); + protected static final String PLATFORM = System.getenv("X10_PLATFORM")==null?"unknown":System.getenv("X10_PLATFORM"); + protected static final String X10_DIST = System.getenv("X10_DIST"); + protected static final String X10GC = System.getenv("X10GC").replace(File.separatorChar, '/'); + protected static final boolean USE_XLC = PLATFORM.startsWith("aix_") && System.getenv("USE_GCC")==null; public static final String MANIFEST = "libx10.mft"; - public static final String[] MANIFEST_LOCATIONS = new String[] { - X10LANG, - X10LANG+"/lib", - }; + public static final String[] MANIFEST_LOCATIONS = new String[] { X10_DIST+"/lib" }; - protected static final String X10LIB = System.getenv("X10LIB")==null?"../../../pgas2/common/work":System.getenv("X10LIB").replace(File.separatorChar, '/'); - protected static final String X10GC = System.getenv("X10GC")==null?X10DIST:System.getenv("X10GC").replace(File.separatorChar, '/'); - protected static final boolean USE_XLC = PLATFORM.startsWith("aix_") && System.getenv("USE_GCC")==null; private final X10CPPCompilerOptions options; - protected final X10RT_Impl x10rt; - - public CXXCommandBuilder(Options options) { + protected X10RTPostCompileOptions x10rtOpts; + + public CXXCommandBuilder(Options options, ErrorQueue eq) { assert (options != null); assert (options.post_compiler != null); this.options = (X10CPPCompilerOptions) options; @@ -62,45 +75,29 @@ if (rtimpl == null) { // assume pgas (default to old behavior) if (PLATFORM.startsWith("aix_")) { - x10rt = X10RT_Impl.PGAS_LAPI; + rtimpl = "pgas_lapi"; } else { - x10rt = X10RT_Impl.PGAS_SOCKETS; + rtimpl = "pgas_sockets"; } - } else if (rtimpl.equals("PGAS_LAPI")) { - x10rt = X10RT_Impl.PGAS_LAPI; - } else if (rtimpl.equals("PGAS_SOCKETS")) { - x10rt = X10RT_Impl.PGAS_SOCKETS; - } else if (rtimpl.equals("PGAS_BGP")) { - x10rt = X10RT_Impl.PGAS_BGP; - } else if (rtimpl.equals("MPI")) { - x10rt = X10RT_Impl.MPI; - } else if (rtimpl.equals("STANDALONE")) { - x10rt = X10RT_Impl.STANDALONE; - } else { - assert false : "Unknown X10RT IMPL "+ rtimpl; - x10rt = X10RT_Impl.PGAS_SOCKETS; } + // allow the user to give an explicit path, otherwise look in etc + if (!rtimpl.endsWith(".properties")) { + rtimpl = X10_DIST + "/etc/x10rt_"+rtimpl+".properties"; + } + x10rtOpts = new X10RTPostCompileOptions(eq, rtimpl); } /** Is GC enabled on this platform? */ protected boolean gcEnabled() { return false; } protected String defaultPostCompiler() { - if (x10rt == X10RT_Impl.MPI) { - return "mpicxx"; - } else { - return "g++"; - } + return x10rtOpts.cxx; } /** Add the arguments that go before the output files */ protected void addPreArgs(ArrayList<String> cxxCmd) { cxxCmd.add("-g"); - cxxCmd.add("-I"+X10LIB+"/include"); - cxxCmd.add("-I"+X10LANG); - cxxCmd.add("-I"+X10LANG+"/gen"); // FIXME: development option - cxxCmd.add("-I"+X10LANG+"/include"); // dist - cxxCmd.add("-I"+X10DIST+"/include"); + cxxCmd.add("-I"+X10_DIST+"/include"); // dist cxxCmd.add("-I."); if (!Configuration.DISABLE_GC && gcEnabled()) { @@ -120,6 +117,9 @@ if (x10.Configuration.NO_CHECKS) { cxxCmd.add("-DNO_CHECKS"); } + + cxxCmd.addAll(x10rtOpts.cxxFlags); + } /** Add the arguments that go after the output files */ @@ -128,12 +128,13 @@ cxxCmd.add(X10GC+"/lib/libgc.a"); } - cxxCmd.add("-L"+X10LIB+"/lib"); - cxxCmd.add("-L"+X10LANG); - cxxCmd.add("-L"+X10LANG+"/lib"); // dist - cxxCmd.add("-L"+X10DIST+"/lib"); + cxxCmd.add("-L"+X10_DIST+"/lib"); // dist cxxCmd.add("-lx10"); - cxxCmd.add("-l"+x10rt.libName()); + + cxxCmd.add("-L"+X10_DIST+"/../pgas2/common/work/lib"); // temporary + cxxCmd.addAll(x10rtOpts.ldFlags); + cxxCmd.addAll(x10rtOpts.libs); + cxxCmd.add("-ldl"); cxxCmd.add("-lm"); cxxCmd.add("-lpthread"); @@ -229,18 +230,18 @@ public static CXXCommandBuilder getCXXCommandBuilder(Options options, ErrorQueue eq) { if (PLATFORM.startsWith("win32_")) - return new Cygwin_CXXCommandBuilder(options); + return new Cygwin_CXXCommandBuilder(options, eq); if (PLATFORM.startsWith("linux_")) - return new Linux_CXXCommandBuilder(options); + return new Linux_CXXCommandBuilder(options, eq); if (PLATFORM.startsWith("aix_")) - return new AIX_CXXCommandBuilder(options); + return new AIX_CXXCommandBuilder(options, eq); if (PLATFORM.startsWith("sunos_")) - return new SunOS_CXXCommandBuilder(options); + return new SunOS_CXXCommandBuilder(options, eq); if (PLATFORM.startsWith("macosx_")) - return new MacOSX_CXXCommandBuilder(options); + return new MacOSX_CXXCommandBuilder(options, eq); eq.enqueue(ErrorInfo.WARNING, "Unknown platform '"+PLATFORM+"'; using the default post-compiler (g++)"); - return new CXXCommandBuilder(options); + return new CXXCommandBuilder(options, eq); } } Modified: trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/Cygwin_CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -6,11 +6,12 @@ import java.util.ArrayList; import polyglot.main.Options; +import polyglot.util.ErrorQueue; public class Cygwin_CXXCommandBuilder extends CXXCommandBuilder { - public Cygwin_CXXCommandBuilder(Options options) { - super(options); + public Cygwin_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options, eq); assert (CXXCommandBuilder.PLATFORM.startsWith("win32_")); } Modified: trunk/x10.compiler/src/x10cpp/postcompiler/Linux_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/Linux_CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/Linux_CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -6,13 +6,14 @@ import java.util.ArrayList; import polyglot.main.Options; +import polyglot.util.ErrorQueue; public class Linux_CXXCommandBuilder extends CXXCommandBuilder { protected static final boolean USE_X86 = CXXCommandBuilder.PLATFORM.endsWith("_x86"); protected static final boolean USE_BFD = System.getenv("USE_BFD")!=null; - public Linux_CXXCommandBuilder(Options options) { - super(options); + public Linux_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options, eq); assert (CXXCommandBuilder.PLATFORM.startsWith("linux_")); } @@ -37,11 +38,5 @@ cxxCmd.add("-lbfd"); cxxCmd.add("-liberty"); } - if (x10rt == X10RT_Impl.PGAS_LAPI) { - cxxCmd.add("-llapi"); - cxxCmd.add("-lmpi_ibm"); - cxxCmd.add("-lpoe"); - } - } } Modified: trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -6,11 +6,12 @@ import java.util.ArrayList; import polyglot.main.Options; +import polyglot.util.ErrorQueue; public class MacOSX_CXXCommandBuilder extends CXXCommandBuilder { - public MacOSX_CXXCommandBuilder(Options options) { - super(options); + public MacOSX_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options,eq); assert (CXXCommandBuilder.PLATFORM.startsWith("macosx_")); } Modified: trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java 2009-11-10 19:03:03 UTC (rev 11975) @@ -6,11 +6,12 @@ import java.util.ArrayList; import polyglot.main.Options; +import polyglot.util.ErrorQueue; public class SunOS_CXXCommandBuilder extends CXXCommandBuilder { - public SunOS_CXXCommandBuilder(Options options) { - super(options); + public SunOS_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options, eq); assert (CXXCommandBuilder.PLATFORM.startsWith("sunos_")); } @@ -24,9 +25,5 @@ protected void addPostArgs(ArrayList<String> cxxCmd) { super.addPostArgs(cxxCmd); - cxxCmd.add("-lresolv"); - cxxCmd.add("-lnsl"); - cxxCmd.add("-lsocket"); - cxxCmd.add("-lrt"); } } Modified: trunk/x10.dist/bin/x10c++ =================================================================== --- trunk/x10.dist/bin/x10c++ 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.dist/bin/x10c++ 2009-11-10 19:03:03 UTC (rev 11975) @@ -12,30 +12,14 @@ prog=$(readlink $0 2>&1) [ $? -eq 127 -o "$prog" = "" ] && prog="$0" -TOP="$(cd "$(dirname "$prog")/.." && pwd)" -if [[ "$UNAME" = CYGWIN* ]]; then TOP="$(cygpath -aw "$TOP")"; fi -if [[ -z "$X10_FROM_SRC" ]]; then - # Default to pre-built distribution; do not set X10REL - [ -z "$X10LIB" ] && export X10LIB="$TOP" - [ -z "$X10LANG" ] && export X10LANG="$TOP" - [ -z "$X10DIST" ] && export X10DIST="$TOP" - [ -z "$X10GC" ] && export X10GC="$TOP" - [ -z "$X10SOURCES" ] && export X10SOURCES="$X10DIST/lib/x10.jar" - X10="$TOP" -else - # Default to developer setup - [ -z "$X10REL" ] && export X10REL="../x10.dist" - [ -z "$X10LIB" ] && export X10LIB="$TOP/../pgas2/common/work" - [ -z "$X10LANG" ] && export X10LANG="$TOP/../x10.runtime/src-cpp" - [ -z "$X10DIST" ] && export X10DIST="$TOP/../x10.dist" - [ -z "$X10GC" ] && export X10GC="$TOP/../x10.runtime/src-cpp/bdwgc/install" - [ -z "$X10SOURCES" ] && export X10SOURCES="$X10DIST/../x10.runtime/src-x10" - X10="$(cd "$TOP/$X10REL" && pwd)" -fi +export X10_DIST="$(cd "$(dirname "$prog")/.." && pwd)" +if [[ "$UNAME" = CYGWIN* ]]; then X10_DIST="$(cygpath -aw "$X10_DIST")"; fi +[ -z "$X10GC" ] && export X10GC="$X10_DIST" +[ -z "$X10SOURCES" ] && export X10SOURCES="${X10_DIST}/lib/x10.jar" -export CP_OVERRIDE="${TOP}${FILE_SEP}lib${FILE_SEP}x10c.jar${PATH_SEP}${TOP}${FILE_SEP}classes${PATH_SEP}" +export CP_OVERRIDE="${X10_DIST}${FILE_SEP}lib${FILE_SEP}x10c.jar${PATH_SEP}${X10_DIST}${FILE_SEP}classes${PATH_SEP}" export DEXT="x10cpp.ExtensionInfo" -exec "${X10}/bin/x10c" "$@" +exec "${X10_DIST}/bin/x10c" "$@" Modified: trunk/x10.dist/bin/x10c.in =================================================================== --- trunk/x10.dist/bin/x10c.in 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.dist/bin/x10c.in 2009-11-10 19:03:03 UTC (rev 11975) @@ -25,7 +25,7 @@ -config) shift; config="$1.cfg";; -extclass) shift; ext=$1;; -dev) dev="true";; - -x10rt) shift; x10rt_impl=$1;; + -x10rt) shift; export X10RT_IMPL=$1;; -O|-optimize) optimize="true";; -rtdev) rtdev="true";; -J*) java_args="${java_args} '${1##-J}'";; @@ -70,17 +70,6 @@ extra_cp="${PATH_SEP}${extra_cp}" fi -if [ -n "$x10rt_impl" ]; then - case "$x10rt_impl" in - bgp) export X10RT_IMPL=PGAS_BGP;; - lapi) export X10RT_IMPL=PGAS_LAPI;; - sockets) export X10RT_IMPL=PGAS_SOCKETS;; - mpi) export X10RT_IMPL=MPI;; - standalone) export X10RT_IMPL=STANDALONE;; - *) - esac -fi - extargs="" # [DC] assert should be off by default # extargs="$extargs -assert" Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.runtime/src-cpp/Makefile 2009-11-10 19:03:03 UTC (rev 11975) @@ -53,18 +53,21 @@ #override CC =/bgsys/ibm_compilers/gcc-4.3.2/gnu-linux/bin/powerpc-bgp-linux-gcc override CXX = /bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-g++ override CC =/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-gcc - + export X10RT_HANDWRITTEN_PROPS="bgp" else ifeq ($(shell uname -s),AIX) + ifdef USE_GCC + export X10RT_HANDWRITTEN_PROPS="aix_gcc" ifdef OPTIMIZE override CXXFLAGS += -O2 -finline-functions endif override CXXFLAGS += -maix64 MPICXX ?= mpicxx else + export X10RT_HANDWRITTEN_PROPS="aix_xlc" CXX = mpCC_r MPICXX ?= mpCC_r override CXXFLAGS -= -g @@ -102,6 +105,19 @@ override CXXFLAGS += -ansi -pedantic -Wall -Wextra -Wno-long-long -Wno-unused-parameter ifeq ($(shell uname -s),Linux) override CXXFLAGS += -pthread + export X10RT_HANDWRITTEN_PROPS="linux" + else + ifeq ($(shell uname -s),CYGWIN) + export X10RT_HANDWRITTEN_PROPS="cygwin" + else + ifeq ($(shell uname -s),Darwin) + export X10RT_HANDWRITTEN_PROPS="darwin" + else + ifeq ($(shell uname -s),SunOS) + export X10RT_HANDWRITTEN_PROPS="sunos" + endif + endif + endif endif endif endif Modified: trunk/x10.runtime/src-cpp/x10rt/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/Makefile 2009-11-10 16:57:54 UTC (rev 11974) +++ trunk/x10.runtime/src-cpp/x10rt/Makefile 2009-11-10 19:03:03 UTC (rev 11975) @@ -21,6 +21,7 @@ install: $(LIBS) $(PROPERTIES) cp $(LIBS) $(X10_HOME)/x10.dist/lib cp $(PROPERTIES) $(X10_HOME)/x10.dist/etc + cp handwritten_properties/$(X10RT_HANDWRITTEN_PROPS)/*.properties $(X10_HOME)/x10.dist/etc tests: $(TESTS) Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_lapi.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_lapi.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_lapi.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS=-Wl,-binitfini:poe_remote_main -L/usr/lpp/ppe.poe/lib +LDLIBS=-lxlpgas_lapi -lmpi_r -lvtd_r -llapi_r -lpthread -lm Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_gcc/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_lapi.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_lapi.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_lapi.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=mpCC_r +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_lapi Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/aix_xlc/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,5 @@ +CXX=xlC_r +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread + Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/bgp/x10rt_pgas_bgp.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/bgp/x10rt_pgas_bgp.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/bgp/x10rt_pgas_bgp.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-g++ +CXXFLAGS= +LDFLAGS=-L/bgsys/drivers/ppcfloor/comm/lib -L/bgsys/drivers/ppcfloor/runtime/SPI +LDLIBS=-lxlpgas_bgp -ldcmf.cnk -ldcmfcoll.cnk -lSPI.cna -lpthread -lrt -lm Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/cygwin/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/cygwin/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/cygwin/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/darwin/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/darwin/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/darwin/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_lapi.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_lapi.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_lapi.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS=-L/opt/ibmhpc/ppe.poe/lib +LDLIBS=-lxlpgas_lapi -llapi -lmpi_ibm -lpoe Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/linux/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread Added: trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/sunos/x10rt_pgas_sockets.properties =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/sunos/x10rt_pgas_sockets.properties (rev 0) +++ trunk/x10.runtime/src-cpp/x10rt/handwritten_properties/sunos/x10rt_pgas_sockets.properties 2009-11-10 19:03:03 UTC (rev 11975) @@ -0,0 +1,4 @@ +CXX=g++ +CXXFLAGS= +LDFLAGS= +LDLIBS=-lxlpgas_sockets -lpthread -lresolv -lnsl -lsocket -lrt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-10 21:18:04
|
Revision: 11983 http://x10.svn.sourceforge.net/x10/?rev=11983&view=rev Author: sparksparkspark Date: 2009-11-10 21:17:56 +0000 (Tue, 10 Nov 2009) Log Message: ----------- Avoid NPE if properties file not found or does not include CXX = Add -rt to general post-compiler options on sunos Modified Paths: -------------- trunk/x10.compiler/.classpath trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java trunk/x10.runtime/META-INF/MANIFEST.MF Modified: trunk/x10.compiler/.classpath =================================================================== --- trunk/x10.compiler/.classpath 2009-11-10 20:42:38 UTC (rev 11982) +++ trunk/x10.compiler/.classpath 2009-11-10 21:17:56 UTC (rev 11983) @@ -1,12 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry excluding="src/" including="data/**" kind="src" path=""/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry combineaccessrules="false" kind="src" path="/polyglot3"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.common"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.constraints"/> - <classpathentry combineaccessrules="false" kind="src" path="/x10.runtime"/> - <classpathentry kind="output" path="classes"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry excluding="src/" including="data/**" kind="src" path=""/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="classes"/> +</classpath> Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-10 20:42:38 UTC (rev 11982) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-10 21:17:56 UTC (rev 11983) @@ -46,7 +46,8 @@ } catch(IOException e) { eq.enqueue(ErrorInfo.IO_ERROR, "Error finding X10RT properties file: "+ e.getMessage()); } - cxx = properties.getProperty("CXX"); + String s = properties.getProperty("CXX"); + cxx = s==null ? "g++" : s; //fallback if above error occured or CXX not given in properties file String regex = " +"; cxxFlags = split(properties.getProperty("CXXFLAGS")); libs = split(properties.getProperty("LDLIBS")); Modified: trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java 2009-11-10 20:42:38 UTC (rev 11982) +++ trunk/x10.compiler/src/x10cpp/postcompiler/SunOS_CXXCommandBuilder.java 2009-11-10 21:17:56 UTC (rev 11983) @@ -25,5 +25,6 @@ protected void addPostArgs(ArrayList<String> cxxCmd) { super.addPostArgs(cxxCmd); + cxxCmd.add("-lrt"); } } Modified: trunk/x10.runtime/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.runtime/META-INF/MANIFEST.MF 2009-11-10 20:42:38 UTC (rev 11982) +++ trunk/x10.runtime/META-INF/MANIFEST.MF 2009-11-10 21:17:56 UTC (rev 11983) @@ -5,6 +5,4 @@ Bundle-Version: 2.0.0 Eclipse-AutoStart: true Bundle-Vendor: rf...@wa... -Require-Bundle: x10.common, - x10.constraints This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-12 04:42:09
|
Revision: 12007 http://x10.svn.sourceforge.net/x10/?rev=12007&view=rev Author: ipeshansky Date: 2009-11-12 04:41:51 +0000 (Thu, 12 Nov 2009) Log Message: ----------- Fix ateach expansion to avoid creating points if possible. Add missing newline in constructor codegen. Make Dist.makeUnique() return a singleton. Mark Dist.makeUnique() return value as rect. Whitespace. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-x10/Dummy.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/lang/Dist.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-12 04:41:51 UTC (rev 12007) @@ -510,27 +510,38 @@ assert (((X10TypeSystem_c) xts).isDistribution(dType)); MethodInstance mi = xts.findMethod(dType, xts.MethodMatcher(dType, APPLY, Collections.singletonList(fType), context)); - Expr index = xnf.Local(bpos, - xnf.Id(bpos, formal.name().id())) - .localInstance(formal.localDef().asInstance()) - .type(fType); + List<Expr> index = new ArrayList<Expr>(); if (formal.isUnnamed()) { ArrayList<Expr> vars = new ArrayList<Expr>(); + ArrayList<Type> varTypes = new ArrayList<Type>(); for (LocalDef ld : formal.localInstances()) { + Type t = ld.type().get(); vars.add(xnf.Local(bpos, nf.Id(bpos, ld.name())) .localInstance(ld.asInstance()) - .type(ld.type().get())); + .type(t)); + varTypes.add(t); } - Type intRail = xts.ValRail(xts.Int()); - MethodInstance cnv = xts.findMethod(fType, - xts.MethodMatcher(fType, CONVERT_IMPLICITLY, - Collections.singletonList(intRail), context)); - assert (cnv.flags().isStatic()); - index = - xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), - xnf.Id(bpos, CONVERT_IMPLICITLY), - xnf.Tuple(bpos, vars).type(intRail)).methodInstance(cnv).type(fType); + MethodInstance mi1 = xts.findMethod(dType, + xts.MethodMatcher(dType, APPLY, varTypes, context)); + if (mi1 != null) { + mi = mi1; + index = vars; + } else { + Type intRail = xts.ValRail(xts.Int()); + MethodInstance cnv = xts.findMethod(fType, + xts.MethodMatcher(fType, CONVERT_IMPLICITLY, + Collections.singletonList(intRail), context)); + assert (cnv.flags().isStatic()); + index.add(xnf.Call(bpos, xnf.CanonicalTypeNode(bpos, fType), + xnf.Id(bpos, CONVERT_IMPLICITLY), + xnf.Tuple(bpos, vars).type(intRail)).methodInstance(cnv).type(fType)); + } + } else { + index.add(xnf.Local(bpos, + xnf.Id(bpos, formal.name().id())) + .localInstance(formal.localDef().asInstance()) + .type(fType)); } Expr place = xnf.Call(bpos, xnf.Local(pos, xnf.Id(pos, tmp)).localInstance(lDef.asInstance()).type(dType), Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-12 04:41:51 UTC (rev 12007) @@ -1973,6 +1973,7 @@ } sw.end(); sw.newline(); sw.write("}"); + sw.newline(); if (!container.flags().isAbstract()) { // emit _make method Modified: trunk/x10.runtime/src-x10/Dummy.x10 =================================================================== --- trunk/x10.runtime/src-x10/Dummy.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/Dummy.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -97,7 +97,7 @@ var f105 : x10.lang.Unsigned; var f106 : x10.lang.UnsupportedOperationException; var f107 : x10.lang.ValRail[Dummy]; - // var f108 : x10.lang.Value; + //var f108 : x10.lang.Value; var f109 : x10.lang._; var f113 : x10.runtime.Clock_c; var f115 : x10.runtime.Future_c[Dummy]; Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -30,8 +30,10 @@ // factories - place is all applicable places // - public static def makeUnique1(): Dist(1) { - return makeUnique1(Place.places); + // There's only one unique distribution + private static val UNIQUE = makeUnique1(Place.places) as Dist(1){rect}; + public static def makeUnique1(): Dist(1){rect} { + return UNIQUE; } public static def makeUnique1(ps: Rail[Place]): Dist(1) { // XTENLANG-4 Modified: trunk/x10.runtime/src-x10/x10/lang/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-12 01:37:40 UTC (rev 12006) +++ trunk/x10.runtime/src-x10/x10/lang/Dist.x10 2009-11-12 04:41:51 UTC (rev 12007) @@ -46,7 +46,7 @@ * point in the region to every place. */ - public static def makeUnique(): Dist(1) = BaseDist.makeUnique1(); + public static def makeUnique(): Dist(1){rect} = BaseDist.makeUnique1(); /** * Returns a distribution over the specified region that maps This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-13 20:36:46
|
Revision: 12051 http://x10.svn.sourceforge.net/x10/?rev=12051&view=rev Author: ipeshansky Date: 2009-11-13 20:36:36 +0000 (Fri, 13 Nov 2009) Log Message: ----------- Add deallocation of closures that used to be async bodies before desugaring. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-13 20:02:57 UTC (rev 12050) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-11-13 20:36:36 UTC (rev 12051) @@ -386,6 +386,9 @@ synth.toBlock(body), xContext()); exprs.add(closure); types.add(closure.closureDef().asType()); + Expr free = (Expr) xnf.BooleanLit(pos, true).typeCheck(this); + exprs.add(free); + types.add(free.type()); Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), RUN_ASYNC, exprs, xts.Void(), types, xContext())); Modified: trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-11-13 20:02:57 UTC (rev 12050) +++ trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-11-13 20:36:36 UTC (rev 12051) @@ -14,9 +14,18 @@ * @author tardieu */ class Activity { + /** + * the finish state governing the execution of this activity + */ val finishState:FinishState!; + /** + * safe to run pending jobs while waiting for a finish (temporary) + */ val safe:Boolean; - // the finish state governing the execution of this activity + /** + * whether to dealloc the body after executing it + */ + private val free:Boolean; /** * The user-specified code for this activity. @@ -35,17 +44,25 @@ */ var finishStack:Stack[FinishState!]!; - /** - * Create activity. - */ + /** + * Create activity. + */ def this(body:()=>Void, finishState:FinishState!, safe:Boolean) { - this.finishState = finishState; - this.safe = safe; + this(body, finishState, safe, false); + } + + /** + * Create activity. + */ + def this(body:()=>Void, finishState:FinishState!, safe:Boolean, free:Boolean) { + this.finishState = finishState; + this.safe = safe; finishState.incr(); this.body = body; + this.free = free; } - /** + /** * Create clocked activity. */ def this(body:()=>Void, finishState:FinishState{self.at(here)}, clocks:ValRail[Clock], phases:ValRail[Int]) { @@ -66,6 +83,7 @@ } if (null != clockPhases) clockPhases.drop(); finishState.notifySubActivityTermination(); + if (free) NativeRuntime.dealloc(body); } // [DC] The correct thing to do here is do toString() on the closure Modified: trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-11-13 20:02:57 UTC (rev 12050) +++ trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-11-13 20:36:36 UTC (rev 12051) @@ -137,23 +137,40 @@ } public static def runAsync(place:Place, body:()=>Void):Void { + runAsync(place, body, false); + } + + public static def runAsync(place:Place, body:()=>Void, free:Boolean):Void { val state = currentState(); state.notifySubActivitySpawn(place); val ok = safe(); if (place.id == Thread.currentThread().locInt()) { - execute(new Activity(body, state, ok)); + execute(new Activity(body, state, ok, free)); } else { runtime().finishStates.put(state); val rid = state.rid(); + var closure:()=>Void; +// val closure = +// ok ? (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)) +// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false))) +// : (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)) +// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false))); + // Workaround for XTENLANG_614 if (ok) { - val closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true)); - NativeRuntime.runAt(place.id, closure); - NativeRuntime.dealloc(closure); + if (free) { + closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)); + } else { + closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false)); + } } else { - val closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false)); - NativeRuntime.runAt(place.id, closure); - NativeRuntime.dealloc(closure); + if (free) { + closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)); + } else { + closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false)); + } } + NativeRuntime.runAt(place.id, closure); + NativeRuntime.dealloc(closure); } } @@ -165,9 +182,13 @@ } public static def runAsync(body:()=>Void):Void { + runAsync(body, false); + } + + public static def runAsync(body:()=>Void, free:Boolean):Void { val state = currentState(); state.notifySubActivitySpawn(here); - execute(new Activity(body, state, safe())); + execute(new Activity(body, state, safe(), free)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-15 08:27:27
|
Revision: 12054 http://x10.svn.sourceforge.net/x10/?rev=12054&view=rev Author: sparksparkspark Date: 2009-11-15 08:27:16 +0000 (Sun, 15 Nov 2009) Log Message: ----------- Implement CUDA kernels Various cleanups Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/ast/X10CPPDelFactory_c.java trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java trunk/x10.compiler/src/x10cuda/ExtensionInfo.java trunk/x10.compiler/src/x10cuda/types/SharedMem.java trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_types.h trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 Modified: trunk/x10.compiler/src/x10cpp/ast/X10CPPDelFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10cpp/ast/X10CPPDelFactory_c.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/ast/X10CPPDelFactory_c.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -50,7 +50,6 @@ w.write(ext.comment()); } makeCodeGenerator(w, tr).visitAppropriate(jl()); - } }; Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -56,7 +56,7 @@ } protected static final String PLATFORM = System.getenv("X10_PLATFORM")==null?"unknown":System.getenv("X10_PLATFORM"); - protected static final String X10_DIST = System.getenv("X10_DIST"); + public static final String X10_DIST = System.getenv("X10_DIST"); protected static final String X10GC = System.getenv("X10GC").replace(File.separatorChar, '/'); protected static final boolean USE_XLC = PLATFORM.startsWith("aix_") && System.getenv("USE_GCC")==null; @@ -98,7 +98,11 @@ /** Add the arguments that go before the output files */ protected void addPreArgs(ArrayList<String> cxxCmd) { cxxCmd.add("-g"); - cxxCmd.add("-I"+X10_DIST+"/include"); // dist + + // prebuilt XRX + cxxCmd.add("-I"+X10_DIST+"/include"); + + // headers generated from user input cxxCmd.add("-I."); if (!Configuration.DISABLE_GC && gcEnabled()) { @@ -129,10 +133,10 @@ cxxCmd.add(X10GC+"/lib/libgc.a"); } - cxxCmd.add("-L"+X10_DIST+"/lib"); // dist + // prebuilt XRX + cxxCmd.add("-L"+X10_DIST+"/lib"); cxxCmd.add("-lx10"); - cxxCmd.add("-L"+X10_DIST+"/../pgas2/common/work/lib"); // temporary cxxCmd.addAll(x10rtOpts.ldFlags); cxxCmd.addAll(x10rtOpts.libs); @@ -205,6 +209,7 @@ file = file.replace(File.separatorChar,'/'); if (exclude.contains(file)) continue; + if (file.endsWith(".cu")) continue; cxxCmd.add(file); } Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -362,7 +362,7 @@ } - void printTemplateSignature(List<Type> list, CodeWriter h) { + public void printTemplateSignature(List<Type> list, CodeWriter h) { int size = list.size(); if (size != 0) { h.write("template<class "); Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -3993,39 +3993,8 @@ inc.write("return "+SERIALIZATION_ID_FIELD+";"); inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); - inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf, x10aux::addr_map& m) {"); - inc.newline(4); inc.begin(0); - // FIXME: factor out this loop - for (int i = 0; i < c.variables.size(); i++) { - if (i > 0) inc.newline(); - VarInstance var = (VarInstance) c.variables.get(i); - String name = var.name().toString(); - if (name.equals(THIS)) - name = SAVED_THIS; - else name = mangled_non_method_name(name); - inc.write("buf.write(this->" + name + ", m);"); - } - inc.end(); inc.newline(); - inc.write("}"); inc.newline(); inc.forceNewline(); - - inc.write("template<class __T> static "+make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+" &buf) {"); - inc.newline(4); inc.begin(0); - inc.write(make_ref(cnamet)+" this_ = new (x10aux::alloc"+chevrons(cnamet)+"()) "+ - cnamet+"("+SERIALIZATION_MARKER+"());"); - inc.newline(); - // FIXME: factor out this loop - for (int i = 0; i < c.variables.size(); i++) { - VarInstance var = (VarInstance) c.variables.get(i); - String name = var.name().toString(); - if (name.equals(THIS)) - name = SAVED_THIS; - else name = mangled_non_method_name(name); - inc.write("this_->"+name+" = buf.read"+chevrons(Emitter.translateType(var.type(), true))+"();"); - inc.newline(); - } - inc.write("return this_;"); inc.end(); inc.newline(); - inc.write("}"); inc.newline(); inc.forceNewline(); - + generateClosureSerializationFunctions(c, cnamet, inc, n.body()); + inc.write(cname+"("+SERIALIZATION_MARKER+") { }"); inc.newline(); inc.forceNewline(); @@ -4091,15 +4060,7 @@ inc.newline(); inc.forceNewline(); */ - if (in_template_closure) - emitter.printTemplateSignature(freeTypeParams, inc); - inc.write("const x10aux::serialization_id_t "+cnamet+"::"+SERIALIZATION_ID_FIELD+" = "); - inc.newline(4); - String template = in_template_closure ? "template " : ""; - inc.write("x10aux::DeserializationDispatcher::addDeserializer("+ - cnamet+"::"+template+DESERIALIZE_METHOD+ - chevrons(Emitter.translateType(xts.Object()))+");"); - inc.newline(); inc.forceNewline(); + generateClosureDeserializationIdDef(inc, cnamet, freeTypeParams, hostClassName, n.body()); if (in_template_closure) { String guard = getHeaderGuard(cname); @@ -4150,8 +4111,58 @@ emitter.exitClosure(c); } + protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { + inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf, x10aux::addr_map& m) {"); + inc.newline(4); inc.begin(0); + // FIXME: factor out this loop + for (int i = 0; i < c.variables.size(); i++) { + if (i > 0) inc.newline(); + VarInstance var = (VarInstance) c.variables.get(i); + String name = var.name().toString(); + if (name.equals(THIS)) + name = SAVED_THIS; + else name = mangled_non_method_name(name); + inc.write("buf.write(this->" + name + ", m);"); + } + inc.end(); inc.newline(); + inc.write("}"); inc.newline(); inc.forceNewline(); - /** + inc.write("template<class __T> static "+make_ref("__T")+" "+DESERIALIZE_METHOD+"("+DESERIALIZATION_BUFFER+" &buf) {"); + inc.newline(4); inc.begin(0); + inc.write(make_ref(cnamet)+" this_ = new (x10aux::alloc"+chevrons(cnamet)+"()) "+ + cnamet+"("+SERIALIZATION_MARKER+"());"); + inc.newline(); + // FIXME: factor out this loop + for (int i = 0; i < c.variables.size(); i++) { + VarInstance var = (VarInstance) c.variables.get(i); + String name = var.name().toString(); + if (name.equals(THIS)) + name = SAVED_THIS; + else name = mangled_non_method_name(name); + inc.write("this_->"+name+" = buf.read"+chevrons(Emitter.translateType(var.type(), true))+"();"); + inc.newline(); + } + inc.write("return this_;"); inc.end(); inc.newline(); + inc.write("}"); inc.newline(); inc.forceNewline(); + } + + + protected void generateClosureDeserializationIdDef(StreamWrapper inc, String cnamet, List<Type> freeTypeParams, String hostClassName, Block block) { + X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); + boolean in_template_closure = freeTypeParams.size()>0; + if (in_template_closure) + emitter.printTemplateSignature(freeTypeParams, inc); + inc.write("const x10aux::serialization_id_t "+cnamet+"::"+SERIALIZATION_ID_FIELD+" = "); + inc.newline(4); + String template = in_template_closure ? "template " : ""; + inc.write("x10aux::DeserializationDispatcher::addDeserializer("+ + cnamet+"::"+template+DESERIALIZE_METHOD+ + chevrons(Emitter.translateType(xts.Object()))+");"); + inc.newline(); inc.forceNewline(); + } + + + /** * Rewrites a given closure so that it has exactly one return statement at the end. * @author igor * TODO: factor out into its own class Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -68,16 +68,17 @@ static final String INSTANCE_INIT = "_instance_init"; // instance field initialisers static final String CONSTRUCTOR = "_constructor"; static final String MAKE = "_make"; - static final String SERIALIZATION_ID_FIELD = "_serialization_id"; - static final String SERIALIZATION_MARKER = "x10aux::SERIALIZATION_MARKER"; - static final String SERIALIZATION_BUFFER = "x10aux::serialization_buffer"; + public static final String SERIALIZATION_ID_FIELD = "_serialization_id"; + public static final String SERIALIZATION_MARKER = "x10aux::SERIALIZATION_MARKER"; + public static final String SERIALIZATION_BUFFER = "x10aux::serialization_buffer"; static final String SERIALIZE_METHOD = "_serialize"; static final String SERIALIZE_ID_METHOD = "_get_serialization_id"; - static final String SERIALIZE_BODY_METHOD = "_serialize_body"; - static final String DESERIALIZATION_BUFFER = "x10aux::deserialization_buffer"; - static final String DESERIALIZE_METHOD = "_deserialize"; + public static final String SERIALIZE_BODY_METHOD = "_serialize_body"; + public static final String DESERIALIZATION_BUFFER = "x10aux::deserialization_buffer"; + public static final String DESERIALIZE_METHOD = "_deserialize"; static final String DESERIALIZER_METHOD = "_deserializer"; - static final String DESERIALIZE_BODY_METHOD = "_deserialize_body"; + static final String DESERIALIZE_BODY_METHOD = "_deserialize_body"; + public static final String DESERIALIZE_CUDA_METHOD = "_deserialize_cuda"; static final String STRUCT_EQUALS = "x10aux::struct_equals"; static final String STRUCT_EQUALS_METHOD = "_struct_equals"; @@ -90,7 +91,7 @@ return "<" + type + (type.endsWith(">")?" ":"")+">"; } - static String make_ref(String type) { + public static String make_ref(String type) { if (refsAsPointers) return type+"*"; return "x10aux::ref"+chevrons(type); Modified: trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cpp/visit/X10CPPTranslator.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -469,65 +469,71 @@ CXXCommandBuilder ccb = CXXCommandBuilder.getCXXCommandBuilder(options, eq); String[] cxxCmd = ccb.buildCXXCommandLine(outputFiles); - if (Report.should_report(postcompile, 1)) { - StringBuffer cmdStr = new StringBuffer(); - for (int i = 0; i < cxxCmd.length; i++) - cmdStr.append(cxxCmd[i]+" "); - Report.report(1, "Executing post-compiler " + cmdStr); - } + if (!doPostCompile(options, eq, outputFiles, cxxCmd)) return false; + + // FIXME: [IP] HACK: Prevent the java post-compiler from running + options.post_compiler = null; + } + return true; + } - try { - Runtime runtime = Runtime.getRuntime(); - Process proc = runtime.exec(cxxCmd, null, options.output_directory); + public static boolean doPostCompile(Options options, ErrorQueue eq, Collection<String> outputFiles, String[] cxxCmd) { + if (Report.should_report(postcompile, 1)) { + StringBuffer cmdStr = new StringBuffer(); + for (int i = 0; i < cxxCmd.length; i++) + cmdStr.append(cxxCmd[i]+" "); + Report.report(1, "Executing post-compiler " + cmdStr); + } - InputStreamReader err = new InputStreamReader(proc.getErrorStream()); + try { + Runtime runtime = Runtime.getRuntime(); + Process proc = runtime.exec(cxxCmd, null, options.output_directory); - String output = null; - try { - char[] c = new char[72]; - int len; - StringBuffer sb = new StringBuffer(); - while((len = err.read(c)) > 0) { - sb.append(String.valueOf(c, 0, len)); - } + InputStreamReader err = new InputStreamReader(proc.getErrorStream()); - if (sb.length() != 0) { - output = sb.toString(); - } - } - finally { - err.close(); - } + String output = null; + try { + char[] c = new char[72]; + int len; + StringBuffer sb = new StringBuffer(); + while((len = err.read(c)) > 0) { + sb.append(String.valueOf(c, 0, len)); + } - proc.waitFor(); + if (sb.length() != 0) { + output = sb.toString(); + } + } + finally { + err.close(); + } - if (!options.keep_output_files) { - String[] rmCmd = new String[1+outputFiles.size()]; - rmCmd[0] = "rm"; - Iterator<String> iter = outputFiles.iterator(); - for (int i = 1; iter.hasNext(); i++) - rmCmd[i] = iter.next(); - runtime.exec(rmCmd); - } + proc.waitFor(); - if (output != null) - eq.enqueue(proc.exitValue() > 0 ? ErrorInfo.POST_COMPILER_ERROR : ErrorInfo.WARNING, output); - if (proc.exitValue() > 0) { - eq.enqueue(ErrorInfo.POST_COMPILER_ERROR, - "Non-zero return code: " + proc.exitValue()); - return false; - } - } - catch(Exception e) { - eq.enqueue(ErrorInfo.POST_COMPILER_ERROR, e.getMessage() != null ? e.getMessage() : e.toString()); - return false; - } - // FIXME: [IP] HACK: Prevent the java post-compiler from running - options.post_compiler = null; - } - return true; - } + if (!options.keep_output_files) { + String[] rmCmd = new String[1+outputFiles.size()]; + rmCmd[0] = "rm"; + Iterator<String> iter = outputFiles.iterator(); + for (int i = 1; iter.hasNext(); i++) + rmCmd[i] = iter.next(); + runtime.exec(rmCmd); + } + if (output != null) + eq.enqueue(proc.exitValue() > 0 ? ErrorInfo.POST_COMPILER_ERROR : ErrorInfo.WARNING, output); + if (proc.exitValue() > 0) { + eq.enqueue(ErrorInfo.POST_COMPILER_ERROR, + "Non-zero return code: " + proc.exitValue()); + return false; + } + } + catch(Exception e) { + eq.enqueue(ErrorInfo.POST_COMPILER_ERROR, e.getMessage() != null ? e.getMessage() : e.toString()); + return false; + } + return true; + } + private boolean translateSourceCollection(SourceCollection sc) { boolean okay = true; Modified: trunk/x10.compiler/src/x10cuda/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10cuda/ExtensionInfo.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cuda/ExtensionInfo.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -7,11 +7,20 @@ package x10cuda; import polyglot.ast.NodeFactory; +import polyglot.frontend.Compiler; +import polyglot.frontend.Goal; +import polyglot.frontend.Scheduler; +import polyglot.main.Options; import polyglot.types.TypeSystem; +import polyglot.util.ErrorQueue; +import polyglot.visit.PostCompiled; import x10.ast.X10NodeFactory_c; +import x10cpp.ExtensionInfo.X10CPPScheduler; import x10cpp.ast.X10CPPExtFactory_c; +import x10cpp.visit.X10CPPTranslator; import x10cuda.ast.X10CUDADelFactory_c; import x10cuda.types.X10CUDATypeSystem_c; +import x10cuda.visit.CUDACodeGenerator; /** @@ -28,6 +37,25 @@ return new X10CUDATypeSystem_c(); } + protected Scheduler createScheduler() { + return new X10CUDAScheduler(this); + } + + public static class X10CUDAScheduler extends X10CPPScheduler { + protected X10CUDAScheduler(ExtensionInfo extInfo) { + super(extInfo); + } + protected Goal PostCompiled() { + return new PostCompiled(extInfo) { + protected boolean invokePostCompiler(Options options, Compiler compiler, ErrorQueue eq) { + if (System.getProperty("x10.postcompile", "TRUE").equals("FALSE")) + return true; + // use & to avoid short-circuit + return CUDACodeGenerator.postCompile(options, compiler, eq) & X10CPPTranslator.postCompile(options, compiler, eq); + } + }.intern(this); + } + } } // vim:tabstop=4:shiftwidth=4:expandtab \ No newline at end of file Modified: trunk/x10.compiler/src/x10cuda/types/SharedMem.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -1,12 +1,14 @@ package x10cuda.types; import java.util.ArrayList; +import java.util.Iterator; import polyglot.ast.Expr; import polyglot.ast.LocalDecl; import polyglot.types.Name; import polyglot.types.Type; import x10.types.X10TypeSystem; +import x10.util.ClassifiedStream; public class SharedMem { @@ -22,6 +24,8 @@ return bytes.longValue(); } public Decl (LocalDecl ast) { this.ast = ast; } + abstract public void generateDef(ClassifiedStream out, String offset); + abstract public void generateInit(ClassifiedStream out, String offset); } private static class Rail extends Decl { @@ -35,9 +39,23 @@ this.numElements = numElements; this.init = init; } + public void generateDef(ClassifiedStream out, String offset) { + String name = ast.name().id().toString(); + out.write("float *"+name+" = (float*) &__shm["+offset+"];"); out.newline(); + } + public void generateInit(ClassifiedStream out, String offset) { + out.write("for (int i=0 ; i<CLUSTERS*4 ; ++i) {"); out.newline(4); out.begin(0); + out.write("clustercache[i] = /**/local_clusters[i]/**/;"); out.newline(); + out.end(); out.newline(); + out.write("}"); + } } private static class Var extends Decl { public Var (LocalDecl ast) { super(ast); } + public void generateDef(ClassifiedStream out, String offset) { + } + public void generateInit(ClassifiedStream out, String offset) { + } } public void addRail(LocalDecl ast, Expr numElements, Expr init) { @@ -56,6 +74,30 @@ } return false; } - - + + public void generateCode(ClassifiedStream out) { + if (decls.size()==0) return; + + out.write("// shm"); + out.newline(); + + for (SharedMem.Decl d : decls) { + String offset = "0"; + d.generateDef(out, offset); + out.write("if (threadIdx.x == 0) {"); out.newline(4); out.begin(0); + d.generateInit(out, offset); + out.end(); out.newline(); + out.write("}"); out.newline(); + } + + out.write("__syncthreads();"); out.newline(); + out.forceNewline(); + + + /* + * float *new_clusterv = (float*) dyn_shm; // [DIM*clusterc_odd] int + * *new_counterv = (int*)&new_clusterv[DIM*clusterc_odd]; // [clusterc] + */ + + } } Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -17,6 +17,7 @@ import java.util.ArrayList; import polyglot.ast.Formal; +import polyglot.frontend.Job; import x10.ast.Closure_c; import x10cpp.types.X10CPPContext_c; import polyglot.types.Name; @@ -31,10 +32,14 @@ super(ts); } - private Closure_c wrappingClosure; - public Closure_c wrappingClosure() { return wrappingClosure; } - public void wrappingClosure(Closure_c v) { wrappingClosure = v; } + private String wrappingClosure; + public String wrappingClosure() { return wrappingClosure; } + public void wrappingClosure(String v) { wrappingClosure = v; } + private String wrappingClass; + public String wrappingClass() { return wrappingClass; } + public void wrappingClass(String v) { wrappingClass = v; } + private boolean generatingKernel; public boolean generatingKernel() { return generatingKernel; } public void generatingKernel(boolean v) { generatingKernel = v; } @@ -63,9 +68,10 @@ private ClassifiedStream cudaStream = null; - public ClassifiedStream cudaStream (StreamWrapper sw) { + public ClassifiedStream cudaStream (StreamWrapper sw, Job j) { if (cudaStream==null) { cudaStream = sw.getNewStream("cu"); + j.compiler().outputFiles().add(wrappingClass()+".cu"); cudaStream.write("#include <x10aux/config.h>"); cudaStream.newline(); cudaStream.write("#include <cfloat>"); cudaStream.newline(); cudaStream.forceNewline(); Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-15 08:27:16 UTC (rev 12054) @@ -13,10 +13,25 @@ package x10cuda.visit; +import static x10cpp.visit.Emitter.mangled_non_method_name; import static x10cpp.visit.SharedVarsMethods.CUDA_NATIVE_STRING; import static x10cpp.visit.SharedVarsMethods.CPP_NATIVE_STRING; +import static x10cpp.visit.SharedVarsMethods.DESERIALIZATION_BUFFER; +import static x10cpp.visit.SharedVarsMethods.DESERIALIZE_METHOD; +import static x10cpp.visit.SharedVarsMethods.SERIALIZATION_BUFFER; +import static x10cpp.visit.SharedVarsMethods.SERIALIZATION_ID_FIELD; +import static x10cpp.visit.SharedVarsMethods.SERIALIZATION_MARKER; +import static x10cpp.visit.SharedVarsMethods.SERIALIZE_BODY_METHOD; import static x10cpp.visit.SharedVarsMethods.THIS; import static x10cpp.visit.SharedVarsMethods.SAVED_THIS; +import static x10cpp.visit.SharedVarsMethods.chevrons; +import static x10cpp.visit.SharedVarsMethods.make_ref; + +import java.io.InputStreamReader; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + import polyglot.ast.ArrayInit_c; import polyglot.ast.Assert_c; import polyglot.ast.Assign_c; @@ -75,6 +90,7 @@ import polyglot.ast.TypeNode; import polyglot.ast.Unary_c; import polyglot.ast.While_c; +import polyglot.frontend.Compiler; import x10.ast.AssignPropertyBody_c; import x10.ast.Await_c; import x10.ast.Closure; @@ -104,18 +120,27 @@ import x10.ast.X10Unary_c; import x10.extension.X10Ext; import x10.types.ConstrainedType; +import x10.types.X10ClassDef; import x10.types.X10ClassType; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10cpp.postcompiler.CXXCommandBuilder; +import x10cpp.types.X10CPPContext_c; import x10cpp.visit.Emitter; import x10cpp.visit.MessagePassingCodeGenerator; +import x10cpp.visit.SharedVarsMethods; +import x10cpp.visit.X10CPPTranslator; import x10cuda.types.SharedMem; import x10cuda.types.X10CUDAContext_c; +import polyglot.main.Options; +import polyglot.main.Report; import polyglot.types.Name; import polyglot.types.QName; import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.VarInstance; +import polyglot.util.ErrorInfo; +import polyglot.util.ErrorQueue; import polyglot.visit.Translator; import x10.util.ClassifiedStream; import x10.util.StreamWrapper; @@ -150,7 +175,7 @@ // defer to CUDAContext.cudaStream() private ClassifiedStream cudaStream() { - return context().cudaStream(sw); + return context().cudaStream(sw, tr.job()); } private boolean generatingKernel() { @@ -182,7 +207,7 @@ private Type railCargo(Type typ) { if (!xts().isRail(typ) && !xts().isValRail(typ)) { - System.out.println("type: "+typ+" is not a rail"); + //System.out.println("type: "+typ+" is not a rail"); return null; } typ = typ.toClass(); @@ -215,14 +240,40 @@ return type + rest; } + void generateSizeOf(StreamWrapper inc, VarInstance var) { + Type t = var.type(); + inc.write("sizeof("); + if (isIntRail(t)) { + inc.write("void *"); + } else if (isFloatRail(t)) { + inc.write("void *"); + } else { + inc.write(Emitter.translateType(t, true)); + } + inc.write(")"); + } + + void generateCudaPut(StreamWrapper inc, VarInstance var) { + inc.write("x10aux::cuda_put(gpu, env, off, "); + + Type t = var.type(); + String name = var.name().toString(); + + if (isIntRail(t)) { + inc.write("(void*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else if (isFloatRail(t)) { + inc.write("(void*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else { + inc.write("this_->"+name); + } + inc.write(");"); + inc.newline(); + } + void handleKernel(Block_c b) { - X10ClassType hostClassType = (X10ClassType) context().wrappingClosure() - .closureDef().typeContainer().get(); - String hostClassName = Emitter.translate_mangled_FQN(hostClassType - .fullName().toString(), "_"); - String kernel_name = getClosureName(hostClassName, context() - .closureId()); + String kernel_name = context().wrappingClosure(); sw.write("/* block split-compiled to cuda as " + kernel_name + " */ "); + System.out.println("Kernel: "+kernel_name); ClassifiedStream out = cudaStream(); @@ -278,34 +329,11 @@ out.end(); out.newline(); out.write("}"); out.newline(); out.write("__syncthreads();"); out.newline(); + out.forceNewline(); - out.forceNewline(); - // shm - out.write("// shm"); - out.newline(); - // FIXME: HACK! HACK! HACK! - out.write("float *clustercache = (float*) __shm;"); out.newline(); out.forceNewline(); - out.write("if (threadIdx.x == 0) {"); out.newline(4); out.begin(0); - out.write("for (int i=0 ; i<CLUSTERS*4 ; ++i) {"); out.newline(4); out.begin(0); - out.write("clustercache[i] = /**/local_clusters[i]/**/;"); out.newline(); - out.end(); out.newline(); - out.write("}"); - out.end(); out.newline(); - out.write("}"); out.newline(); + context().shm().generateCode(out); - // TODO: in general, do this: - /* - * for (context().shm()) { out.write(); } - */ - /* - * float *new_clusterv = (float*) dyn_shm; // [DIM*clusterc_odd] int - * *new_counterv = (int*)&new_clusterv[DIM*clusterc_odd]; // [clusterc] - */ - out.write("__syncthreads();"); out.newline(); - - out.forceNewline(); - // body sw.pushCurrentStream(out); super.visit(b); @@ -361,32 +389,38 @@ protected MultipleValues processLoop(For loop) { MultipleValues r = new MultipleValues(); - assert loop.inits().size() == 1; + assert loop.inits().size() == 2 : loop.inits(); ForInit i_ = loop.inits().get(0); assert i_ instanceof LocalDecl : i_.getClass(); LocalDecl i = (LocalDecl) i_; + ForInit j_ = loop.inits().get(1); + assert j_ instanceof LocalDecl : j_.getClass(); + LocalDecl j = (LocalDecl) j_; assert loop.cond() instanceof Binary : loop.cond().getClass(); Binary cond = (Binary) loop.cond(); assert cond.operator() == Binary.LE : cond.operator(); assert cond.left() instanceof Local : cond.left().getClass(); Local cond_left = (Local) cond.left(); assert cond_left.name().id() == i.name().id() : cond_left; + assert cond.right() instanceof Local : cond.right().getClass(); + Local cond_right = (Local) cond.right(); + assert cond_right.name().id() == j.name().id() : cond_right; Expr from_ = i.init(); - Expr to_ = cond.right(); - assert from_ instanceof IntLit; // FIXME: proper error - assert to_ instanceof IntLit; // FIXME: proper error + Expr to_ = j.init(); + assert from_ instanceof IntLit : from_.getClass(); // FIXME: proper error + assert to_ instanceof IntLit : to_.getClass(); // FIXME: proper error IntLit from = (IntLit) from_; IntLit to = (IntLit) to_; - assert from.value() == 0; // FIXME: proper error + assert from.value() == 0 : from.value(); // FIXME: proper error r.iterations = to.value() + 1; assert loop.body() instanceof Block : loop.body().getClass(); Block block = (Block) loop.body(); - assert block.statements().size() == 2; + assert block.statements().size() == 2 : block.statements(); Stmt first = block.statements().get(0); assert first instanceof LocalDecl : first.getClass(); LocalDecl real_var = (LocalDecl) first; Stmt second = block.statements().get(1); - assert second instanceof Block; + assert second instanceof Block : second.getClass(); r.body = (Block) second; r.var = real_var.name().id(); return r; @@ -428,13 +462,10 @@ X10Call_c init_call = (X10Call_c) init_expr; // TODO: makeVal too Receiver init_call_target = init_call.target(); - assert init_call_target instanceof CanonicalTypeNode; // FIXME: - // proper - // error + assert init_call_target instanceof CanonicalTypeNode; // FIXME: proper error CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; assert init_call_target_node.nameString().equals("Rail"); - assert init_call.name().toString().equals("makeVar") : init_call - .name(); // FIXME: proper error + assert init_call.name().toString().equals("makeVar") : init_call.name(); // FIXME: proper error assert init_call.typeArguments().size() == 1; TypeNode rail_type_arg_node = init_call.typeArguments().get(0); Type rail_type_arg = rail_type_arg_node.type(); @@ -443,7 +474,6 @@ assert init_call.arguments().size() == 2; Expr num_elements = init_call.arguments().get(0); Expr rail_init_closure = init_call.arguments().get(1); - shm.addRail(ld, num_elements, rail_init_closure); } @@ -468,7 +498,7 @@ assert async_target_type_node.nameString().equals("Runtime"); // FIXME: // proper // error - assert async_call.arguments().size() == 1 : async_call.arguments(); // FIXME: + assert async_call.arguments().size() == 2 : async_call.arguments(); // FIXME: // proper // error Expr async_arg = async_call.arguments().get(0); @@ -487,12 +517,82 @@ } public void visit(Closure_c n) { - Closure_c last = context().wrappingClosure(); - context().wrappingClosure(n); + String last = context().wrappingClosure(); + String lastHostClassName = context().wrappingClass(); + X10ClassType hostClassType = (X10ClassType) n.closureDef().typeContainer().get(); + String nextHostClassName = Emitter.translate_mangled_FQN(hostClassType.fullName().toString(), "_"); + String next = getClosureName(nextHostClassName, context().closureId()+1); + //System.out.println(last+" goes to "+next); + context().wrappingClosure(next); + context().wrappingClass(nextHostClassName); super.visit(n); context().wrappingClosure(last); + context().wrappingClass(lastHostClassName); + //System.out.println("back to "+last); } + + protected void generateClosureDeserializationIdDef(StreamWrapper inc, String cnamet, List<Type> freeTypeParams, String hostClassName, Block block) { + if (nodeHasCudaAnnotation(block)) { + + X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); + boolean in_template_closure = freeTypeParams.size()>0; + if (in_template_closure) + emitter.printTemplateSignature(freeTypeParams, inc); + inc.write("const x10aux::serialization_id_t "+cnamet+"::"+SharedVarsMethods.SERIALIZATION_ID_FIELD+" = "); + inc.newline(4); + String template = in_template_closure ? "template " : ""; + inc.write("x10aux::DeserializationDispatcher::addDeserializer("+ + cnamet+"::"+template+SharedVarsMethods.DESERIALIZE_METHOD+ + chevrons(Emitter.translateType(xts.Object()))+", true, "+ + cnamet+"::"+template+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+", "+ + "\""+hostClassName+".cubin\", \""+cnamet+"\");"); + inc.newline(); inc.forceNewline(); + } else { + super.generateClosureDeserializationIdDef(inc, cnamet, freeTypeParams, hostClassName, block); + } + } + + protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { + super.generateClosureSerializationFunctions(c, cnamet, inc, block); + + if (nodeHasCudaAnnotation(block)) { + + inc.write("static x10_ulong "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &buf, x10aux::place gpu, size_t &blocks, size_t &threads, size_t &shm) {"); + inc.newline(4); inc.begin(0); + + inc.write(make_ref(cnamet)+" this_ = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(buf);"); + inc.newline(); + + inc.write("blocks = 8;"); inc.newline(); + inc.write("threads = 64;"); inc.newline(); + inc.write("shm = 0;"); inc.newline(); + + inc.write("size_t sz = 0"); //sizeof(this_->len) + sizeof(void*);"); + // FIXME: factor out this loop + for (int i = 0; i < c.variables.size(); i++) { + inc.write(" + "); + VarInstance var = (VarInstance) c.variables.get(i); + generateSizeOf(inc, var); + } + inc.write(";"); inc.newline(); + + + inc.write("x10_ulong env = x10aux::remote_alloc(gpu, sz);"); inc.newline(); + inc.write("size_t off = 0;"); inc.newline(); + + // FIXME: factor out this loop + for (int i = 0; i < c.variables.size(); i++) { + VarInstance var = (VarInstance) c.variables.get(i); + generateCudaPut(inc, var); + } + + inc.write("assert(off==sz);"); inc.newline(); + inc.write("return env;"); inc.end(); inc.newline(); + inc.write("}"); inc.newline(); inc.forceNewline(); + } + } + public void visit(New_c n) { assert !generatingKernel() : "New not allowed in @Cudable code."; super.visit(n); @@ -875,6 +975,23 @@ super.visit(n); } + public static boolean postCompile(Options options, Compiler compiler, ErrorQueue eq) { + // TODO Auto-generated method stub + if (options.post_compiler != null && !options.output_stdout) { + Collection<String> outputFiles = compiler.outputFiles(); + String[] nvccCmd = { "nvcc", "--cubin", "-I"+CXXCommandBuilder.X10_DIST+"/include", null }; + for (String f : outputFiles) { + if (f.endsWith(".cu")) { + nvccCmd[3] = f; + if (!X10CPPTranslator.doPostCompile(options, eq, outputFiles, nvccCmd)) return false; + } + } + + } + + return true; + } + } // end of CUDACodeGenerator // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-11-15 08:27:16 UTC (rev 12054) @@ -23,11 +23,15 @@ return buf; } -serialization_id_t DeserializationDispatcher::addDeserializer (Deserializer deser, bool is_async) { +serialization_id_t DeserializationDispatcher::addDeserializer (Deserializer deser, bool is_async, + CudaPre cuda_pre, + const char *cubin, + const char *kernel) +{ if (NULL == it) { it = new (alloc<DeserializationDispatcher>()) DeserializationDispatcher(); } - return it->addDeserializer_(deser, is_async); + return it->addDeserializer_(deser, is_async, cuda_pre, cubin, kernel); } static void ensure_data_size (DeserializationDispatcher::Data *&data_v, @@ -39,7 +43,12 @@ data_c = newsz; } -serialization_id_t DeserializationDispatcher::addDeserializer_ (Deserializer deser, bool is_async) { +serialization_id_t DeserializationDispatcher::addDeserializer_ (Deserializer deser, bool is_async, + CudaPre cuda_pre, + const char *cubin, + const char *kernel) +{ + is_async = true; // FIXME: x10 compiler backend should give us this info // grow slowly as this is init phase and we don't want to take // up RAM unnecessarily ensure_data_size(data_v, next_id+1, data_c); @@ -47,14 +56,24 @@ _S_("DeserializationDispatcher registered the following handler for id: " <<r<<": "<<std::hex<<(size_t)deser<<std::dec); data_v[r].deser = deser; - data_v[r].has_mt = true; //is_async; + data_v[r].has_mt = is_async; + data_v[r].cuda_pre = cuda_pre; + data_v[r].cubin = cubin; + data_v[r].kernel = kernel; return r; } +CudaPre DeserializationDispatcher::getCudaPre_(serialization_id_t id) +{ return data_v[id].cuda_pre; } + + + + serialization_id_t DeserializationDispatcher::addPutFunctions (BufferFinder bfinder, Notifier notifier, BufferFinder cuda_bfinder, - Notifier cuda_notifier) { + Notifier cuda_notifier) +{ if (NULL == it) { it = new (alloc<DeserializationDispatcher>()) DeserializationDispatcher(); } @@ -64,7 +83,8 @@ serialization_id_t DeserializationDispatcher::addPutFunctions_ (BufferFinder bfinder, Notifier notifier, BufferFinder cuda_bfinder, - Notifier cuda_notifier) { + Notifier cuda_notifier) +{ ensure_data_size(data_v, next_id+1, data_c); serialization_id_t r = next_id++; _S_("DeserializationDispatcher registered the following put handler for id: " @@ -77,21 +97,17 @@ return r; } -BufferFinder DeserializationDispatcher::getPutBufferFinder_ (serialization_id_t id) { - return data_v[id].put_bfinder; -} +BufferFinder DeserializationDispatcher::getPutBufferFinder_ (serialization_id_t id) +{ return data_v[id].put_bfinder; } -Notifier DeserializationDispatcher::getPutNotifier_ (serialization_id_t id) { - return data_v[id].put_notifier; -} +Notifier DeserializationDispatcher::getPutNotifier_ (serialization_id_t id) +{ return data_v[id].put_notifier; } -BufferFinder DeserializationDispatcher::getCudaPutBufferFinder_ (serialization_id_t id) { - return data_v[id].cuda_put_bfinder; -} +BufferFinder DeserializationDispatcher::getCudaPutBufferFinder_ (serialization_id_t id) +{ return data_v[id].cuda_put_bfinder; } -Notifier DeserializationDispatcher::getCudaPutNotifier_ (serialization_id_t id) { - return data_v[id].cuda_put_notifier; -} +Notifier DeserializationDispatcher::getCudaPutNotifier_ (serialization_id_t id) +{ return data_v[id].cuda_put_notifier; } serialization_id_t DeserializationDispatcher::addGetFunctions (BufferFinder bfinder, Notifier notifier, @@ -119,21 +135,17 @@ return r; } -BufferFinder DeserializationDispatcher::getGetBufferFinder_ (serialization_id_t id) { - return data_v[id].get_bfinder; -} +BufferFinder DeserializationDispatcher::getGetBufferFinder_ (serialization_id_t id) +{ return data_v[id].get_bfinder; } -Notifier DeserializationDispatcher::getGetNotifier_ (serialization_id_t id) { - return data_v[id].get_notifier; -} +Notifier DeserializationDispatcher::getGetNotifier_ (serialization_id_t id) +{ return data_v[id].get_notifier; } -BufferFinder DeserializationDispatcher::getCudaGetBufferFinder_ (serialization_id_t id) { - return data_v[id].cuda_get_bfinder; -} +BufferFinder DeserializationDispatcher::getCudaGetBufferFinder_ (serialization_id_t id) +{ return data_v[id].cuda_get_bfinder; } -Notifier DeserializationDispatcher::getCudaGetNotifier_ (serialization_id_t id) { - return data_v[id].cuda_get_notifier; -} +Notifier DeserializationDispatcher::getCudaGetNotifier_ (serialization_id_t id) +{ return data_v[id].cuda_get_notifier; } x10aux::msg_type DeserializationDispatcher::getMsgType_ (serialization_id_t id) { if (!data_v[id].has_mt) { @@ -161,21 +173,28 @@ void DeserializationDispatcher::registerHandlers_ () { for (size_t i=0 ; i<next_id ; ++i) { - if (data_v[i].has_mt) { + Data &d = data_v[i]; + if (d.has_mt) { msg_type id; - if (data_v[i].deser!=NULL) { - id = x10aux::register_async_handler(); + if (d.deser!=NULL) { + id = x10aux::register_async_handler(d.cubin, d.kernel); _X_("DeserializationDispatcher registered sid "<<i<<" as an async id "<<id); - } else if (data_v[i].put_bfinder!=NULL && data_v[i].put_notifier!=NULL) { + if (d.cubin) { + _X_(" cubin: "<<(d.cubin?d.cubin:"null")); + } + if (d.kernel) { + _X_(" kernel: "<<(d.kernel?d.kernel:"null")); + } + } else if (d.put_bfinder!=NULL && d.put_notifier!=NULL) { id = x10aux::register_put_handler(); _X_("DeserializationDispatcher registered sid "<<i<<" as a put id "<<id); - } else if (data_v[i].get_bfinder!=NULL && data_v[i].get_notifier!=NULL) { + } else if (d.get_bfinder!=NULL && d.get_notifier!=NULL) { id = x10aux::register_get_handler(); _X_("DeserializationDispatcher registered sid "<<i<<" as a get id "<<id); } else { continue; } - data_v[i].mt = id; + d.mt = id; ensure_data_size(data_v, id+1, data_c); data_v[id].sid = i; } Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-11-15 08:27:16 UTC (rev 12054) @@ -15,6 +15,10 @@ typedef ref<x10::lang::Ref> (*Deserializer)(deserialization_buffer &buf); template<> inline const char *typeName<Deserializer>() { return "Deserializer"; } + typedef x10_ulong (*CudaPre)(deserialization_buffer &buf, place p, + size_t &blocks, size_t &threads, size_t &shm); + template<> inline const char *typeName<CudaPre>() { return "CudaPre"; } + typedef void *(*BufferFinder)(deserialization_buffer &buf, x10_int len); template<> inline const char *typeName<BufferFinder>() { return "BufferFinder"; } @@ -37,7 +41,12 @@ Notifier cuda_put_notifier; BufferFinder cuda_get_bfinder; Notifier cuda_get_notifier; + Deserializer deser; + CudaPre cuda_pre; + const char *cubin; + const char *kernel; + bool has_mt; x10aux::msg_type mt; x10aux::serialization_id_t sid; @@ -62,9 +71,17 @@ ref<x10::lang::Ref> create_(deserialization_buffer &buf); ref<x10::lang::Ref> create_(deserialization_buffer &buf, serialization_id_t id); - static serialization_id_t addDeserializer(Deserializer deser, bool is_async=false); - serialization_id_t addDeserializer_(Deserializer deser, bool is_async); + static serialization_id_t addDeserializer (Deserializer deser, bool is_async=false, + CudaPre cuda_pre = NULL, + const char *cubin = NULL, + const char *kernel = NULL); + serialization_id_t addDeserializer_ (Deserializer deser, bool is_async, + CudaPre cuda_pre, + const char *cubin, const char *kernel); + static CudaPre getCudaPre(serialization_id_t id); + CudaPre getCudaPre_(serialization_id_t id); + static serialization_id_t addPutFunctions(BufferFinder bfinder, Notifier notifier, BufferFinder cuda_bfinder, Notifier cuda_notifier); serialization_id_t addPutFunctions_(BufferFinder bfinder, Notifier notifier, @@ -101,54 +118,48 @@ void registerHandlers_(void); }; - inline BufferFinder DeserializationDispatcher::getPutBufferFinder (serialization_id_t id) { - return it->getPutBufferFinder_(id); - } + inline CudaPre DeserializationDispatcher::getCudaPre (serialization_id_t id) + { return it->getCudaPre_(id); } - inline BufferFinder DeserializationDispatcher::getGetBufferFinder (serialization_id_t id) { - return it->getGetBufferFinder_(id); - } - inline Notifier DeserializationDispatcher::getPutNotifier (serialization_id_t id) { - return it->getPutNotifier_(id); - } + inline BufferFinder DeserializationDispatcher::getPutBufferFinder (serialization_id_t id) + { return it->getPutBufferFinder_(id); } - inline Notifier DeserializationDispatcher::getGetNotifier (serialization_id_t id) { - return it->getGetNotifier_(id); - } + inline BufferFinder DeserializationDispatcher::getGetBufferFinder (serialization_id_t id) + { return it->getGetBufferFinder_(id); } - inline BufferFinder DeserializationDispatcher::getCudaPutBufferFinder (serialization_id_t id) { - return it->getCudaPutBufferFinder_(id); - } + inline Notifier DeserializationDispatcher::getPutNotifier (serialization_id_t id) + { return it->getPutNotifier_(id); } - inline BufferFinder DeserializationDispatcher::getCudaGetBufferFinder (serialization_id_t id) { - return it->getCudaGetBufferFinder_(id); - } + inline Notifier DeserializationDispatcher::getGetNotifier (serialization_id_t id) + { return it->getGetNotifier_(id); } - inline Notifier DeserializationDispatcher::getCudaPutNotifier (serialization_id_t id) { - return it->getCudaPutNotifier_(id); - } + inline BufferFinder DeserializationDispatcher::getCudaPutBufferFinder (serialization_id_t id) + { return it->getCudaPutBufferFinder_(id); } - inline Notifier DeserializationDispatcher::getCudaGetNotifier (serialization_id_t id) { - return it->getCudaGetNotifier_(id); - } + inline BufferFinder DeserializationDispatcher::getCudaGetBufferFinder (serialization_id_t id) + { return it->getCudaGetBufferFinder_(id); } - inline x10aux::msg_type DeserializationDispatcher::getMsgType (serialization_id_t id) { - return it->getMsgType_(id); - } + inline Notifier DeserializationDispatcher::getCudaPutNotifier (serialization_id_t id) + { return it->getCudaPutNotifier_(id); } - inline serialization_id_t DeserializationDispatcher::getSerializationId (x10aux::msg_type id) { - return it->getSerializationId_(id); - } + inline Notifier DeserializationDispatcher::getCudaGetNotifier (serialization_id_t id) + { return it->getCudaGetNotifier_(id); } + + inline x10aux::msg_type DeserializationDispatcher::getMsgType (serialization_id_t id) + { return it->getMsgType_(id); } + + inline serialization_id_t DeserializationDispatcher::getSerializationId (x10aux::msg_type id) + { return it->getSerializationId_(id); } + + template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf, - serialization_id_t id) { - return static_cast<ref<T> >(it->create_(buf,id)); - } + serialization_id_t id) + { return static_cast<ref<T> >(it->create_(buf,id)); } - template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf) { - return static_cast<ref<T> >(it->create_(buf)); - } + template<class T> ref<T> DeserializationDispatcher::create(deserialization_buffer &buf) + { return static_cast<ref<T> >(it->create_(buf)); } template<> inline const char *typeName<DeserializationDispatcher>() { return "DeserializationDispatcher"; } Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-15 08:25:10 UTC (rev 12053) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-15 08:27:16 UTC (rev 12054) @@ -13,6 +13,9 @@ #include <x10/lang/VoidFun_0_0.h> #include <x10/lang/String.h> // for debug output +#include <x10/lang/Value.h> // for x10_runtime_Runtime__closure__6 +#include <x10/runtime/RID.h> + using namespace x10::lang; using namespace x10aux; @@ -28,26 +31,101 @@ volatile x10_long x10aux::serialized_bytes = 0; volatile x10_long x10aux::deserialized_bytes = 0; -void x10aux::run_at(x10aux::place place, x10aux::ref<Object> body) { +void *kernel_put_finder (const x10rt_msg_params &p, x10rt_copy_sz) +{ + x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + buf.read<x10_ulong>(); + x10_ulong remote_addr = buf.read<x10_ulong>(); + assert(buf.consumed() <= p.len); + _X_(ANSI_X10RT<<"Cuda kernel populating: "<<remote_addr<<ANSI_RESET); + return (void*)(size_t)remote_addr; +} - assert(place!=here); // this case should be handled earlier - assert(place<num_places); // this is ensured by XRX runtime +void kernel_put_notifier (const x10rt_msg_params &p, x10rt_copy_sz) +{ + x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + bool *finished = (bool*)(size_t)buf.read<x10_ulong>(); + *finished = true; +} +x10aux::msg_type x10aux::kernel_put; + +void x10aux::registration_complete (void) +{ + x10rt_registration_complete(); + x10aux::here = x10rt_here(); + x10aux::num_places = x10rt_nplaces(); + x10aux::num_hosts = x10rt_nhosts(); + x10aux::kernel_put = + x10rt_register_put_receiver(NULL, NULL, kernel_put_finder, kernel_put_notifier); + x10aux::x10rt_initialized = true; +} + +// FIXME: this is perhaps the worst hack i've ever done +struct x10_runtime_Runtime__closure__6 : x10::lang::Value { + static const x10aux::serialization_id_t _serialization_id; + x10aux::ref<x10::lang::VoidFun_0_0> body; + x10::runtime::RID rid; +}; + +void x10aux::run_at(x10aux::place p, x10aux::ref<Object> body) { + + assert(p!=here); // this case should be handled earlier + assert(p<num_places); // this is ensured by XRX runtime + serialization_buffer buf; + addr_map m; - addr_map m; + serialization_id_t sid = body->_get_serialization_id(); + msg_type id = DeserializationDispatcher::getMsgType(sid); + _X_(ANSI_BOLD<<ANSI_X10RT<<"Transmitting an async: "<<ANSI_RESET - <<ref<Object>(body)->toString()->c_str()<<" to place: "<<place); + <<ref<Object>(body)->toString()->c_str()<<" id "<<id + <<" sid "<<sid<<" to place: "<<p); - body->_serialize_body(buf, m); + if (!is_cuda(p)) { - unsigned long sz = buf.length(); - _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); - serialized_bytes += sz; asyncs_sent++; + body->_serialize_body(buf, m); - msg_type id = DeserializationDispatcher::getMsgType(body->_get_serialization_id()); - x10rt_msg_params p = {place, id, buf.steal(), sz}; - x10rt_send_msg(p); + unsigned long sz = buf.length(); + serialized_bytes += sz; asyncs_sent++; + + _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); + + x10rt_msg_params params = {p, id, buf.steal(), sz}; + x10rt_send_msg(params); + + } else { + + // FIXME: this is a hack -- we should be doing this for all asyncs + + assert (sid == x10_runtime_Runtime__closure__6::_serialization_id); + + x10aux::ref<x10_runtime_Runtime__closure__6> body_ = body; + + + x10aux::ref<x10::lang::Object> real_body = body_->body; + x10::runtime::RID rid = body_->rid; + + serialization_id_t real_sid = real_body->_get_serialization_id(); + msg_type real_id = DeserializationDispatcher::getMsgType(real_sid); + + _X_(ANSI_BOLD<<ANSI_X10RT<<"This is actually a kernel: "<<ANSI_RESET + <<ref<Object>(real_body)->toString()->c_str()<<" id "<<real_id + <<" sid "<<real_sid<<" at GPU: "<<p); + + x10::runtime::RID::_serialize(rid, buf, m); + real_body->_serialize_body(buf, m); + + unsigned long sz = buf.length(); + serialized_bytes += sz; asyncs_sent++; + + _X_(ANSI_BOLD<<ANSI_X10RT<<"async size: "<<ANSI_RESET<<sz); + + x10rt_msg_params params = {p, real_id, buf.steal(), sz}; + x10rt_send_msg(params); + + } } void x10aux::send_get (x10aux::place place, x10aux::serialization_id_t id_, @@ -98,10 +176,40 @@ x10aux::dealloc(async.operator->()); } -x10aux::msg_type x10aux::register_async_handler (void) { - return x10rt_register_msg_receiver(receive_async, NULL, NULL, NULL, NULL); +static void *cuda_pre (const x10rt_msg_params &p, size_t &blocks, size_t &threads, size_t &shm) +{ + _X_(ANSI_X10RT<<"Receiving a kernel pre callback, deserialising..."<<ANSI_RESET); + x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + buf.read<x10::runtime::RID>(); + // note: high bytes thrown away in implicit conversion + serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); + x10aux::CudaPre pre = x10aux::DeserializationDispatcher::getCudaPre(sid); + x10_ulong env = pre(buf, p.dest_place, blocks, threads, shm); + assert(buf.consumed() <= p.len); + return (void*)(size_t)env; } +static void cuda_post (const x10rt_msg_params &p, void *env) +{ + _X_(ANSI_X10RT<<"Receiving a kernel post callback, deserialising..."<<ANSI_RESET); + remote_free(p.dest_place, (x10_ulong)(size_t)env); + x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); + x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + x10aux::ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::runtime(); + x10aux::ref<x10::lang::Object> fs = rt->FMGL(finishStates)->get(rid); + (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->incr))(); + (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivityTermination))(); +} + +x10aux::msg_type x10aux::register_async_handler (const char *cubin, const char *kernel) +{ + if (cubin==NULL && kernel==NULL) { + return x10rt_register_msg_receiver(receive_async, NULL, NULL, NULL, NULL); + } else { + return x10rt_register_msg_receiver(receive_async, cuda_pre, cuda_post, cubin, kernel); + } +} + static void *receive_put (const x10rt_msg_params &p, x10aux::copy_sz len) { _X_(ANSI_X10RT<<"Receiving a put, deserialising for buffer finder..."<<ANSI_RESET); x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); @@ -202,4 +310,20 @@ cuda_receive_get, cuda_finished_get); } +void x10aux::cuda_put (place gpu, x10_ulong addr, size_t &off, void *var, size_t sz) +{ + bool finished = false; + x10aux::serial... [truncated message content] |
From: <spa...@us...> - 2009-11-15 10:47:47
|
Revision: 12060 http://x10.svn.sourceforge.net/x10/?rev=12060&view=rev Author: sparksparkspark Date: 2009-11-15 10:47:41 +0000 (Sun, 15 Nov 2009) Log Message: ----------- Add signals to x10.gdb Fix error in verification of cuda test Modified Paths: -------------- trunk/x10.common/contrib/gdb/x10.gdb trunk/x10.dist/samples/CudaKernelTest.x10 Modified: trunk/x10.common/contrib/gdb/x10.gdb =================================================================== --- trunk/x10.common/contrib/gdb/x10.gdb 2009-11-15 10:14:20 UTC (rev 12059) +++ trunk/x10.common/contrib/gdb/x10.gdb 2009-11-15 10:47:41 UTC (rev 12060) @@ -4,3 +4,4 @@ break x10aux::throwNPE break x10aux::throwBPE break x10aux::throwArrayIndexOutOfBoundsException +handle SIGPWR SIGXCPU nostop noprint Modified: trunk/x10.dist/samples/CudaKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-15 10:14:20 UTC (rev 12059) +++ trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-15 10:47:41 UTC (rev 12060) @@ -25,7 +25,7 @@ // validate var success:Boolean = true; for ((i) in 0..remote.length-1) - if (1-Math.abs((recv(i)*recv(i)) / (i as Float)) > 1E-6f) success = false; + if ((1-Math.abs((recv(i)*recv(i)) / (i as Float))) > 1E-6f) success = false; Console.OUT.println((success?"SUCCESS":"FAIL")+" at place "+p); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-15 12:46:11
|
Revision: 12062 http://x10.svn.sourceforge.net/x10/?rev=12062&view=rev Author: sparksparkspark Date: 2009-11-15 12:45:59 +0000 (Sun, 15 Nov 2009) Log Message: ----------- Change the way kernels are set up -- fixes alignment bug on x86_64 and should also be a bit quicker Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-15 10:51:08 UTC (rev 12061) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-15 12:45:59 UTC (rev 12062) @@ -28,6 +28,7 @@ import static x10cpp.visit.SharedVarsMethods.make_ref; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -141,6 +142,7 @@ import polyglot.types.VarInstance; import polyglot.util.ErrorInfo; import polyglot.util.ErrorQueue; +import polyglot.util.SimpleCodeWriter; import polyglot.visit.Translator; import x10.util.ClassifiedStream; import x10.util.StreamWrapper; @@ -239,36 +241,6 @@ return type + rest; } - - void generateSizeOf(StreamWrapper inc, VarInstance var) { - Type t = var.type(); - inc.write("sizeof("); - if (isIntRail(t)) { - inc.write("void *"); - } else if (isFloatRail(t)) { - inc.write("void *"); - } else { - inc.write(Emitter.translateType(t, true)); - } - inc.write(")"); - } - - void generateCudaPut(StreamWrapper inc, VarInstance var) { - inc.write("x10aux::cuda_put(gpu, env, off, "); - - Type t = var.type(); - String name = var.name().toString(); - - if (isIntRail(t)) { - inc.write("(void*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); - } else if (isFloatRail(t)) { - inc.write("(void*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); - } else { - inc.write("this_->"+name); - } - inc.write(");"); - inc.newline(); - } void handleKernel(Block_c b) { String kernel_name = context().wrappingClosure(); @@ -278,25 +250,7 @@ ClassifiedStream out = cudaStream(); // environment (passed into kernel via pointer) - out.write("struct " + kernel_name + "_env {"); - out.newline(4); - out.begin(0); - // emitter.printDeclarationList(out, context(), - // context().kernelParams()); - for (VarInstance var : context().kernelParams()) { - String name = var.name().toString(); - if (name.equals(THIS)) { - name = SAVED_THIS; - } else { - name = Emitter.mangled_non_method_name(name); - } - out.write(prependCudaType(var.type(),name) + ";"); - out.newline(); - } - out.end(); - out.newline(); - out.write("};"); - out.newline(); + generateStruct(kernel_name, out, context().kernelParams()); out.forceNewline(); @@ -347,6 +301,28 @@ out.forceNewline(); } + private void generateStruct(String kernel_name, SimpleCodeWriter out, ArrayList<VarInstance> vars) { + out.write("struct " + kernel_name + "_env {"); + out.newline(4); + out.begin(0); + // emitter.printDeclarationList(out, context(), + // context().kernelParams()); + for (VarInstance var : vars) { + String name = var.name().toString(); + if (name.equals(THIS)) { + name = SAVED_THIS; + } else { + name = Emitter.mangled_non_method_name(name); + } + out.write(prependCudaType(var.type(),name) + ";"); + out.newline(); + } + out.end(); + out.newline(); + out.write("};"); + out.newline(); + } + // Java cannot return multiple values from a function class MultipleValues { public long iterations; @@ -568,27 +544,27 @@ inc.write("threads = 64;"); inc.newline(); inc.write("shm = 0;"); inc.newline(); - inc.write("size_t sz = 0"); //sizeof(this_->len) + sizeof(void*);"); - // FIXME: factor out this loop + generateStruct("", inc, c.variables); + inc.write("_env env;"); inc.newline(); + for (int i = 0; i < c.variables.size(); i++) { - inc.write(" + "); VarInstance var = (VarInstance) c.variables.get(i); - generateSizeOf(inc, var); + Type t = var.type(); + String name = var.name().toString(); + inc.write("env."+name+" = "); + if (isIntRail(t)) { + inc.write("(x10_int*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else if (isFloatRail(t)) { + inc.write("(x10_float*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else { + inc.write("this_->"+name); + } + inc.write(";"); + inc.newline(); } - inc.write(";"); inc.newline(); - - - inc.write("x10_ulong env = x10aux::remote_alloc(gpu, sz);"); inc.newline(); - inc.write("size_t off = 0;"); inc.newline(); - - // FIXME: factor out this loop - for (int i = 0; i < c.variables.size(); i++) { - VarInstance var = (VarInstance) c.variables.get(i); - generateCudaPut(inc, var); - } - - inc.write("assert(off==sz);"); inc.newline(); - inc.write("return env;"); inc.end(); inc.newline(); + inc.write("x10_ulong remote_env = x10aux::remote_alloc(gpu, sizeof(env));"); inc.newline(); + inc.write("x10aux::cuda_put(gpu, remote_env, &env, sizeof(env));"); inc.newline(); + inc.write("return remote_env;"); inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); } } Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-15 10:51:08 UTC (rev 12061) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-15 12:45:59 UTC (rev 12062) @@ -310,19 +310,18 @@ cuda_receive_get, cuda_finished_get); } -void x10aux::cuda_put (place gpu, x10_ulong addr, size_t &off, void *var, size_t sz) +void x10aux::cuda_put (place gpu, x10_ulong addr, void *var, size_t sz) { bool finished = false; x10aux::serialization_buffer buf; addr_map m; buf.realloc_func = x10aux::put_realloc; buf.write((x10_ulong)(size_t)&finished, m); - buf.write(addr+off, m); + buf.write(addr, m); size_t len = buf.length(); x10rt_msg_params p = {gpu, kernel_put, buf.steal(), len}; x10rt_send_put(p, var, sz); while (!finished) x10rt_probe(); - off += sz; } Modified: trunk/x10.runtime/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.h 2009-11-15 10:51:08 UTC (rev 12061) +++ trunk/x10.runtime/src-cpp/x10aux/network.h 2009-11-15 12:45:59 UTC (rev 12062) @@ -102,10 +102,7 @@ void send_put (place p, serialization_id_t id, serialization_buffer &buf, void *data, x10aux::copy_sz len); - void cuda_put (place gpu, x10_ulong addr, size_t &off, void *var, size_t sz); - - template<class T> void cuda_put (place gpu, x10_ulong addr, size_t &off, T var) - { cuda_put(gpu, addr, off, &var, sizeof(var)); } + void cuda_put (place gpu, x10_ulong addr, void *var, size_t sz); } #endif // vim:tabstop=4:shiftwidth=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-16 08:26:00
|
Revision: 12069 http://x10.svn.sourceforge.net/x10/?rev=12069&view=rev Author: sparksparkspark Date: 2009-11-16 08:25:50 +0000 (Mon, 16 Nov 2009) Log Message: ----------- WIP on XTENLANG-489 change Rail.makeVar to Rail.make change Rail.makeVal to ValRail.make add some other functions to Rail (native implementations missing for now) Modified Paths: -------------- trunk/x10.dist/samples/ArraySum.x10 trunk/x10.dist/samples/CudaKernelTest.x10 trunk/x10.dist/samples/FRASimpleDist.x10 trunk/x10.dist/samples/FSSimpleDist.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/KMeans.x10 trunk/x10.dist/samples/KMeansDist.x10 trunk/x10.dist/samples/KMeansSPMD.x10 trunk/x10.dist/samples/NQueensDist.x10 trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/array/FastArray.x10 trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 trunk/x10.runtime/src-x10/x10/array/ValRow.x10 trunk/x10.runtime/src-x10/x10/array/VarMat.x10 trunk/x10.runtime/src-x10/x10/array/VarRow.x10 trunk/x10.runtime/src-x10/x10/array/XformMat.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/Point.x10 trunk/x10.runtime/src-x10/x10/lang/Rail.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 trunk/x10.runtime/src-x10/x10/runtime/Pool.x10 trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/GrowableRail.x10 trunk/x10.runtime/src-x10/x10/util/HashMap.x10 trunk/x10.runtime/src-x10/x10/util/Random.x10 trunk/x10.tests/examples/Benchmarks/DistRandomAccess1.x10 trunk/x10.tests/examples/Benchmarks/DistStream1.x10 trunk/x10.tests/examples/Benchmarks/ParRandomAccess1.x10 trunk/x10.tests/examples/Benchmarks/ParStream1.x10 trunk/x10.tests/examples/Benchmarks/SeqPseudoArray1.x10 trunk/x10.tests/examples/Benchmarks/SeqPseudoArray2a.x10 trunk/x10.tests/examples/Benchmarks/SeqPseudoArray2b.x10 trunk/x10.tests/examples/Benchmarks/SeqRail1.x10 trunk/x10.tests/examples/Benchmarks/SeqRail2.x10 trunk/x10.tests/examples/Benchmarks/SeqRandomAccess1.x10 trunk/x10.tests/examples/Benchmarks/SeqStream1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayPlusEqual.x10 trunk/x10.tests/examples/Constructs/Array/ArrayStaticPlusEqual.x10 trunk/x10.tests/examples/Constructs/Array/TestArray.x10 trunk/x10.tests/examples/Constructs/Atomic/ConditionalAtomicQueue.x10 trunk/x10.tests/examples/Constructs/Clock/ClockPascal.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest10.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest10a.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest9.x10 trunk/x10.tests/examples/Constructs/Distribution/TestDist.x10 trunk/x10.tests/examples/Constructs/Generics/Generics5.x10 trunk/x10.tests/examples/Constructs/Instanceof/NullObjectToBox.x10 trunk/x10.tests/examples/Constructs/Instanceof/ObjectToPrimitive2.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckRail.x10 trunk/x10.tests/examples/Constructs/Point/PointArray.x10 trunk/x10.tests/examples/Constructs/Region/TestRegion.x10 trunk/x10.tests/examples/Issues/XTENLANG_13.x10 trunk/x10.tests/examples/Issues/XTENLANG_17.x10 trunk/x10.tests/examples/Issues/XTENLANG_193.x10 trunk/x10.tests/examples/Issues/XTENLANG_201.x10 trunk/x10.tests/examples/Issues/XTENLANG_210.x10 trunk/x10.tests/examples/Issues/XTENLANG_258.x10 trunk/x10.tests/examples/Issues/XTENLANG_307.x10 trunk/x10.tests/examples/Issues/XTENLANG_32.x10 trunk/x10.tests/examples/Issues/XTENLANG_39.x10 trunk/x10.tests/examples/Issues/XTENLANG_48.x10 trunk/x10.tests/examples/Issues/XTENLANG_52.x10 trunk/x10.tests/examples/Misc/ArraySum.x10 trunk/x10.tests/examples/Misc/Assign1.x10 trunk/x10.tests/examples/Misc/Assign2.x10 trunk/x10.tests/examples/Misc/AssignIntToChar.x10 trunk/x10.tests/examples/Misc/FRA.x10 trunk/x10.tests/examples/Misc/FRASimpleDist.x10 trunk/x10.tests/examples/Misc/FS.x10 trunk/x10.tests/examples/Misc/FSSimple.x10 trunk/x10.tests/examples/Misc/FSSimpleDist.x10 trunk/x10.tests/examples/Misc/NQueensPar.x10 trunk/x10.tests/examples/Misc/NullableComparison.x10 trunk/x10.tests/examples/Misc/Stencil1D.x10 trunk/x10.tests/examples/Timings/Initialization.x10 Modified: trunk/x10.dist/samples/ArraySum.x10 =================================================================== --- trunk/x10.dist/samples/ArraySum.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/ArraySum.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -16,7 +16,7 @@ public def this(n: Int) { size=n; R= 0..n-1 as Region{rail}; - data = Rail.makeVar[Int](n, (x:nat)=>1); + data = Rail.make[Int](n, (x:nat)=>1); // for ((i) in R) S executes S for each point in R. // R must be a 1-d region. (i) decomposes the 1-d point // to retrieve the index in the 0th dimension. Modified: trunk/x10.dist/samples/CudaKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -34,8 +34,8 @@ for (host in Place.places) at (host) { - val init = Rail.makeVar(len,(i:Int)=>i as Float); - val recv = Rail.makeVar(len,(i:Int)=>0.0 as Float); + val init = Rail.make(len,(i:Int)=>i as Float); + val recv = Rail.make(len,(i:Int)=>0.0 as Float); var done_work:Boolean = false; Modified: trunk/x10.dist/samples/FRASimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FRASimpleDist.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/FRASimpleDist.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -12,7 +12,7 @@ def this(size:int) { mask = size-1; - a = Rail.makeVar[long](size, (i:nat)=>i as long); + a = Rail.make[long](size, (i:nat)=>i as long); } public def update(ran:long) { @@ -31,7 +31,7 @@ // Utility routine to start random number generator at Nth step static def HPCC_starts(var n:long): long { var i:int, j:int; - val m2 = Rail.makeVar[long](64); + val m2 = Rail.make[long](64); while (n < 0) n += PERIOD; while (n > PERIOD) n -= PERIOD; if (n == 0) return 0x1L; Modified: trunk/x10.dist/samples/FSSimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FSSimpleDist.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/FSSimpleDist.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -24,7 +24,7 @@ public static def main(args:Rail[String]!){here == Place.FIRST_PLACE} { val verified: Rail[boolean]! = [true]; - val times = Rail.makeVar[double](NUM_TIMES); + val times = Rail.make[double](NUM_TIMES); val N0 = args.length>0? int.parseInt(args(0)) : DEFAULT_SIZE; val N = N0 * NUM_PLACES; val localSize = N0; @@ -39,9 +39,9 @@ async(Place.places(p)) { - val a = Rail.makeVar[double](localSize); - val b = Rail.makeVar[double](localSize); - val c = Rail.makeVar[double](localSize); + val a = Rail.make[double](localSize); + val b = Rail.make[double](localSize); + val c = Rail.make[double](localSize); for (var i:int=0; i<localSize; i++) { b(i) = 1.5 * (p*localSize+i); Modified: trunk/x10.dist/samples/Histogram.x10 =================================================================== --- trunk/x10.dist/samples/Histogram.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/Histogram.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -21,7 +21,7 @@ val N = int.parseInt(args(0)); val S=int.parseInt(args(1)); val a = Array.make[int](0..N-1, ((i):Point)=> i); - val b = Rail.makeVar[int](S); + val b = Rail.make[int](S); run(a, b); val v = b(0); var ok:boolean = true; Modified: trunk/x10.dist/samples/KMeans.x10 =================================================================== --- trunk/x10.dist/samples/KMeans.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/KMeans.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -34,7 +34,7 @@ var count:Int; def this(dim:Int, init:(Int)=>Float): SumVector(dim) { property(dim); - vec = Rail.makeVar[Float](this.dim, init); + vec = Rail.make[Float](this.dim, init); count = 0; } public def apply(i:Int) = vec(i); @@ -89,9 +89,9 @@ def computeMeans(myK:Int, points: ValRail[ValVector(myDim)]): KMeansData(myK, myDim) { var redCluster : KMeansData(myK, myDim) = - Rail.makeVar[SumVector(myDim)](myK, (i:Int)=> new V(myDim, (j:Int)=>points(i)(j))); + Rail.make[SumVector(myDim)](myK, (i:Int)=> new V(myDim, (j:Int)=>points(i)(j))); var blackCluster: KMeansData(myK, myDim) = - Rail.makeVar[SumVector(myDim)](myK, (i:Int)=> new V(myDim, (j:Int)=>0.0F)); + Rail.make[SumVector(myDim)](myK, (i:Int)=> new V(myDim, (j:Int)=>0.0F)); for ((i) in 1..ITERATIONS) { val tmp = redCluster; redCluster = blackCluster; @@ -129,8 +129,8 @@ public static def main (args : Rail[String]) { val rnd = new Random(0); - val points = Rail.makeVal[ValVector](POINTS, - (Int)=>Rail.makeVal[Float](DIM, (Int)=>rnd.nextFloat())); + val points = ValRail.make[ValVector](POINTS, + (Int)=>ValRail.make[Float](DIM, (Int)=>rnd.nextFloat())); val result = new KMeans(DIM).computeMeans(K, points); for ((k) in 0..K-1) result(k).print(); } Modified: trunk/x10.dist/samples/KMeansDist.x10 =================================================================== --- trunk/x10.dist/samples/KMeansDist.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/KMeansDist.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -12,28 +12,28 @@ public static def main (args : Rail[String]!) { val rnd = PlaceLocalStorage.createDistributedObject[Random](Dist.makeUnique(), () => new Random(0)); val local_curr_clusters = PlaceLocalStorage.createDistributedObject[Rail[Float]](Dist.makeUnique(), - () => Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => 0 as Float)); + () => Rail.make[Float](CLUSTERS*DIM, (i:Int) => 0 as Float)); val local_new_clusters = PlaceLocalStorage.createDistributedObject[Rail[Float]](Dist.makeUnique(), - () => Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => 0 as Float)); + () => Rail.make[Float](CLUSTERS*DIM, (i:Int) => 0 as Float)); val local_cluster_counts = PlaceLocalStorage.createDistributedObject[Rail[Int]](Dist.makeUnique(), - ()=> Rail.makeVar[Int](CLUSTERS, (i:Int) => 0)); + ()=> Rail.make[Int](CLUSTERS, (i:Int) => 0)); val points_dist = Dist.makeBlock(points_region, 0); val points = Array.makeVal[Float](points_dist, (p:Point)=>rnd.get().nextFloat()); - val central_clusters = Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => { + val central_clusters = Rail.make[Float](CLUSTERS*DIM, (i:Int) => { val p = Point.make([i/DIM, i%DIM]); return at (points_dist(p)) points(p); }); - val central_cluster_counts = Rail.makeVar[Int](CLUSTERS, (i:Int) => 0); + val central_cluster_counts = Rail.make[Int](CLUSTERS, (i:Int) => 0); for (i in 1..ITERATIONS) { Console.OUT.println("Iteration: "+i); // have to create a valrail so that it will be serialised - val central_clusters_copy = Rail.makeVal(CLUSTERS*DIM, (i:Int) => central_clusters(i)); + val central_clusters_copy = ValRail.make(CLUSTERS*DIM, (i:Int) => central_clusters(i)); for (var j:Int=0 ; j<CLUSTERS ; ++j) { local_cluster_counts.get()(j) = 0; @@ -90,9 +90,9 @@ for (d in points_dist.places()) async(d) { // have to create valrails for serialisation val local_new_clusters_copy = - Rail.makeVal(CLUSTERS*DIM, (i:Int) => local_new_clusters.get()(i)); + ValRail.make(CLUSTERS*DIM, (i:Int) => local_new_clusters.get()(i)); val local_cluster_counts_copy = - Rail.makeVal(CLUSTERS, (i:Int) => local_cluster_counts.get()(i)); + ValRail.make(CLUSTERS, (i:Int) => local_cluster_counts.get()(i)); at (Place.FIRST_PLACE) atomic { for (var j:Int=0 ; j<DIM*CLUSTERS ; ++j) { central_clusters(j) += local_new_clusters.get()(j); Modified: trunk/x10.dist/samples/KMeansSPMD.x10 =================================================================== --- trunk/x10.dist/samples/KMeansSPMD.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/KMeansSPMD.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -45,11 +45,11 @@ val points_cache = ValRail.make[Float](POINTS*DIM, init_points); val points = Array.make[Float](points_dist, (p:Point)=>points_cache(p(0)*DIM+p(1))); - val central_clusters = Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => points_cache(i)); + val central_clusters = Rail.make[Float](CLUSTERS*DIM, (i:Int) => points_cache(i)); // used to measure convergence at each iteration: val central_clusters_old = - Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => central_clusters(i)); - val central_cluster_counts = Rail.makeVar[Int](CLUSTERS, (i:Int) => 0); + Rail.make[Float](CLUSTERS*DIM, (i:Int) => central_clusters(i)); + val central_cluster_counts = Rail.make[Int](CLUSTERS, (i:Int) => 0); class Cell[T] { private var value:T; @@ -69,9 +69,9 @@ val local_points = points.restriction(here) as Array[Float](2); - val clusters = Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => 0.0f); - val new_clusters = Rail.makeVar[Float](CLUSTERS*DIM, (i:Int) => 0.0f); - val cluster_counts = Rail.makeVar[Int](CLUSTERS, (i:Int) => 0); + val clusters = Rail.make[Float](CLUSTERS*DIM, (i:Int) => 0.0f); + val new_clusters = Rail.make[Float](CLUSTERS*DIM, (i:Int) => 0.0f); + val cluster_counts = Rail.make[Int](CLUSTERS, (i:Int) => 0); for (var iter:Int=0 ; iter<ITERATIONS && !finished.get() ; iter++) { Modified: trunk/x10.dist/samples/NQueensDist.x10 =================================================================== --- trunk/x10.dist/samples/NQueensDist.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/NQueensDist.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -44,11 +44,11 @@ class Board { global val q: ValRail[Int]; def this() { - q = Rail.makeVal[Int](0, (Nat)=>0); + q = ValRail.make[Int](0, (Nat)=>0); } def this(old: ValRail[Int], newItem:Int) { val n = old.length; - q = Rail.makeVal[Int](n+1, (i:Nat)=> (i < n? old(i) : newItem)); + q = ValRail.make[Int](n+1, (i:Nat)=> (i < n? old(i) : newItem)); } global def safe(j: int) { val n = q.length; Modified: trunk/x10.dist/samples/NQueensPar.x10 =================================================================== --- trunk/x10.dist/samples/NQueensPar.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.dist/samples/NQueensPar.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -33,12 +33,12 @@ val q: Rail[Int]{self.at(this)}; def this() { - q = Rail.makeVar[Int](0, (Nat)=>0); + q = Rail.make[Int](0, (Nat)=>0); } def this(old: Rail[Int]!, newItem:Int) { val n = old.length; - q = Rail.makeVar[Int](n+1, (i:Nat)=> (i < n? old(i) : newItem)); + q = Rail.make[Int](n+1, (i:Nat)=> (i < n? old(i) : newItem)); } def safe(j: int) { Modified: trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/BaseArray.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -213,7 +213,7 @@ // scatter val ps:ValRail[Place] = dist.places(); - val results = Rail.makeVar[T](ps.length, (p:nat) => unit); + val results = Rail.make[T](ps.length, (p:nat) => unit); val r = 0..(ps.length-1); @@ -240,7 +240,7 @@ // scatter val ps = dist.places(); - val results = Rail.makeVal[Future[T]](ps.length, (p:nat) => { + val results = ValRail.make[Future[T]](ps.length, (p:nat) => { future(ps(p)) { var result: T = unit; val a = (this | here) as Array[T](rank); @@ -302,8 +302,8 @@ protected proto global def layout(r: Region): RectLayout { if (r.isEmpty()) { // XXX EmptyLayout class? - val min = Rail.makeVal[int](r.rank, (nat)=>0); - val max = Rail.makeVal[int](r.rank, (nat)=>-1); + val min = ValRail.make[int](r.rank, (nat)=>0); + val max = ValRail.make[int](r.rank, (nat)=>-1); return new RectLayout(min, max); } else { return new RectLayout(r.min(), r.max()); Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -40,7 +40,7 @@ // regions val init = (i:nat) => Region.makeRectangular(i, i); - val regions = Rail.makeVal[Region](ps.length, init); + val regions = ValRail.make[Region](ps.length, init); // overall region val overall = Region.makeRectangular(0, ps.length-1); @@ -58,7 +58,7 @@ val max = b.max()(axis); val init = (i:nat) => Region.makeEmpty(r.rank); - var regions:Rail[Region]! = Rail.makeVar[Region](Place.MAX_PLACES, init); + var regions:Rail[Region]! = Rail.make[Region](Place.MAX_PLACES, init); for (var i: int = min, p: int = 0; i<=max; i+=blockSize, p++) { val r1 = Region.makeFull(axis); @@ -147,14 +147,14 @@ // regions val init = (i:nat) => (this.regions(i) as Region(rank)).intersection(r); - val rs = Rail.makeVal[Region](this.regions.length, init); + val rs = ValRail.make[Region](this.regions.length, init); return new BaseDist(r, ps, rs); } public global def restriction(p: Place): Dist(rank) { val ps = [p]; - val rs = Rail.makeVal[Region](1, (nat)=>get(p)); + val rs = ValRail.make[Region](1, (nat)=>get(p)); return new BaseDist(region.intersection(rs(0) as Region(rank)), ps, rs) as Dist(rank); } @@ -180,7 +180,7 @@ return r1.intersection(r2); }; - val rs: ValRail[Region(rank)] = Rail.makeVal[Region(rank)](regions.length, init); + val rs: ValRail[Region(rank)] = ValRail.make[Region(rank)](regions.length, init); // overall region var overall: Region(rank) = Region.makeEmpty(rank); @@ -201,7 +201,7 @@ val r2 = that.get(this.places(i)) as Region(rank); return r1.difference(r2); }; - val rs = Rail.makeVal[Region(rank)](this.regions.length, init); + val rs = ValRail.make[Region(rank)](this.regions.length, init); // overall region var overall: Region(rank) = Region.makeEmpty(rank); @@ -222,7 +222,7 @@ val r = this.get(p) as Region(rank); // XXXX return r.difference(that.region).union(that.get(p)); }; - val rs = Rail.makeVal[Region(rank)](ps.length, init); + val rs = ValRail.make[Region(rank)](ps.length, init); return new BaseDist(this.region.union(that.region), ps, rs) as Dist(rank); } @@ -238,7 +238,7 @@ val r2 = this.get(ps(i)) as Region(rank); // XXXX return r2.union(r1); }; - val rs = Rail.makeVal[Region(rank)](ps.length, init); + val rs = ValRail.make[Region(rank)](ps.length, init); // overall region var overall: Region(rank) = Region.makeEmpty(rank); @@ -328,10 +328,10 @@ // compute the map val empty = Region.makeEmpty(rank); - val regionMap = Rail.makeVar[Region](Place.MAX_PLACES, (nat)=>empty); + val regionMap = Rail.make[Region](Place.MAX_PLACES, (nat)=>empty); for (var i: int = 0; i<this.places.length; i++) regionMap(this.places(i).id) = this.regions(i); - this.regionMap = Rail.makeVal[Region](regionMap.length, (i:nat) => regionMap(i)); + this.regionMap = ValRail.make[Region](regionMap.length, (i:nat) => regionMap(i)); } Modified: trunk/x10.runtime/src-x10/x10/array/DistArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -98,7 +98,7 @@ val plsInit:()=>LocalState[T]! = () => { val region = dist.get(here); val localLayout = layout(region); - val localRaw = Rail.makeVar[T](localLayout.size()); + val localRaw = Rail.make[T](localLayout.size()); for (pt:Point in region) { localRaw(localLayout.offset(pt)) = init(pt); @@ -115,7 +115,7 @@ val plsInit:()=>LocalState[T]! = () => { val region = dist.get(here); val localLayout = layout(region); - val localRaw = Rail.makeVar[T](localLayout.size()); + val localRaw = Rail.make[T](localLayout.size()); return new LocalState[T](localLayout, localRaw); }; Modified: trunk/x10.runtime/src-x10/x10/array/FastArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/FastArray.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/FastArray.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -145,7 +145,7 @@ finish async (dist.onePlace) { val layout = layout(region); val n = layout.size(); - val raw = Rail.makeVar[T](n); + val raw = Rail.make[T](n); if (init!=null) { val f = at (init.location) { init as (Point) => T }; for (p:Point in region) @@ -160,7 +160,7 @@ layout = layout(region); val n = layout.size(); - val r = Rail.makeVar[T](n); + val r = Rail.make[T](n); val f = init as (Point) => T; for (p:Point in region) @@ -185,7 +185,7 @@ layout = layout(region); val n = layout.size(); - val r = Rail.makeVar[T](n); + val r = Rail.make[T](n); raw = r; Modified: trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/LocalArray.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -116,7 +116,7 @@ layout = layout(region); val n = layout.size(); - val r = Rail.makeVar[T](n); + val r = Rail.make[T](n); raw = r; } @@ -125,7 +125,7 @@ layout = layout(region); val n = layout.size(); - val r = Rail.makeVar[T](n); + val r = Rail.make[T](n); val f = init as (Point) => T; for (p:Point in region) @@ -149,7 +149,7 @@ if (d.region.isEmpty()) { this.layout = layout(d.region); - this.raw = Rail.makeVar[T](0); + this.raw = Rail.make[T](0); } else { this.layout = a.layout(); this.raw = a.raw(); Modified: trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -35,7 +35,7 @@ */ public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int, isSimplified:boolean) { - super(rows, cols, Rail.makeVal[PolyRow](rows, (i:nat)=>new PolyRow(cols, (j:nat)=>init(i,j)))); + super(rows, cols, ValRail.make[PolyRow](rows, (i:nat)=>new PolyRow(cols, (j:nat)=>init(i,j)))); property(cols-1); this.isSimplified = isSimplified; } @@ -82,7 +82,7 @@ return this; val pmb = new PolyMatBuilder(rank); - var removed:Rail[boolean]! = Rail.makeVar[boolean](rows, (nat)=>false); // XTENLANG-39 workaround + var removed:Rail[boolean]! = Rail.make[boolean](rows, (nat)=>false); // XTENLANG-39 workaround for (var i: int = 0; i<rows; i++) { val r = this(i); @@ -125,7 +125,7 @@ } else { for (jr:PolyRow in this) { val ja = jr(k); - val as = Rail.makeVar[int](rank+1); + val as = Rail.make[int](rank+1); if (ia>0 && ja<0) { for (var l: int = 0; l<=rank; l++) as(l) = ia*jr(l) - ja*ir(l); @@ -193,10 +193,10 @@ } global def rectMin(): ValRail[int] - = Rail.makeVal[int](rank, (i:nat)=>rectMin(i)); + = ValRail.make[int](rank, (i:nat)=>rectMin(i)); global def rectMax(): ValRail[int] - = Rail.makeVal[int](rank, (i:nat)=>rectMax(i)); + = ValRail.make[int](rank, (i:nat)=>rectMax(i)); global def isZeroBased(): boolean { if (!isRect()) Modified: trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/PolyMatBuilder.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -62,7 +62,7 @@ public def add(var coeff: int, op: int, k: int): void { coeff += ZERO; - val as = Rail.makeVar[int](rank+1); + val as = Rail.make[int](rank+1); for (var i: int = 0; i<rank; i++) { val a = (coeff&3) - 2; as(i) = op==LE? a : - a; Modified: trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -165,7 +165,7 @@ private static def copy(tt: PolyMatBuilder!, ff: PolyMat, offset: int): void { for (r:PolyRow in ff) { val f = r; - val t = Rail.makeVar[int](tt.rank+1); + val t = Rail.make[int](tt.rank+1); for (var i: int = 0; i<ff.rank; i++) t(offset+i) = f(i); t(tt.rank) = f(ff.rank); @@ -184,7 +184,7 @@ private static def translate(tt: PolyMatBuilder!, ff: PolyMat, v: Point(ff.rank)): void { for (r:PolyRow in ff) { val f = r; - val t = Rail.makeVar[int](ff.rank+1); + val t = Rail.make[int](ff.rank+1); var s:Int = 0; for (var i: int = 0; i<ff.rank; i++) { t(i) = f(i); @@ -226,8 +226,8 @@ } protected global def computeBoundingBox(): Region(rank) { - val min = Rail.makeVar[int](rank); - val max = Rail.makeVar[int](rank); + val min = Rail.make[int](rank); + val max = Rail.make[int](rank); var pm: PolyMat{self.rank==this.rank} = mat; for (var axis: int = 0; axis<rank; axis++) { var x: PolyMat = pm; Modified: trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/PolyRow.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -125,7 +125,7 @@ global def complement(): PolyRow { val init = (i:nat) => i<rank? -this(i) : -this(rank)+1; - val as = Rail.makeVal[int](rank+1, init); + val as = ValRail.make[int](rank+1, init); return new PolyRow(as); } Modified: trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/PolyScanner.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -107,21 +107,21 @@ this.X1 = X1; val r = pm.rank; this.rank = r; - val n = Rail.makeVar[VarMat](r); + val n = Rail.make[VarMat](r); myMin = n; - val x = Rail.makeVar[VarMat](r); + val x = Rail.make[VarMat](r); myMax = x; - val nSum = Rail.makeVar[VarMat](r); + val nSum = Rail.make[VarMat](r); minSum = nSum; - val xSum = Rail.makeVar[VarMat](r); + val xSum = Rail.make[VarMat](r); maxSum = xSum; - val n2 = Rail.makeVar[Rail[PolyRow]!](r); + val n2 = Rail.make[Rail[PolyRow]!](r); min2 = n2; - val x2 = Rail.makeVar[Rail[PolyRow]!](r); + val x2 = Rail.make[Rail[PolyRow]!](r); max2 = x2; //printInfo(Console.OUT); - parFlags = Rail.makeVar[boolean](r); + parFlags = Rail.make[boolean](r); } private def init() { @@ -158,8 +158,8 @@ myMax(axis) = new VarMat(imax, axis+1); minSum(axis) = new VarMat(imin, axis+1); maxSum(axis) = new VarMat(imax, axis+1); - min2(axis) = Rail.makeVar[PolyRow](imin); - max2(axis) = Rail.makeVar[PolyRow](imax); + min2(axis) = Rail.make[PolyRow](imin); + max2(axis) = Rail.make[PolyRow](imax); // fill in imin=0; imax=0; @@ -245,9 +245,9 @@ private val rank: int = PolyScanner.this.rank; private val s = PolyScanner.this; - private val x = Rail.makeVar[int](rank); - private val myMin = Rail.makeVar[int](rank); - private val myMax = Rail.makeVar[int](rank); + private val x = Rail.make[int](rank); + private val myMin = Rail.make[int](rank); + private val myMax = Rail.make[int](rank); private var k: int; def this() {} @@ -343,8 +343,8 @@ } public def loop(body:(Rail[int])=>void) { - val p = Rail.makeVar[int](X1(0).rows); - val q = Rail.makeVar[int](X1(0).cols); + val p = Rail.make[int](X1(0).rows); + val q = Rail.make[int](X1(0).cols); loop(body, p, q, 0); } @@ -389,7 +389,7 @@ finish { for (var i:int=min; i<=max; i++) { q(r) = i; - val qq = Rail.makeVar[int](q.length, (i:nat)=>q(i)); + val qq = Rail.make[int](q.length, (i:nat)=>q(i)); async { //Console.OUT.println("async{"); loop(body, p, qq, r+1); @@ -429,7 +429,7 @@ // XXX makes simplifying assumptions about conformance of regions // - make this more general!!! public operator this || (that:PolyScanner!) { - val x = Rail.makeVal(this.X1.length + that.X1.length, (i:nat) => + val x = ValRail.make(this.X1.length + that.X1.length, (i:nat) => i<this.X1.length? this.X1(i) : that.X1(i-this.X1.length)); return new PolyScanner(this.C, x); } Modified: trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/RectLayout.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -39,7 +39,7 @@ this.rank = r; this.min = min; - val d0 = Rail.makeVal[int](r, (i:nat) => max(i) - min(i) + 1); + val d0 = ValRail.make[int](r, (i:nat) => max(i) - min(i) + 1); delta = d0; var size: int = 1; Modified: trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -140,7 +140,7 @@ rank = r.rank; min = r.mat.rectMin(); max = r.mat.rectMax(); - val xx = Rail.makeVar[int](r.rank, (i:nat)=>r.mat.rectMin()(i)); + val xx = Rail.make[int](r.rank, (i:nat)=>r.mat.rectMin()(i)); xx(r.rank-1)--; x = xx; } Modified: trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/UnionRegion.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -163,8 +163,8 @@ protected global def computeBoundingBox(): Region(rank) { - val myMin = Rail.makeVar[int](rank); - val myMax = Rail.makeVar[int](rank); + val myMin = Rail.make[int](rank); + val myMax = Rail.make[int](rank); for (var axis: int = 0; axis<rank; axis++) myMin(axis) = Int.MAX_VALUE; for (var axis: int = 0; axis<rank; axis++) Modified: trunk/x10.runtime/src-x10/x10/array/ValRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/ValRow.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/ValRow.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -22,7 +22,7 @@ public def this(cols: nat, init: (nat)=>int) { super(cols); - row = Rail.makeVal[int](cols, init); + row = ValRail.make[int](cols, init); } public safe global def apply(i:nat) = row(i); Modified: trunk/x10.runtime/src-x10/x10/array/VarMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/VarMat.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/VarMat.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -9,7 +9,7 @@ = super(mat.length, cols, mat); public def this(rows: nat, cols: nat, init:(nat)=>VarRow) - = super(rows, cols, Rail.makeVal[VarRow](rows, init)); + = super(rows, cols, ValRail.make[VarRow](rows, init)); public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int) = this(rows, cols, (i:nat)=>new VarRow(cols, (j:nat)=>init(i,j))); Modified: trunk/x10.runtime/src-x10/x10/array/VarRow.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/VarRow.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/VarRow.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -9,12 +9,12 @@ public def this(cols: nat, init: (nat)=>int) { super(cols); - row = Rail.makeVar[int](cols, init); + row = Rail.make[int](cols, init); } public def this(cols: nat) { super(cols); - row = Rail.makeVar[int](cols); + row = Rail.make[int](cols); } global def row() = row as Rail[int]!; Modified: trunk/x10.runtime/src-x10/x10/array/XformMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/XformMat.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/array/XformMat.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -9,7 +9,7 @@ = super(mat.length, cols, mat); public def this(rows: nat, cols: nat, init:(nat)=>ValRow) - = super(rows, cols, Rail.makeVal[ValRow](rows, init)); + = super(rows, cols, ValRail.make[ValRow](rows, init)); public def this(rows: nat, cols: nat, init: (i:nat,j:nat)=>int) = this(rows, cols, (i:nat)=>new ValRow(cols, (j:nat)=>init(i,j))); Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -19,10 +19,10 @@ */ public final struct Place(id: Int) { public const MAX_PLACES = NativeRuntime.MAX_HOSTS; - public const places = Rail.makeVal[Place](MAX_PLACES, ((id: Int) => Place(id))); - public const children = Rail.makeVal[ValRail[Place]]( + public const places = ValRail.make[Place](MAX_PLACES, ((id: Int) => Place(id))); + public const children = ValRail.make[ValRail[Place]]( NativeRuntime.MAX_PLACES, - (p: Int) => Rail.makeVal[Place](NativeRuntime.numChildren(p), + (p: Int) => ValRail.make[Place](NativeRuntime.numChildren(p), (i:Int) => Place(NativeRuntime.child(p,i)))); public const FIRST_PLACE: Place(0) = places(0) as Place(0); Modified: trunk/x10.runtime/src-x10/x10/lang/Point.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Point.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/lang/Point.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -46,8 +46,8 @@ public static def make(cs: Rail[int]!): Point(cs.length) { // (i:nat)=>cs(i) is workaround for XTENLANG-32 - // val a: ValRail[int](cs.length) = Rail.makeVal[int](cs.length, (i:nat)=>cs(i)); - val a = Rail.makeVal[int](cs.length, (i:nat)=>cs(i)); + // val a: ValRail[int](cs.length) = ValRail.make[int](cs.length, (i:nat)=>cs(i)); + val a = ValRail.make[int](cs.length, (i:nat)=>cs(i)); return make(a); } @@ -57,7 +57,7 @@ */ public static def make(rank:nat, init:(i:nat)=>int) { - val a = Rail.makeVal[int](rank, init); + val a = ValRail.make[int](rank, init); return make(a); } @@ -86,79 +86,79 @@ } public global operator - this: Point(rank) { - val cs = Rail.makeVar[int](rank, (i:nat)=>-this.coords(i)); + val cs = Rail.make[int](rank, (i:nat)=>-this.coords(i)); return Point.make(cs); } public global operator this + (that: Point(rank)): Point(rank) { val init = (i:nat) => this.coords(i) + that.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this - (that: Point(rank)): Point(rank) { val init = (i:nat) => this.coords(i) - that.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this * (that: Point(rank)): Point(rank) { val init = (i:nat) => this.coords(i) * that.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this / (that: Point(rank)): Point(rank) { val init = (i:nat) => this.coords(i) / that.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this + (c: int): Point(rank) { val init = (i:nat) => this.coords(i) + c; - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this - (c: int): Point(rank) { val init = (i:nat) => this.coords(i) - c; - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this * (c: int): Point(rank) { val init = (i:nat) => this.coords(i) * c; - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator this / (c: int): Point(rank) { val init = (i:nat) => this.coords(i) / c; - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator (c: int) + this: Point(rank) { val init = (i:nat) => c + this.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator (c: int) - this: Point(rank) { val init = (i:nat) => c - this.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator (c: int) * this: Point(rank) { val init = (i:nat) => c * this.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } public global operator (c: int) / this: Point(rank) { val init = (i:nat) => c / this.coords(i); - val cs = Rail.makeVar[int](rank, init); + val cs = Rail.make[int](rank, init); return Point.make(cs); } Modified: trunk/x10.runtime/src-x10/x10/lang/Rail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -15,50 +15,80 @@ @NativeRep("java", "x10.core.Rail<#1>", "x10.core.Rail.BoxedRail", "new x10.core.Rail.RTT(#2)") @NativeRep("c++", "x10aux::ref<x10::lang::Rail<#1 > >", "x10::lang::Rail<#1 >", null) -public final class Rail[T](length: nat) - implements Settable[nat,T], Iterable[T] +public final class Rail[T](length: Int) + implements Settable[Int,T], Iterable[T] { - // need to declare a constructor to shut up the initialization checker - private native def this(n: nat): Rail[T]{self.length==n}; + private native def this(n: Int): Rail[T]{self.length==n}; + + /* @Native("java", "x10.core.RailFactory.<#2>makeValRail(#3, #4, #5)") @Native("c++", "x10::lang::ValRail<#1 >::make(#4, #5)") - public native static safe def makeVal[S](length: nat, init: (nat) => S): ValRail[S]{self.length==length}; + public native static safe def makeVal[S](length: Int, init: (Int) => S): ValRail[S]{self.length==length}; @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4, #5)") @Native("c++", "x10::lang::Rail<#1 >::make(#4, #5)") - public native static safe def makeVar[S](length: nat, init: (nat) => S): Rail[S]!{self.length==length}; + public native static safe def makeVar[S](length: Int, init: (Int) => S): Rail[S]!{self.length==length}; + */ + @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4, #5)") + @Native("c++", "x10::lang::Rail<#1 >::make(#4, #5)") + public native static safe def make[S](length: Int, init: (Int) => S): Rail[S]!{self.length==length}; + + @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4, #5, #6)") + @Native("c++", "x10::lang::Rail<#1 >::make(#4, #5, #6)") + public native static safe def make[S](length: Int, off:Int, init:Rail[S]): Rail[S]!{self.length==length}; + + @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4, #5)") + @Native("c++", "x10::lang::Rail<#1 >::make(#4, #5)") + public native static safe def make[S](length: Int, init:S): Rail[S]!{self.length==length}; + + // FIXME: hack! uninitialised rail is unsound (used by x10.array.DistArray) + @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4)") + @Native("c++", "x10::lang::Rail<#1 >::make(#4)") + public native static safe def make[S](length: Int): Rail[S]!{self.length==length}; + + @Native("java", "#0.reset(#1)") + @Native("c++", "(#0)->reset(#1)") + public native safe def reset(init: (Int) => T): Void; + + @Native("java", "#0.reset(#1)") + @Native("c++", "(#0)->reset(#1)") + public native safe def reset(init: T): Void; + +/* @Native("java", "x10.core.RailFactory.<#2>makeValRail(#3, #4)") @Native("c++", "x10::lang::ValRail<#1 >::make(#4)") - public native static safe def makeVal[S](length: nat): ValRail[S]{self.length==length}; + public native static safe def makeVal[S](length: Int): ValRail[S]{self.length==length}; - @Native("java", "x10.core.RailFactory.<#2>makeVarRail(#3, #4)") - @Native("c++", "x10::lang::Rail<#1 >::make(#4)") - public native static safe def makeVar[S](length: nat): Rail[S]!{self.length==length}; +*/ +/* @Native("java", "x10.core.RailFactory.<#2>makeRailFromValRail(#3, #4)") @Native("c++", "x10::lang::Rail<#1 >::make(#4)") public native static safe def make[U](r: ValRail[U]): Rail[U]!{self.length==r.length}; +*/ @Native("java", "x10.core.RailFactory.<#2>makeRailFromValRail(#3, #4)") @Native("c++", "x10::lang::Rail<#1 >::make(#4)") public native static safe operator [U](r: ValRail[U]): Rail[U]!{self.length==r.length}; +/* @Native("java", "#0.get(#1)") @Native("c++", "(*#0)[#1]") - public native safe def get(i: nat): T; + public native safe def get(i: Int): T; +*/ @Native("java", "#0.apply(#1)") @Native("c++", "(*#0)[#1]") @Native("cuda", "(#0)[#1]") - public native safe def apply(i: nat): T; + public native safe def apply(i: Int): T; @Native("java", "#0.set(#1, #2)") @Native("c++", "(*#0)[#2] = #1") @Native("cuda", "(#0)[#2] = #1") - public native safe def set(v: T, i: nat): T; + public native safe def set(v: T, i: Int): T; @Native("java", "#0.iterator()") @Native("c++", "(#0)->iterator()") @@ -67,7 +97,7 @@ @Native("java", "x10.lang.System.makeRemoteRail(#3, #4,#5,#6)") @Native("c++", "x10::lang::System::makeRemoteRail(#4,#5,#6)") - public native static safe def makeRemote[T] (p:Place, length:Int, init: (nat) => T) : Rail[T]{self.length==length&&self.location==p}; + public native static safe def makeRemote[T] (p:Place, length:Int, init: (Int) => T) : Rail[T]!p{self.length==length}; // Transfer functions Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -232,7 +232,7 @@ public static safe def makeRemoteRail[T] (p:Place, length:Int, init: (nat) => T) : Rail[T]{self.length==length} { if (p.isCUDA()) return cudaMakeRail[T](p,length); // FIXME: no initialisation - return at (p) Rail.makeVar[T](length, init); + return at (p) Rail.make[T](length, init); } } Modified: trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -10,52 +10,54 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.util.Pair; @NativeRep("java", "x10.core.ValRail<#1>", "x10.core.ValRail.BoxedValRail", "new x10.core.ValRail.RTT(#2)") @NativeRep("c++", "x10aux::ref<x10::lang::ValRail<#1 > >", "x10::lang::ValRail<#1 >", null) -public final class ValRail[+T](length: nat) implements (nat) => T, Iterable[T] { +public final class ValRail[+T](length: Int) implements (Int) => T, Iterable[T] { // need to declare a constructor to shut up the initialization checker - private native def this(n: nat): ValRail[T]{self.length==n}; + private native def this(n: Int): ValRail[T]{self.length==n}; +/* @Native("java", "x10.core.RailFactory.<#2>makeValRail(#3, #4, #5)") @Native("c++", "x10::lang::ValRail<#1 >::make(#4, #5)") - public native static def make[T](length: Nat, init: (Nat) => T, value: boolean): ValRail[T](length); + public native static def make[T](length: Int, init: (Int) => T, value: boolean): ValRail[T](length); +*/ @Native("java", "x10.core.RailFactory.<#2>makeValRail(#3, #4, #5)") @Native("c++", "x10::lang::ValRail<#1 >::make(#4, #5)") - public native static def make[T](length: Nat, init: (Nat) => T): ValRail[T](length); + public native static def make[T](length: Int, init: (Int) => T): ValRail[T](length); @Native("java", "x10.core.RailFactory.<#2>makeValRailFromRail(#3, #4)") @Native("c++", "x10::lang::ValRail<#1 >::make(#4)") - public native static operator [U](r: Rail[U]): ValRail[U]{self.length==r.length}; + public native static operator[U](r: Rail[U]): ValRail[U]{self.length==r.length}; +/* @Native("java", "#0.get(#1)") @Native("c++", "(#0)->get(#1)") - public global native safe def get(i: nat): T; + public global native safe def get(i: Int): T; +*/ @Native("java", "#0.apply(#1)") @Native("c++", "(*#0)[#1]") @Native("cuda", "(#0)[#1]") - public global native safe def apply(i: nat): T; + public global native safe def apply(i: Int): T; @Native("java", "#0.iterator()") @Native("c++", "(#0)->iterator()") public global native def iterator(): Iterator[T]; + @Native("java", "x10.lang.System.copyTo(#0,#1,#2,#3,#4,#5)") @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") //@Native("c++", "(#0)->copyTo(#1, #2, #3, #4, #5)") public global native def copyTo (src_off:Int, dst:Rail[T], dst_off:Int, len:Int) : Void; -/* FIXME: This interface is not possible to define properly without structs: - * the closure needs to return both an offset and a rail. - * For now we assume the offset on the remote side is 0. - */ @Native("java", "x10.lang.System.copyTo(#0,#1,#2,#3,#4,#5,#6)") @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") //@Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5,#6)") public global native def copyTo (src_off:Int, - dst_place:Place, dst_finder:()=>Rail[T], - len:Int) : Void; + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], + len:Int) : Void; } Modified: trunk/x10.runtime/src-x10/x10/runtime/Pool.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Pool.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/runtime/Pool.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -35,8 +35,8 @@ def this(latch:Latch!, size:Int) { this.latch = latch; this.size = size; - val workers = Rail.makeVar[Worker!](MAX); - val threads = Rail.makeVar[Thread!](size); + val workers = Rail.make[Worker!](MAX); + val threads = Rail.make[Thread!](size); // worker for the master thread val master = new Worker(latch, 0); Modified: trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -30,7 +30,7 @@ /** * Keep track of the number of activities associated with this finish state. */ - private val counts = Rail.makeVar[Int](Place.MAX_PLACES, (Int)=>0) as Rail[Int]!; + private val counts = Rail.make[Int](Place.MAX_PLACES, (Int)=>0) as Rail[Int]!; private var count:AtomicInteger = new AtomicInteger(0); Modified: trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -25,7 +25,7 @@ public def incr():Void {} def this() { - val c = Rail.makeVar[Int](Place.MAX_PLACES, (Int)=>0); + val c = Rail.make[Int](Place.MAX_PLACES, (Int)=>0); c(here.id) = 1; counts = c; } Modified: trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -128,7 +128,7 @@ public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void, Boolean):Void { val state = currentState(); - val phases = Rail.makeVal[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); + val phases = ValRail.make[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); state.notifySubActivitySpawn(place); if (place.id == Thread.currentThread().locInt()) { execute(new Activity(body, state, clocks, phases)); @@ -180,7 +180,7 @@ public static def runAsync(clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); - val phases = Rail.makeVal[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); + val phases = ValRail.make[Int](clocks.length, (i:Nat)=>(clocks(i) as Clock_c).register_c()); state.notifySubActivitySpawn(here); execute(new Activity(body, state, clocks, phases)); } Modified: trunk/x10.runtime/src-x10/x10/util/GrowableRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/GrowableRail.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/util/GrowableRail.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -42,11 +42,11 @@ /** Convert to a mutable rail. This copies the content of the rail. */ @Native("java", "#0.toRail()") @Native("c++", "(#0)->toRail()") - public native def toRail(): Rail[T]; + public native def toRail(): Rail[T]!; /** Convert to an immutable rail. This copies the content of the rail. */ @Native("java", "#0.toValRail()") @Native("c++", "(#0)->toValRail()") - public native def toValRail(): ValRail[T]; + public native def toValRail(): ValRail[T]!; } Modified: trunk/x10.runtime/src-x10/x10/util/HashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -60,7 +60,7 @@ assert (sz & -sz) == sz; assert sz >= MIN_SIZE; - table = Rail.makeVar[HashEntry[K,V]!](sz); + table = Rail.make[HashEntry[K,V]!](sz); mask = sz - 1; size = 0; occupation = 0; @@ -169,7 +169,7 @@ public def rehash(): void { val t = table; val oldSize = size; - table = Rail.makeVar[HashEntry[K,V]!](t.length*2); + table = Rail.make[HashEntry[K,V]!](t.length*2); mask = table.length - 1; size = 0; occupation = 0; Modified: trunk/x10.runtime/src-x10/x10/util/Random.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Random.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.runtime/src-x10/x10/util/Random.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -129,7 +129,7 @@ private var MT: Rail[int]!; public proto def init(seed: long): Void { - val mt = Rail.makeVar[int](N); + val mt = Rail.make[int](N); MT=mt; // Ensure the seed is nonzero. if (seed == 0L) { Modified: trunk/x10.tests/examples/Benchmarks/DistRandomAccess1.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/DistRandomAccess1.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.tests/examples/Benchmarks/DistRandomAccess1.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -22,7 +22,7 @@ const POLY = 0x0000000000000007L; const PERIOD = 1317624576693539401L; - //val places = Rail.makeVal[Place](PARALLELISM, (p:int)=>Place.places(p)); + //val places = ValRail.make[Place](PARALLELISM, (p:int)=>Place.places(p)); final class LocalTable { @@ -31,7 +31,7 @@ def this(size:int) { mask = size-1; - a = Rail.makeVar[long](size, (i:int) => i as long); + a = Rail.make[long](size, (i:int) => i as long); } final def update(ran:long) { @@ -41,12 +41,12 @@ } } - val tables = Rail.makeVal[LocalTable](PARALLELISM, + val tables = ValRail.make[LocalTable](PARALLELISM, (p:nat) => at (Place.places(p)) new LocalTable(localTableSize)); final static def HPCCStarts(var n:long): long { var i:int, j:int; - val m2 = Rail.makeVar[long](64); + val m2 = Rail.make[long](64); while (n < 0) n += PERIOD; while (n > PERIOD) n -= PERIOD; if (n == 0) return 0x1L; @@ -97,7 +97,7 @@ // runs without synchronization and is allowed .01*tableSize errors if (first) { randomAccessUpdate(tables); - val errors = Rail.makeVar[int](1); + val errors = Rail.make[int](1); for (var p:int=0; p<PARALLELISM; p++) { val table = tables(p); finish async(Place.places(p)) { Modified: trunk/x10.tests/examples/Benchmarks/DistStream1.x10 =================================================================== --- trunk/x10.tests/examples/Benchmarks/DistStream1.x10 2009-11-16 04:09:51 UTC (rev 12068) +++ trunk/x10.tests/examples/Benchmarks/DistStream1.x10 2009-11-16 08:25:50 UTC (rev 12069) @@ -20,16 +20,16 @@ // // - val as = Rail.makeVal[Rail[double]](PARALLELISM, (p:int) => - ... [truncated message content] |
From: <ta...@us...> - 2009-11-16 19:56:57
|
Revision: 12080 http://x10.svn.sourceforge.net/x10/?rev=12080&view=rev Author: tardieu Date: 2009-11-16 19:56:49 +0000 (Mon, 16 Nov 2009) Log Message: ----------- enable x86_64 target on osx Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk Modified: trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2009-11-16 18:00:53 UTC (rev 12079) +++ trunk/x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 2009-11-16 19:56:49 UTC (rev 12080) @@ -19,8 +19,6 @@ protected void addPreArgs(ArrayList<String> cxxCmd) { super.addPreArgs(cxxCmd); - // FIXME: for now, only support 32-bit builds - cxxCmd.add("-m32"); } protected void addPostArgs(ArrayList<String> cxxCmd) { Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2009-11-16 18:00:53 UTC (rev 12079) +++ trunk/x10.runtime/src-cpp/Makefile 2009-11-16 19:56:49 UTC (rev 12080) @@ -113,7 +113,7 @@ export X10RT_PLATFORM="cygwin" else ifeq ($(shell uname -s),Darwin) - export X10RT_PLATFORM="darwin" + export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 && echo darwin64 || echo darwin) else ifeq ($(shell uname -s),SunOS) export X10RT_PLATFORM="sunos" Modified: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2009-11-16 18:00:53 UTC (rev 12079) +++ trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2009-11-16 19:56:49 UTC (rev 12080) @@ -63,6 +63,10 @@ WPLATFORM := macos_x86_g++4 SOCKETS_USE := yes endif +ifeq ($(X10RT_PLATFORM), darwin64) + WPLATFORM := macos_x86_64_g++4 + SOCKETS_USE := yes +endif ifeq ($(X10RT_PLATFORM), sunos) WPLATFORM := sunos_sparc_g++4 SOCKETS_USE := yes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-17 18:44:36
|
Revision: 12105 http://x10.svn.sourceforge.net/x10/?rev=12105&view=rev Author: sparksparkspark Date: 2009-11-17 18:44:22 +0000 (Tue, 17 Nov 2009) Log Message: ----------- More CUDA work Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/types/SharedMem.java trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/CudaKernelTest.x10 Modified: trunk/x10.compiler/src/x10cuda/types/SharedMem.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2009-11-17 18:32:42 UTC (rev 12104) +++ trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2009-11-17 18:44:22 UTC (rev 12105) @@ -9,6 +9,7 @@ import polyglot.types.Type; import x10.types.X10TypeSystem; import x10.util.ClassifiedStream; +import x10.util.StreamWrapper; public class SharedMem { @@ -26,6 +27,7 @@ public Decl (LocalDecl ast) { this.ast = ast; } abstract public void generateDef(ClassifiedStream out, String offset); abstract public void generateInit(ClassifiedStream out, String offset); + abstract public void generateSize(StreamWrapper inc); } private static class Rail extends Decl { @@ -44,18 +46,34 @@ out.write("float *"+name+" = (float*) &__shm["+offset+"];"); out.newline(); } public void generateInit(ClassifiedStream out, String offset) { - out.write("for (int i=0 ; i<CLUSTERS*4 ; ++i) {"); out.newline(4); out.begin(0); - out.write("clustercache[i] = /**/local_clusters[i]/**/;"); out.newline(); + out.write("{"); out.newline(4); out.begin(0); + out.write("for (int i=0 ; i<num_clusters*4 ; ++i) {"); out.newline(4); out.begin(0); + out.write("clustercache[i] = /**/clusters_[i]/**/;"); out.newline(); out.end(); out.newline(); out.write("}"); + out.end(); out.newline(); + out.write("}"); } + public void generateSize(StreamWrapper inc) { + // FIXME: hardcoded kmeans code + inc.write("this_->num_clusters*4*sizeof(x10_float)"); + + } } private static class Var extends Decl { public Var (LocalDecl ast) { super(ast); } public void generateDef(ClassifiedStream out, String offset) { + // TODO: not implemented + assert false: "not implemented"; } public void generateInit(ClassifiedStream out, String offset) { + // TODO: not implemented + assert false: "not implemented"; } + public void generateSize(StreamWrapper inc) { + // TODO: not implemented + assert false: "not implemented"; + } } public void addRail(LocalDecl ast, Expr numElements, Expr init) { @@ -100,4 +118,15 @@ */ } + + public void generateSize(StreamWrapper inc) { + // TODO Auto-generated method stub + String prefix = ""; + for (SharedMem.Decl d : decls) { + inc.write(prefix); + d.generateSize(inc); + prefix = " + "; + } + if (prefix.equals("")) inc.write("0"); + } } Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-17 18:32:42 UTC (rev 12104) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-17 18:44:22 UTC (rev 12105) @@ -81,6 +81,10 @@ return cudaStream; } + X10CUDAContext_c established; + public void establishClosure() { established = this; } + public X10CUDAContext_c established() { return established; } + } //vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-17 18:32:42 UTC (rev 12104) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-17 18:44:22 UTC (rev 12105) @@ -441,7 +441,7 @@ assert init_call_target instanceof CanonicalTypeNode; // FIXME: proper error CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; assert init_call_target_node.nameString().equals("Rail"); - assert init_call.name().toString().equals("makeVar") : init_call.name(); // FIXME: proper error + assert init_call.name().toString().equals("make") : init_call.name(); // FIXME: proper error assert init_call.typeArguments().size() == 1; TypeNode rail_type_arg_node = init_call.typeArguments().get(0); Type rail_type_arg = rail_type_arg_node.type(); @@ -486,6 +486,8 @@ b = (Block_c) async_body; context().setCudaKernelCFG(outer.iterations, outer.var, inner.iterations, inner.var, shm); + context().established().setCudaKernelCFG(outer.iterations, outer.var, + inner.iterations, inner.var, shm); generatingKernel(true); handleKernel(b); generatingKernel(false); @@ -493,6 +495,7 @@ } public void visit(Closure_c n) { + context().establishClosure(); String last = context().wrappingClosure(); String lastHostClassName = context().wrappingClass(); X10ClassType hostClassType = (X10ClassType) n.closureDef().typeContainer().get(); @@ -542,7 +545,9 @@ inc.write("blocks = 8;"); inc.newline(); inc.write("threads = 64;"); inc.newline(); - inc.write("shm = 0;"); inc.newline(); + inc.write("shm = "); inc.begin(0); + context().shm().generateSize(inc); + inc.write(";"); inc.end(); inc.newline(); generateStruct("", inc, c.variables); inc.write("_env env;"); inc.newline(); @@ -552,10 +557,21 @@ Type t = var.type(); String name = var.name().toString(); inc.write("env."+name+" = "); + if (isIntRail(t)) { - inc.write("(x10_int*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + if (xts().isRail(t)) { + inc.write("(x10_int*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else { + inc.write("(x10_int*)(size_t)x10aux::remote_alloc(gpu, sizeof(x10_int)*this_->"+name+"->FMGL(length));"); inc.newline(); + inc.write("x10aux::cuda_put(gpu, (x10_ulong) env."+name+", &(*this_->"+name+")[0], sizeof(x10_int)*this_->"+name+"->FMGL(length))"); + } } else if (isFloatRail(t)) { - inc.write("(x10_float*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + if (xts().isRail(t)) { + inc.write("(x10_float*)(size_t)x10aux::get_remote_ref(this_->"+name+".operator->())"); + } else { + inc.write("(x10_float*)(size_t)x10aux::remote_alloc(gpu, sizeof(x10_float)*this_->"+name+"->FMGL(length));"); inc.newline(); + inc.write("x10aux::cuda_put(gpu, (x10_ulong) env."+name+", &(*this_->"+name+")[0], sizeof(x10_float)*this_->"+name+"->FMGL(length))"); + } } else { inc.write("this_->"+name); } Modified: trunk/x10.dist/samples/CudaKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-17 18:32:42 UTC (rev 12104) +++ trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-17 18:44:22 UTC (rev 12105) @@ -6,7 +6,8 @@ static def doWork (init:Rail[Float]!, recv:Rail[Float]!, p:Place, len:Int) { val remote = Rail.makeRemote(p,len,(Int)=>0.0 as Float); // allocate - finish init.copyTo(0, remote, 0, len); // dma there + //finish init.copyTo(0, remote, 0, len); // dma there + val init_ = init as ValRail[Float]; at (p) @Cuda { for ((block):Point in 0..7) { @@ -14,7 +15,8 @@ val tid = block*64 + thread; val tids = 8*64; for (var i:Int=tid ; i<len ; i+=tids) { - remote(i) = Math.sqrt(remote(i)); + //remote(i) = Math.sqrt(remote(i)); + remote(i) = Math.sqrt(init_(i)); } } } @@ -24,8 +26,12 @@ // validate var success:Boolean = true; - for ((i) in 0..remote.length-1) - if (Math.abs(1 - (recv(i)*recv(i))/(i as Float)) > 1E-6f) success = false; + for ((i) in 0..remote.length-1) { + if (Math.abs(1 - (recv(i)*recv(i))/(i as Float)) > 1E-6f) { + Console.ERR.println("recv("+i+"): "+recv(i)+" * "+recv(i)+" = "+(recv(i)*recv(i))); + success = false; + } + } Console.OUT.println((success?"SUCCESS":"FAIL")+" at "+p); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-18 00:27:27
|
Revision: 12114 http://x10.svn.sourceforge.net/x10/?rev=12114&view=rev Author: sparksparkspark Date: 2009-11-18 00:27:19 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Change Cuda to CUDA Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Rail.h trunk/x10.runtime/src-cpp/x10aux/cuda/cuda_utils.h trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-x10/x10/lang/System.x10 Added Paths: ----------- trunk/x10.dist/samples/CUDAKernelTest.x10 trunk/x10.dist/samples/CUDATopology.x10 trunk/x10.runtime/src-x10/x10/compiler/CUDA.x10 Removed Paths: ------------- trunk/x10.dist/samples/CudaKernelTest.x10 trunk/x10.dist/samples/CudaTopology.x10 trunk/x10.runtime/src-x10/x10/compiler/Cuda.x10 Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2009-11-18 00:27:19 UTC (rev 12114) @@ -51,7 +51,7 @@ private Name threadsVar; public Name threadsVar() { return threadsVar; } private SharedMem shm; public SharedMem shm() { return shm; } private ArrayList<VarInstance> kernelParams; public ArrayList<VarInstance> kernelParams() { return kernelParams; } - public void setCudaKernelCFG(Expr blocks, Name blocksVar, Expr threads, Name threadsVar, SharedMem shm) { + public void setCUDAKernelCFG(Expr blocks, Name blocksVar, Expr threads, Name threadsVar, SharedMem shm) { this.blocks = blocks; this.blocksVar = blocksVar; this.threads = threads; Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 00:27:19 UTC (rev 12114) @@ -155,7 +155,7 @@ public class CUDACodeGenerator extends MessagePassingCodeGenerator { - private static final String CUDA_ANNOTATION = "x10.compiler.Cuda"; + private static final String CUDA_ANNOTATION = "x10.compiler.CUDA"; public CUDACodeGenerator(StreamWrapper sw, Translator tr) { super(sw, tr); @@ -194,7 +194,7 @@ // does the block have the annotation that denotes that it should be // split-compiled to cuda? - private boolean nodeHasCudaAnnotation(Node n) { + private boolean nodeHasCUDAAnnotation(Node n) { X10Ext ext = (X10Ext) n.ext(); try { Type cudable = getType(CUDA_ANNOTATION); @@ -228,7 +228,7 @@ return cargo != null && cargo.isInt(); } - String prependCudaType(Type t, String rest) { + String prependCUDAType(Type t, String rest) { String type = Emitter.translateType(t, true); if (isIntRail(t)) { @@ -268,7 +268,7 @@ } else { name = Emitter.mangled_non_method_name(name); } - out.write("__shared__ "+prependCudaType(var.type(),name) + ";"); out.newline(); + out.write("__shared__ "+prependCUDAType(var.type(),name) + ";"); out.newline(); } out.write("if (threadIdx.x==0) {"); out.newline(4); out.begin(0); for (VarInstance var : context().kernelParams()) { @@ -316,7 +316,7 @@ } else { name = Emitter.mangled_non_method_name(name); } - out.write(prependCudaType(var.type(),name) + ";"); + out.write(prependCUDAType(var.type(),name) + ";"); out.newline(); } out.end(); @@ -408,7 +408,7 @@ public void visit(Block_c b) { super.visit(b); - if (nodeHasCudaAnnotation(b)) { + if (nodeHasCUDAAnnotation(b)) { assert !generatingKernel() : "Nesting of cuda annotation makes no sense."; // TODO: assert the block is the body of an async @@ -488,9 +488,9 @@ Block async_body = async_closure.body(); b = (Block_c) async_body; - context().setCudaKernelCFG(outer.max, outer.var, + context().setCUDAKernelCFG(outer.max, outer.var, inner.max, inner.var, shm); - context().established().setCudaKernelCFG(outer.max, outer.var, + context().established().setCUDAKernelCFG(outer.max, outer.var, inner.max, inner.var, shm); generatingKernel(true); handleKernel(b); @@ -516,7 +516,7 @@ protected void generateClosureDeserializationIdDef(StreamWrapper inc, String cnamet, List<Type> freeTypeParams, String hostClassName, Block block) { - if (nodeHasCudaAnnotation(block)) { + if (nodeHasCUDAAnnotation(block)) { X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); boolean in_template_closure = freeTypeParams.size()>0; @@ -539,7 +539,7 @@ protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { super.generateClosureSerializationFunctions(c, cnamet, inc, block); - if (nodeHasCudaAnnotation(block)) { + if (nodeHasCUDAAnnotation(block)) { inc.write("static x10_ulong "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &buf, x10aux::place gpu, size_t &blocks, size_t &threads, size_t &shm) {"); inc.newline(4); inc.begin(0); @@ -603,7 +603,7 @@ } public void visit(New_c n) { - assert !generatingKernel() : "New not allowed in @Cudable code."; + assert !generatingKernel() : "New not allowed in @CUDA code."; super.visit(n); } Copied: trunk/x10.dist/samples/CUDAKernelTest.x10 (from rev 12105, trunk/x10.dist/samples/CudaKernelTest.x10) =================================================================== --- trunk/x10.dist/samples/CUDAKernelTest.x10 (rev 0) +++ trunk/x10.dist/samples/CUDAKernelTest.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -0,0 +1,61 @@ +import x10.io.Console; +import x10.compiler.CUDA; + +public class CUDAKernelTest { + + static def doWork (init:Rail[Float]!, recv:Rail[Float]!, p:Place, len:Int) { + val remote = Rail.makeRemote(p,len,(Int)=>0.0 as Float); // allocate + + //finish init.copyTo(0, remote, 0, len); // dma there + val init_ = init as ValRail[Float]; + + at (p) @CUDA { + for ((block):Point in 0..7) { + for ((thread):Point in 0..63) async { + val tid = block*64 + thread; + val tids = 8*64; + for (var i:Int=tid ; i<len ; i+=tids) { + //remote(i) = Math.sqrt(remote(i)); + remote(i) = Math.sqrt(init_(i)); + } + } + } + } + + finish recv.copyFrom(0, remote, 0, len); // dma back + + // validate + var success:Boolean = true; + for ((i) in 0..remote.length-1) { + if (Math.abs(1 - (recv(i)*recv(i))/(i as Float)) > 1E-6f) { + Console.ERR.println("recv("+i+"): "+recv(i)+" * "+recv(i)+" = "+(recv(i)*recv(i))); + success = false; + } + } + Console.OUT.println((success?"SUCCESS":"FAIL")+" at "+p); + } + + public static def main (args : Rail[String]!) { + val len = args.length==1 ? Int.parseInt(args(0)) : 1000000; + + for (host in Place.places) at (host) { + + val init = Rail.make[Float](len,(i:Int)=>i as Float); + val recv = Rail.make[Float](len,(i:Int)=>0.0 as Float); + + var done_work:Boolean = false; + + for (gpu in here.children()) if (gpu.isCUDA()) { + doWork(init, recv, gpu, len); + done_work = true; + } + + if (!done_work) { + doWork(init, recv, here, len); + } + } + } +} + +// vim: shiftwidth=4:tabstop=4:expandtab + Property changes on: trunk/x10.dist/samples/CUDAKernelTest.x10 ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/x10.dist/samples/CUDATopology.x10 (from rev 12102, trunk/x10.dist/samples/CudaTopology.x10) =================================================================== --- trunk/x10.dist/samples/CUDATopology.x10 (rev 0) +++ trunk/x10.dist/samples/CUDATopology.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -0,0 +1,32 @@ +import x10.io.Console; + +public class CUDATopology { + public static def main (args : Rail[String]) { + for (p in Place.places) { + at (p) { + Console.OUT.println("Dumping places at place: "+p); + for (p2 in Place.places) { + Console.OUT.println("Place: "+p2); + Console.OUT.println(" Parent: "+p2.parent()); + Console.OUT.println(" NumChildren: "+p2.numChildren()); + if (p2.isCUDA()) Console.OUT.println(" Is a CUDA place"); + if (p2.isHost()) Console.OUT.println(" Is a Host place"); + if (p2.isSPE()) Console.OUT.println(" Is a SPE place"); + val children = p2.children(); + for (c in children) { + Console.OUT.println(" Child "+c.childIndex()+": "+c); + Console.OUT.println(" Parent: "+c.parent()); + Console.OUT.println(" NumChildren: "+c.numChildren()); + if (c.isCUDA()) Console.OUT.println(" Is a CUDA place"); + if (c.isHost()) Console.OUT.println(" Is a Host place"); + if (c.isSPE()) Console.OUT.println(" Is a SPE place"); + } + } + Console.OUT.println(); + } + } + } +} + +// vim: shiftwidth=8:tabstop=8:expandtab + Property changes on: trunk/x10.dist/samples/CUDATopology.x10 ___________________________________________________________________ Added: svn:mergeinfo + /branches/itable/x10.dist/samples/CudaTopology.x10:10541-10846 /branches/placeLocal/x10.dist/samples/CudaTopology.x10:11035-11056 Deleted: trunk/x10.dist/samples/CudaKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.dist/samples/CudaKernelTest.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -1,61 +0,0 @@ -import x10.io.Console; -import x10.compiler.Cuda; - -public class CudaKernelTest { - - static def doWork (init:Rail[Float]!, recv:Rail[Float]!, p:Place, len:Int) { - val remote = Rail.makeRemote(p,len,(Int)=>0.0 as Float); // allocate - - //finish init.copyTo(0, remote, 0, len); // dma there - val init_ = init as ValRail[Float]; - - at (p) @Cuda { - for ((block):Point in 0..7) { - for ((thread):Point in 0..63) async { - val tid = block*64 + thread; - val tids = 8*64; - for (var i:Int=tid ; i<len ; i+=tids) { - //remote(i) = Math.sqrt(remote(i)); - remote(i) = Math.sqrt(init_(i)); - } - } - } - } - - finish recv.copyFrom(0, remote, 0, len); // dma back - - // validate - var success:Boolean = true; - for ((i) in 0..remote.length-1) { - if (Math.abs(1 - (recv(i)*recv(i))/(i as Float)) > 1E-6f) { - Console.ERR.println("recv("+i+"): "+recv(i)+" * "+recv(i)+" = "+(recv(i)*recv(i))); - success = false; - } - } - Console.OUT.println((success?"SUCCESS":"FAIL")+" at "+p); - } - - public static def main (args : Rail[String]!) { - val len = args.length==1 ? Int.parseInt(args(0)) : 1000000; - - for (host in Place.places) at (host) { - - val init = Rail.make[Float](len,(i:Int)=>i as Float); - val recv = Rail.make[Float](len,(i:Int)=>0.0 as Float); - - var done_work:Boolean = false; - - for (gpu in here.children()) if (gpu.isCUDA()) { - doWork(init, recv, gpu, len); - done_work = true; - } - - if (!done_work) { - doWork(init, recv, here, len); - } - } - } -} - -// vim: shiftwidth=4:tabstop=4:expandtab - Deleted: trunk/x10.dist/samples/CudaTopology.x10 =================================================================== --- trunk/x10.dist/samples/CudaTopology.x10 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.dist/samples/CudaTopology.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -1,32 +0,0 @@ -import x10.io.Console; - -public class CudaTopology { - public static def main (args : Rail[String]) { - for (p in Place.places) { - at (p) { - Console.OUT.println("Dumping places at place: "+p); - for (p2 in Place.places) { - Console.OUT.println("Place: "+p2); - Console.OUT.println(" Parent: "+p2.parent()); - Console.OUT.println(" NumChildren: "+p2.numChildren()); - if (p2.isCUDA()) Console.OUT.println(" Is a CUDA place"); - if (p2.isHost()) Console.OUT.println(" Is a Host place"); - if (p2.isSPE()) Console.OUT.println(" Is a SPE place"); - val children = p2.children(); - for (c in children) { - Console.OUT.println(" Child "+c.childIndex()+": "+c); - Console.OUT.println(" Parent: "+c.parent()); - Console.OUT.println(" NumChildren: "+c.numChildren()); - if (c.isCUDA()) Console.OUT.println(" Is a CUDA place"); - if (c.isHost()) Console.OUT.println(" Is a Host place"); - if (c.isSPE()) Console.OUT.println(" Is a SPE place"); - } - } - Console.OUT.println(); - } - } - } -} - -// vim: shiftwidth=8:tabstop=8:expandtab - Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.h 2009-11-18 00:27:19 UTC (rev 12114) @@ -114,7 +114,7 @@ template<class S> static x10aux::ref<S> _deserialize(x10aux::deserialization_buffer &buf); - static R makeCuda(x10::lang::Place p, x10_int length); + static R makeCUDA(x10::lang::Place p, x10_int length); static const x10aux::serialization_id_t _copy_to_serialization_id; @@ -296,7 +296,7 @@ } - template <class T> x10aux::ref<Rail<T> > Rail<T>::makeCuda(x10::lang::Place p, + template <class T> x10aux::ref<Rail<T> > Rail<T>::makeCUDA(x10::lang::Place p, x10_int length) { // create a local proxy with the right size, but rather than Modified: trunk/x10.runtime/src-cpp/x10aux/cuda/cuda_utils.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/cuda/cuda_utils.h 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-cpp/x10aux/cuda/cuda_utils.h 2009-11-18 00:27:19 UTC (rev 12114) @@ -44,7 +44,7 @@ return (T*) mem; } - template<class T> class CudaRail { + template<class T> class CUDARail { protected: @@ -55,7 +55,7 @@ public: - CudaRail (x10_int length) { + CUDARail (x10_int length) { cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>(); cudaArray *mem; CU_ASSERT(cudaMallocArray(&mem, &desc, num, 1)); Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc 2009-11-18 00:27:19 UTC (rev 12114) @@ -24,7 +24,7 @@ } serialization_id_t DeserializationDispatcher::addDeserializer (Deserializer deser, bool is_async, - CudaPre cuda_pre, + CUDAPre cuda_pre, const char *cubin, const char *kernel) { @@ -44,7 +44,7 @@ } serialization_id_t DeserializationDispatcher::addDeserializer_ (Deserializer deser, bool is_async, - CudaPre cuda_pre, + CUDAPre cuda_pre, const char *cubin, const char *kernel) { @@ -63,7 +63,7 @@ return r; } -CudaPre DeserializationDispatcher::getCudaPre_(serialization_id_t id) +CUDAPre DeserializationDispatcher::getCUDAPre_(serialization_id_t id) { return data_v[id].cuda_pre; } @@ -103,10 +103,10 @@ Notifier DeserializationDispatcher::getPutNotifier_ (serialization_id_t id) { return data_v[id].put_notifier; } -BufferFinder DeserializationDispatcher::getCudaPutBufferFinder_ (serialization_id_t id) +BufferFinder DeserializationDispatcher::getCUDAPutBufferFinder_ (serialization_id_t id) { return data_v[id].cuda_put_bfinder; } -Notifier DeserializationDispatcher::getCudaPutNotifier_ (serialization_id_t id) +Notifier DeserializationDispatcher::getCUDAPutNotifier_ (serialization_id_t id) { return data_v[id].cuda_put_notifier; } serialization_id_t DeserializationDispatcher::addGetFunctions (BufferFinder bfinder, @@ -141,10 +141,10 @@ Notifier DeserializationDispatcher::getGetNotifier_ (serialization_id_t id) { return data_v[id].get_notifier; } -BufferFinder DeserializationDispatcher::getCudaGetBufferFinder_ (serialization_id_t id) +BufferFinder DeserializationDispatcher::getCUDAGetBufferFinder_ (serialization_id_t id) { return data_v[id].cuda_get_bfinder; } -Notifier DeserializationDispatcher::getCudaGetNotifier_ (serialization_id_t id) +Notifier DeserializationDispatcher::getCUDAGetNotifier_ (serialization_id_t id) { return data_v[id].cuda_get_notifier; } x10aux::msg_type DeserializationDispatcher::getMsgType_ (serialization_id_t id) { Modified: trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h 2009-11-18 00:27:19 UTC (rev 12114) @@ -15,9 +15,9 @@ typedef ref<x10::lang::Ref> (*Deserializer)(deserialization_buffer &buf); template<> inline const char *typeName<Deserializer>() { return "Deserializer"; } - typedef x10_ulong (*CudaPre)(deserialization_buffer &buf, place p, + typedef x10_ulong (*CUDAPre)(deserialization_buffer &buf, place p, size_t &blocks, size_t &threads, size_t &shm); - template<> inline const char *typeName<CudaPre>() { return "CudaPre"; } + template<> inline const char *typeName<CUDAPre>() { return "CUDAPre"; } typedef void *(*BufferFinder)(deserialization_buffer &buf, x10_int len); template<> inline const char *typeName<BufferFinder>() { return "BufferFinder"; } @@ -43,7 +43,7 @@ Notifier cuda_get_notifier; Deserializer deser; - CudaPre cuda_pre; + CUDAPre cuda_pre; const char *cubin; const char *kernel; @@ -72,15 +72,15 @@ ref<x10::lang::Ref> create_(deserialization_buffer &buf, serialization_id_t id); static serialization_id_t addDeserializer (Deserializer deser, bool is_async=false, - CudaPre cuda_pre = NULL, + CUDAPre cuda_pre = NULL, const char *cubin = NULL, const char *kernel = NULL); serialization_id_t addDeserializer_ (Deserializer deser, bool is_async, - CudaPre cuda_pre, + CUDAPre cuda_pre, const char *cubin, const char *kernel); - static CudaPre getCudaPre(serialization_id_t id); - CudaPre getCudaPre_(serialization_id_t id); + static CUDAPre getCUDAPre(serialization_id_t id); + CUDAPre getCUDAPre_(serialization_id_t id); static serialization_id_t addPutFunctions(BufferFinder bfinder, Notifier notifier, BufferFinder cuda_bfinder, Notifier cuda_notifier); @@ -90,10 +90,10 @@ BufferFinder getPutBufferFinder_(serialization_id_t id); static Notifier getPutNotifier(serialization_id_t id); Notifier getPutNotifier_(serialization_id_t id); - static BufferFinder getCudaPutBufferFinder(serialization_id_t id); - BufferFinder getCudaPutBufferFinder_(serialization_id_t id); - static Notifier getCudaPutNotifier(serialization_id_t id); - Notifier getCudaPutNotifier_(serialization_id_t id); + static BufferFinder getCUDAPutBufferFinder(serialization_id_t id); + BufferFinder getCUDAPutBufferFinder_(serialization_id_t id); + static Notifier getCUDAPutNotifier(serialization_id_t id); + Notifier getCUDAPutNotifier_(serialization_id_t id); static serialization_id_t addGetFunctions(BufferFinder bfinder, Notifier notifier, BufferFinder cuda_bfinder, Notifier cuda_notifier); @@ -103,10 +103,10 @@ BufferFinder getGetBufferFinder_(serialization_id_t id); static Notifier getGetNotifier(serialization_id_t id); Notifier getGetNotifier_(serialization_id_t id); - static BufferFinder getCudaGetBufferFinder(serialization_id_t id); - BufferFinder getCudaGetBufferFinder_(serialization_id_t id); - static Notifier getCudaGetNotifier(serialization_id_t id); - Notifier getCudaGetNotifier_(serialization_id_t id); + static BufferFinder getCUDAGetBufferFinder(serialization_id_t id); + BufferFinder getCUDAGetBufferFinder_(serialization_id_t id); + static Notifier getCUDAGetNotifier(serialization_id_t id); + Notifier getCUDAGetNotifier_(serialization_id_t id); static x10aux::msg_type getMsgType(serialization_id_t id); x10aux::msg_type getMsgType_(serialization_id_t id); @@ -118,8 +118,8 @@ void registerHandlers_(void); }; - inline CudaPre DeserializationDispatcher::getCudaPre (serialization_id_t id) - { return it->getCudaPre_(id); } + inline CUDAPre DeserializationDispatcher::getCUDAPre (serialization_id_t id) + { return it->getCUDAPre_(id); } inline BufferFinder DeserializationDispatcher::getPutBufferFinder (serialization_id_t id) @@ -134,17 +134,17 @@ inline Notifier DeserializationDispatcher::getGetNotifier (serialization_id_t id) { return it->getGetNotifier_(id); } - inline BufferFinder DeserializationDispatcher::getCudaPutBufferFinder (serialization_id_t id) - { return it->getCudaPutBufferFinder_(id); } + inline BufferFinder DeserializationDispatcher::getCUDAPutBufferFinder (serialization_id_t id) + { return it->getCUDAPutBufferFinder_(id); } - inline BufferFinder DeserializationDispatcher::getCudaGetBufferFinder (serialization_id_t id) - { return it->getCudaGetBufferFinder_(id); } + inline BufferFinder DeserializationDispatcher::getCUDAGetBufferFinder (serialization_id_t id) + { return it->getCUDAGetBufferFinder_(id); } - inline Notifier DeserializationDispatcher::getCudaPutNotifier (serialization_id_t id) - { return it->getCudaPutNotifier_(id); } + inline Notifier DeserializationDispatcher::getCUDAPutNotifier (serialization_id_t id) + { return it->getCUDAPutNotifier_(id); } - inline Notifier DeserializationDispatcher::getCudaGetNotifier (serialization_id_t id) - { return it->getCudaGetNotifier_(id); } + inline Notifier DeserializationDispatcher::getCUDAGetNotifier (serialization_id_t id) + { return it->getCUDAGetNotifier_(id); } inline x10aux::msg_type DeserializationDispatcher::getMsgType (serialization_id_t id) Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-18 00:27:19 UTC (rev 12114) @@ -37,7 +37,7 @@ buf.read<x10_ulong>(); x10_ulong remote_addr = buf.read<x10_ulong>(); assert(buf.consumed() <= p.len); - _X_(ANSI_X10RT<<"Cuda kernel populating: "<<remote_addr<<ANSI_RESET); + _X_(ANSI_X10RT<<"CUDA kernel populating: "<<remote_addr<<ANSI_RESET); return (void*)(size_t)remote_addr; } @@ -201,7 +201,7 @@ buf.read<x10::runtime::RID>(); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); - x10aux::CudaPre pre = x10aux::DeserializationDispatcher::getCudaPre(sid); + x10aux::CUDAPre pre = x10aux::DeserializationDispatcher::getCUDAPre(sid); x10_ulong env = pre(buf, p.dest_place, blocks, threads, shm); assert(buf.consumed() <= p.len); return (void*)(size_t)env; @@ -244,7 +244,7 @@ x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); - x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCudaPutBufferFinder(sid); + x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCUDAPutBufferFinder(sid); void *dropzone = bf(buf,len); assert(buf.consumed() <= p.len); return dropzone; @@ -266,7 +266,7 @@ x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); - x10aux::Notifier n = x10aux::DeserializationDispatcher::getCudaPutNotifier(sid); + x10aux::Notifier n = x10aux::DeserializationDispatcher::getCUDAPutNotifier(sid); n(buf,len); assert(buf.consumed() <= p.len); deserialized_bytes += buf.consumed() ; asyncs_received++; @@ -294,7 +294,7 @@ x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); - x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCudaGetBufferFinder(sid); + x10aux::BufferFinder bf = x10aux::DeserializationDispatcher::getCUDAGetBufferFinder(sid); void *dropzone = bf(buf,len); assert(buf.consumed() <= p.len); deserialized_bytes += buf.consumed() ; asyncs_received++; @@ -317,7 +317,7 @@ x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); - x10aux::Notifier n = x10aux::DeserializationDispatcher::getCudaGetNotifier(sid); + x10aux::Notifier n = x10aux::DeserializationDispatcher::getCUDAGetNotifier(sid); n(buf,len); assert(buf.consumed() <= p.len); deserialized_bytes += buf.consumed() ; asyncs_received++; Copied: trunk/x10.runtime/src-x10/x10/compiler/CUDA.x10 (from rev 12102, trunk/x10.runtime/src-x10/x10/compiler/Cuda.x10) =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/CUDA.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/CUDA.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -0,0 +1,11 @@ +/* + * + * (C) Copyright IBM Corporation 2006-2008. + * + * This file is part of X10 Language. + * + */ + +package x10.compiler; + +public interface CUDA { }; Property changes on: trunk/x10.runtime/src-x10/x10/compiler/CUDA.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + /branches/itable/x10.runtime.17/src-x10/x10/compiler/Cuda.x10:10541-10846 /branches/placeLocal/x10.runtime/src-x10/x10/compiler/Cuda.x10:11035-11056 Added: svn:eol-style + native Deleted: trunk/x10.runtime/src-x10/x10/compiler/Cuda.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Cuda.x10 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-x10/x10/compiler/Cuda.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -1,11 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.compiler; - -public interface Cuda { }; Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-11-18 00:04:04 UTC (rev 12113) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2009-11-18 00:27:19 UTC (rev 12114) @@ -224,7 +224,7 @@ */ - @Native("c++", "x10::lang::Rail<#1>::makeCuda(#4,#5)") + @Native("c++", "x10::lang::Rail<#1>::makeCUDA(#4,#5)") private static def cudaMakeRail[T] (dst:Place, length:Int) : Rail[T]{self.length==length} { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-18 10:42:06
|
Revision: 12117 http://x10.svn.sourceforge.net/x10/?rev=12117&view=rev Author: sparksparkspark Date: 2009-11-18 10:41:46 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Allow threads/blocks to be arbitrary expressions (not semantics preserving if the threads expression has side-effects) Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/KMeansCUDA.x10 Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 10:35:11 UTC (rev 12116) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2009-11-18 10:41:46 UTC (rev 12117) @@ -541,53 +541,53 @@ if (nodeHasCUDAAnnotation(block)) { - inc.write("static x10_ulong "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &buf, x10aux::place gpu, size_t &blocks, size_t &threads, size_t &shm) {"); + inc.write("static x10_ulong "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &__buf, x10aux::place __gpu, size_t &__blocks, size_t &__threads, size_t &__shm) {"); inc.newline(4); inc.begin(0); - inc.write(make_ref(cnamet)+" this_ = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(buf);"); + inc.write(make_ref(cnamet)+" __this = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(__buf);"); inc.newline(); for (int i = 0; i < c.variables.size(); i++) { VarInstance var = (VarInstance) c.variables.get(i); Type t = var.type(); String name = var.name().toString(); - inc.write(Emitter.translateType(t, true)+" "+name+" = this_->"+name+";"); inc.newline(); + inc.write(Emitter.translateType(t, true)+" "+name+" = __this->"+name+";"); inc.newline(); } - inc.write("blocks = ("); inc.begin(0); + inc.write("__blocks = ("); inc.begin(0); tr.print(null, context().blocks(), inc); inc.write(")+1;"); inc.end(); inc.newline(); - inc.write("threads = ("); inc.begin(0); + inc.write("__threads = ("); inc.begin(0); tr.print(null, context().threads(), inc); inc.write(")+1;"); inc.end(); inc.newline(); - inc.write("shm = "); inc.begin(0); + inc.write("__shm = "); inc.begin(0); context().shm().generateSize(inc, tr); inc.write(";"); inc.end(); inc.newline(); - generateStruct("", inc, c.variables); - inc.write("_env env;"); inc.newline(); + generateStruct("__", inc, c.variables); + inc.write("___env __env;"); inc.newline(); for (int i = 0; i < c.variables.size(); i++) { VarInstance var = (VarInstance) c.variables.get(i); Type t = var.type(); String name = var.name().toString(); - inc.write("env."+name+" = "); + inc.write("__env."+name+" = "); if (isIntRail(t)) { if (xts().isRail(t)) { inc.write("(x10_int*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); } else { - inc.write("(x10_int*)(size_t)x10aux::remote_alloc(gpu, sizeof(x10_int)*"+name+"->FMGL(length));"); inc.newline(); - inc.write("x10aux::cuda_put(gpu, (x10_ulong) env."+name+", &(*"+name+")[0], sizeof(x10_int)*"+name+"->FMGL(length))"); + inc.write("(x10_int*)(size_t)x10aux::remote_alloc(__gpu, sizeof(x10_int)*"+name+"->FMGL(length));"); inc.newline(); + inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", &(*"+name+")[0], sizeof(x10_int)*"+name+"->FMGL(length))"); } } else if (isFloatRail(t)) { if (xts().isRail(t)) { inc.write("(x10_float*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); } else { - inc.write("(x10_float*)(size_t)x10aux::remote_alloc(gpu, sizeof(x10_float)*"+name+"->FMGL(length));"); inc.newline(); - inc.write("x10aux::cuda_put(gpu, (x10_ulong) env."+name+", &(*"+name+")[0], sizeof(x10_float)*"+name+"->FMGL(length))"); + inc.write("(x10_float*)(size_t)x10aux::remote_alloc(__gpu, sizeof(x10_float)*"+name+"->FMGL(length));"); inc.newline(); + inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", &(*"+name+")[0], sizeof(x10_float)*"+name+"->FMGL(length))"); } } else { inc.write(name); @@ -595,9 +595,9 @@ inc.write(";"); inc.newline(); } - inc.write("x10_ulong remote_env = x10aux::remote_alloc(gpu, sizeof(env));"); inc.newline(); - inc.write("x10aux::cuda_put(gpu, remote_env, &env, sizeof(env));"); inc.newline(); - inc.write("return remote_env;"); inc.end(); inc.newline(); + inc.write("x10_ulong __remote_env = x10aux::remote_alloc(__gpu, sizeof(__env));"); inc.newline(); + inc.write("x10aux::cuda_put(__gpu, __remote_env, &__env, sizeof(__env));"); inc.newline(); + inc.write("return __remote_env;"); inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); } } Modified: trunk/x10.dist/samples/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 10:35:11 UTC (rev 12116) +++ trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 10:41:46 UTC (rev 12117) @@ -36,7 +36,7 @@ num_global_points=opts("-n", 100000), iterations=opts("-i",500); val MEM_ALIGN = 32; // FOR CUDA - Console.OUT.println("points: "+num_global_points+" dim: "+4); + Console.OUT.println("points: "+num_global_points+" clusters: "+num_clusters+" dim: "+4); // file is dimension-major val fr = (new File(fname)).openRead(); @@ -80,12 +80,13 @@ val kernel_start_time = System.currentTimeMillis(); // classify kernel + val blocks = 8, threads = 64; at (gpu) @CUDA { - for ((block) in 0..15) { + for ((block) in 0..blocks-1) { val clustercache = Rail.make[Float](num_clusters*4, clusters_copy); - for ((thread) in 0..63) async { - val tid = block * 64 + thread; - val tids = 16 * 64; + for ((thread) in 0..threads-1) async { + val tid = block * threads + thread; + val tids = blocks * threads; for (var p:Int=tid ; p<num_local_points ; p+=tids) { var closest:Int = -1; var closest_dist:Float = Float.MAX_VALUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2009-11-18 13:53:06
|
Revision: 12118 http://x10.svn.sourceforge.net/x10/?rev=12118&view=rev Author: sparksparkspark Date: 2009-11-18 13:52:57 +0000 (Wed, 18 Nov 2009) Log Message: ----------- 1) Ignore wget failure when building x10rt if there is a tar already present 2) Implement automatic blocks/threads detection at x10rt level Modified Paths: -------------- trunk/x10.dist/samples/KMeansCUDA.x10 trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk Modified: trunk/x10.dist/samples/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.dist/samples/KMeansCUDA.x10 2009-11-18 13:52:57 UTC (rev 12118) @@ -80,7 +80,7 @@ val kernel_start_time = System.currentTimeMillis(); // classify kernel - val blocks = 8, threads = 64; + val blocks = 4, threads = 256; at (gpu) @CUDA { for ((block) in 0..blocks-1) { val clustercache = Rail.make[Float](num_clusters*4, clusters_copy); Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-11-18 13:52:57 UTC (rev 12118) @@ -31,6 +31,64 @@ volatile x10_long x10aux::serialized_bytes = 0; volatile x10_long x10aux::deserialized_bytes = 0; + +const int cuda_kernel_cfgs[] = { + /*1024*/ 8, 128, + /*1024*/ 4, 256, + /*1024*/ 2, 512, + + /*960*/ 5, 192, + /*960*/ 3, 320, + + /*896*/ 7, 128, + /*896*/ 2, 448, + + /*768*/ 6, 128, + /*768*/ 4, 192, + /*768*/ 3, 256, + /*768*/ 2, 384, + + /*640*/ 5, 128, + /*640*/ 2, 320, + + /*576*/ 3, 192, + + /*512*/ 8, 64, + /*512*/ 4, 128, + /*512*/ 2, 256, + /*512*/ 1, 512, + + /*448*/ 7, 64, + /*448*/ 1, 448, + + /*384*/ 6, 64, + /*384*/ 3, 128, + /*384*/ 2, 192, + /*384*/ 1, 384, + + /*320*/ 5, 64, + /*320*/ 1, 320, + + /*256*/ 4, 64, + /*256*/ 2, 128, + /*256*/ 1, 256, + + /*192*/ 3, 64, + /*192*/ 1, 192, + + /*128*/ 2, 64, + /*128*/ 1, 128, + + /*64*/ 1, 64, + + 0 /* terminator */ +}; + +void x10aux::blocks_threads (place p, msg_type t, int shm, int &bs, int &ts, const int *cfgs) +{ x10rt_blocks_threads(p,t,shm,bs,ts,cfgs); } + + + void *kernel_put_finder (const x10rt_msg_params &p, x10rt_copy_sz) { x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); Modified: trunk/x10.runtime/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.h 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10aux/network.h 2009-11-18 13:52:57 UTC (rev 12118) @@ -36,7 +36,10 @@ inline x10_boolean is_cuda (place p) { return x10rt_is_cuda(p); } inline void event_probe (void) { x10rt_probe(); } + extern const int cuda_cfgs[]; + void blocks_threads (place p, msg_type t, int shm, int &bs, int &ts, const int *cfgs=cuda_cfgs); + inline x10_ulong remote_alloc (place p, size_t sz) { _X_(ANSI_BOLD<<ANSI_X10RT<<"Remote alloc: "<<ANSI_RESET <<"size "<<sz<<" to place: "<<p); Modified: trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/common/x10rt_cuda.cc 2009-11-18 13:52:57 UTC (rev 12118) @@ -238,8 +238,9 @@ }; }; - static void ensure_initialized (void) + void ensure_initialized (void) { + // only do once per process static int done = 0; if (!done) { CU_SAFE(cuInit(0)); @@ -247,6 +248,16 @@ } } + bool stream_ready (CUstream s) + { + CUresult r = cuStreamQuery(s); + if (r==CUDA_ERROR_NOT_READY) return false; + CU_SAFE(r); + return true; + } + + int round_up (int x, int y) { return (x + (y-1)) / y * y; } + } struct x10rt_cuda_ctx { @@ -509,20 +520,20 @@ pthread_mutex_lock(&big_lock_of_doom); if (ctx->cbs.arrc <= p.type) { - fprintf(stderr,"X10RT: Kernel %llu is invalid.\n", (unsigned long long)p.type); + fprintf(stderr,"X10RT: async %lu is invalid.\n", (unsigned long)p.type); abort(); } - if (ctx->cbs[p.type].kernel_cbs.pre == NULL) { - fprintf(stderr,"X10RT: Kernel %llu has no 'pre' registered.\n", (unsigned long long)p.type); - abort(); - } if (ctx->cbs[p.type].kernel_cbs.kernel == NULL) { - fprintf(stderr,"X10RT: Kernel %llu has no kernel registered.\n",(unsigned long long)p.type); + fprintf(stderr,"X10RT: async %lu is not a CUDA kernel.\n",(unsigned long)p.type); abort(); } + if (ctx->cbs[p.type].kernel_cbs.pre == NULL) { + fprintf(stderr,"X10RT: CUDA Kernel %lu has no 'pre' registered.\n", (unsigned long)p.type); + abort(); + } if (ctx->cbs[p.type].kernel_cbs.post == NULL) { - fprintf(stderr,"X10RT: Kernel %llu has no 'post' registered.\n",(unsigned long long)p.type); + fprintf(stderr,"X10RT: CUDA Kernel %lu has no 'post' registered.\n",(unsigned long)p.type); abort(); } @@ -539,15 +550,69 @@ } + +void x10rt_cuda_blocks_threads (x10rt_cuda_ctx *ctx, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg) +{ #ifdef ENABLE_CUDA -static bool stream_ready (CUstream s) -{ - CUresult r = cuStreamQuery(s); - if (r==CUDA_ERROR_NOT_READY) return false; - CU_SAFE(r); - return true; + if (ctx->cbs.arrc <= type) { + fprintf(stderr,"X10RT: async %lu is invalid.\n", (unsigned long)type); + abort(); + } + if (ctx->cbs[type].kernel_cbs.kernel == NULL) { + fprintf(stderr,"X10RT: async %lu is not a CUDA kernel.\n",(unsigned long)type); + abort(); + } + CUfunction k = ctx->cbs[type].kernel_cbs.kernel; + + pthread_mutex_lock(&big_lock_of_doom); + CU_SAFE(cuCtxPushCurrent(ctx->ctx)); + + int mps, max_shm; + CU_SAFE(cuDeviceGetAttribute(&mps, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, ctx->hw)); + CU_SAFE(cuDeviceGetAttribute(&max_shm,CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK,ctx->hw)); + + CUdevprop prop; + CU_SAFE(cuDeviceGetProperties(&prop, ctx->hw)); + int max_regs = prop.regsPerBlock; + + int major, minor; + CU_SAFE(cuDeviceComputeCapability(&major, &minor, ctx->hw)); + + + int static_shm, regs; + CU_SAFE(cuFuncGetAttribute(&static_shm, CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES, k)); + CU_SAFE(cuFuncGetAttribute(®s, CU_FUNC_ATTRIBUTE_NUM_REGS, k)); + + CU_SAFE(cuCtxPopCurrent(NULL)); + pthread_mutex_unlock(&big_lock_of_doom); + + // round up to 512 bytes (the granularity of shm allocation) + int shm = round_up(dyn_shm + static_shm, 512); + + int alloc_size = (minor>=2) ? 512 : 256; + int max_threads = (minor>=2) ? 1024 : 768; + + while (*cfg) { + int b = *(cfg++); + int t = *(cfg++); + if (b*shm > max_shm) continue; + if (t*b > max_threads) continue; + int block_regs = round_up(regs*round_up(t,64), alloc_size); + if (b*block_regs > max_regs) continue; + blocks = b * mps; + threads = t; + return; + } + + blocks = 0; + threads = 0; + +#else + (void)ctx; (void)msg_type; (void)dyn_shm; (void)blocks; (void)threads; (void)cfg; + abort(); +#endif } -#endif void x10rt_cuda_probe (x10rt_cuda_ctx *ctx) Modified: trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/common/x10rt_front.cc 2009-11-18 13:52:57 UTC (rev 12118) @@ -96,6 +96,11 @@ { x10rt_lgl_remote_op_fence(); } +void x10rt_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg) +{ x10rt_lgl_blocks_threads (d, type, dyn_shm, blocks, threads, cfg); } + + void x10rt_probe (void) { x10rt_lgl_probe(); } Modified: trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/common/x10rt_logical.cc 2009-11-18 13:52:57 UTC (rev 12118) @@ -705,6 +705,36 @@ x10rt_net_remote_op_fence(); } +void x10rt_lgl_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg) +{ + assert(d < x10rt_lgl_nplaces()); + + if (d < x10rt_lgl_nhosts()) { + blocks = 8; threads = 1; + } else if (x10rt_lgl_parent(d) == x10rt_lgl_here()) { + // local accelerator + switch (x10rt_lgl_type(d)) { + case X10RT_LGL_CUDA: { + x10rt_cuda_ctx *cctx = static_cast<x10rt_cuda_ctx*>(g.accel_ctxs[g.index[d]]); + x10rt_cuda_blocks_threads(cctx, type, dyn_shm, blocks, threads, cfg); + } break; + case X10RT_LGL_SPE: { + blocks = 8; threads = 1; + } break; + default: { + fprintf(stderr,"Place %lu has invalid type %d in remote_op_xor.\n", + d, x10rt_lgl_type(d)); + abort(); + } + } + } else { + fprintf(stderr,"Routing of remote ops still unsupported.\n"); + abort(); + } +} + + void x10rt_lgl_probe (void) { x10rt_net_probe(); Modified: trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/include/x10rt_cuda.h 2009-11-18 13:52:57 UTC (rev 12118) @@ -28,6 +28,9 @@ void x10rt_cuda_send_put (x10rt_cuda_ctx *ctx, x10rt_msg_params &, void *buf, x10rt_copy_sz len); +void x10rt_cuda_blocks_threads (x10rt_cuda_ctx *ctx, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg); + void *x10rt_cuda_device_alloc (x10rt_cuda_ctx *ctx, size_t sz); void x10rt_cuda_device_free (x10rt_cuda_ctx *ctx, void *ptr); Modified: trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/include/x10rt_front.h 2009-11-18 13:52:57 UTC (rev 12118) @@ -43,6 +43,9 @@ void x10rt_remote_op_fence (void); +void x10rt_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg); + void x10rt_probe (void); void x10rt_finalize (void); Modified: trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/include/x10rt_logical.h 2009-11-18 13:52:57 UTC (rev 12118) @@ -58,6 +58,9 @@ void x10rt_lgl_remote_op_fence (void); +void x10rt_lgl_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm, + int &blocks, int &threads, const int *cfg); + void x10rt_lgl_probe (void); void x10rt_lgl_finalize (void); Modified: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2009-11-18 10:41:46 UTC (rev 12117) +++ trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2009-11-18 13:52:57 UTC (rev 12118) @@ -101,7 +101,7 @@ $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) else $(SOCKETS_TGZ).phony: - $(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(SOCKETS_TGZ)" + -$(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(SOCKETS_TGZ)" $(SOCKETS_TGZ): $(SOCKETS_TGZ).phony @@ -142,7 +142,7 @@ $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) else $(LAPI_TGZ).phony: - $(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(LAPI_TGZ)" + -$(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(LAPI_TGZ)" $(LAPI_TGZ): $(LAPI_TGZ).phony @@ -179,7 +179,7 @@ $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) else $(BGP_TGZ).phony: - $(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(BGP_TGZ)" + -$(WGET) -N "http://dist.codehaus.org/x10/binaryReleases/svn head/$(BGP_TGZ)" $(BGP_TGZ): $(BGP_TGZ).phony This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2009-11-18 17:05:24
|
Revision: 12123 http://x10.svn.sourceforge.net/x10/?rev=12123&view=rev Author: ipeshansky Date: 2009-11-18 17:05:16 +0000 (Wed, 18 Nov 2009) Log Message: ----------- Ignore generated files. Property Changed: ---------------- trunk/x10.dist/bin/ trunk/x10.runtime/src-cpp/x10rt/bin/ trunk/x10.runtime/src-cpp/x10rt/etc/ trunk/x10.runtime/src-cpp/x10rt/include/ trunk/x10.runtime/src-cpp/x10rt/lib/ trunk/x10.runtime/src-cpp/x10rt/test/ Property changes on: trunk/x10.dist/bin ___________________________________________________________________ Modified: svn:ignore - x10 x10c setupX10 + x10 x10c setupX10 daemon launcher manager daemon.exe launcher.exe manager.exe Property changes on: trunk/x10.runtime/src-cpp/x10rt/bin ___________________________________________________________________ Added: svn:ignore + daemon launcher manager daemon.exe launcher.exe manager.exe Property changes on: trunk/x10.runtime/src-cpp/x10rt/etc ___________________________________________________________________ Modified: svn:ignore - x10rt_mpi.properties x10rt_standalone.properties + x10rt_mpi.properties x10rt_standalone.properties x10rt_pgas_sockets.properties x10rt_pgas_lapi.properties Property changes on: trunk/x10.runtime/src-cpp/x10rt/include ___________________________________________________________________ Added: svn:ignore + pgasrt.h pgasrt_*.h xlupc_*.h Property changes on: trunk/x10.runtime/src-cpp/x10rt/lib ___________________________________________________________________ Modified: svn:ignore - libx10rt_standalone.a + libx10rt_mpi.a libx10rt_standalone.a libx10rt_pgas_sockets.a libx10rt_pgas_lapi.a Property changes on: trunk/x10.runtime/src-cpp/x10rt/test ___________________________________________________________________ Modified: svn:ignore - x10rt_basic.mpi x10rt_basic.standalone x10rt_gups.mpi x10rt_gups.standalone + x10rt_basic.mpi x10rt_basic.standalone x10rt_basic.pgas_sockets x10rt_basic.pgas_lapi x10rt_gups.mpi x10rt_gups.standalone x10rt_gups.pgas_sockets x10rt_gups.pgas_lapi x10rt_topology.mpi x10rt_topology.standalone x10rt_topology.pgas_sockets x10rt_topology.pgas_lapi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |