From: <spa...@us...> - 2010-02-03 20:29:43
|
Revision: 12793 http://x10.svn.sourceforge.net/x10/?rev=12793&view=rev Author: sparksparkspark Date: 2010-02-03 20:28:53 +0000 (Wed, 03 Feb 2010) Log Message: ----------- Handle passing null pointers to CUDA Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/Object.h trunk/x10.runtime/src-cpp/x10aux/ref.h Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-02-03 20:28:53 UTC (rev 12793) @@ -619,14 +619,14 @@ if (isIntRail(t)) { if (xts().isRail(t)) { - inc.write("(x10_int*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); + inc.write("(x10_int*)(size_t)x10aux::get_remote_ref_maybe_null("+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))"); } } else if (isFloatRail(t)) { if (xts().isRail(t)) { - inc.write("(x10_float*)(size_t)x10aux::get_remote_ref("+name+".operator->())"); + inc.write("(x10_float*)(size_t)x10aux::get_remote_ref_maybe_null("+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))"); Modified: trunk/x10.runtime/src-cpp/x10/lang/Object.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.runtime/src-cpp/x10/lang/Object.h 2010-02-03 20:28:53 UTC (rev 12793) @@ -93,6 +93,7 @@ // Needed for linking - do not override virtual x10_boolean _struct_equals(x10aux::ref<Object> other) { + assert(other!=x10aux::null); // checked in basic_functions.h x10aux::struct_equals if (other == x10aux::ref<Object>(this)) return true; if (this->location == x10aux::here) return false; // already tested above if (other->location == this->location && Modified: trunk/x10.runtime/src-cpp/x10aux/ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-02-03 20:25:09 UTC (rev 12792) +++ trunk/x10.runtime/src-cpp/x10aux/ref.h 2010-02-03 20:28:53 UTC (rev 12793) @@ -16,6 +16,9 @@ inline x10_addr_t get_remote_ref(void *obj) { return *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)); } + inline x10_addr_t get_remote_ref_maybe_null(void *obj) { + return obj==NULL ? NULL : get_remote_ref(obj); + } inline void set_remote_ref(void *obj, x10_addr_t ref) { *(x10_addr_t*)(((char*)obj)-sizeof(x10_addr_t)) = ref; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |