Commit a60b9e6f authored by martin.hecker's avatar martin.hecker
Browse files

fix x10 examples, adapting it to x10 2.6

parent d6525ab1
bin
**/*.class
bin-java
*.class
*.o
*.hi
*.d
.dist-buildwrapper
x10-gen-src
.cache-main
......@@ -2,5 +2,8 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="x10dt.X10_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="x10-gen-src"/>
<classpathentry kind="src" output="bin-java" path="src-java"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -6,19 +6,33 @@
</projects>
<buildSpec>
<buildCommand>
<name>x10dt.ui.launch.cpp.X10CppBuilder</name>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.imp.smapifier.SmapieBuilder</name>
<name>x10dt.ui.builder.java.X10JavaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>x10dt.ui.launch.core.SmapieBuilder</name>
<arguments>
<dictionary>
<key>exten</key>
<value>x10</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>x10dt.ui.launch.cpp.x10nature</nature>
<nature>org.eclipse.imp.smapifier.smapinature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>x10dt.ui.builder.java.x10nature</nature>
<nature>x10dt.ui.launch.core.smapinature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.5
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="x10dt.ui.launch.java.launching.X10LaunchConfigurationType">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/x10Examples/x10-gen-src/MergesortDistributed.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="MergesortDistributed"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="100"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="x10Examples"/>
<stringAttribute key="x10dt.ui.launch.cpp.launchAttrs.hostFile" value=""/>
<stringAttribute key="x10dt.ui.launch.cpp.launchAttrs.hostList" value="localhost"/>
<intAttribute key="x10dt.ui.launch.cpp.launchAttrs.numPlaces" value="1"/>
<intAttribute key="x10dt.ui.launch.cpp.launchAttrs.useHostFile" value="1"/>
<booleanAttribute key="x10dt.ui.launch.cpp.mvm.is_local" value="true"/>
</launchConfiguration>
......@@ -6,10 +6,9 @@ public class Hello {
/**
* The main method for the Hello class
*/
public static def main(Array[String]) {
Console.OUT.println("Hello, World! from "+here);
at(here.next()) {
Console.OUT.println("Hello, World! from "+here);
public static def main(Rail[String]) {
finish for (p in Place.places()) {
at (p) async Console.OUT.println("Hello World from place "+p.id);
}
}
......
../../../programmierparadigmen/uebungsaufgaben/Parallel/mergesort/loesung/Mergesort.x10
\ No newline at end of file
../../../programmierparadigmen/programmierparadigmen-tutoren/uebungsaufgaben/Parallel/mergesort/MergesortDistributed.x10
\ No newline at end of file
import x10.io.Console;
import x10.util.Random;
import x10.util.ArrayList;
import x10.regionarray.Dist;
import x10.regionarray.Array;
import x10.regionarray.DistArray;
import x10.regionarray.Region;
public class MergesortDistributed {
private static val rand = new Random();
private static val MIN_ELEMENTS_PARALLEL = 65536;
public static def sort(values : Array[Int]{self.rank==1}) : Array[Int]{self.rank==1} {
val dist <: Dist = Dist.makeBlock(values.region);
val distvalues = DistArray.make[Int](dist, (i:Point) => values(i));
finish for (p in dist.places()) at(p) {
val local = distvalues.getLocalPortion();
val helper = new Array[Int](local.region);
Console.OUT.println("Place: " + here + "Region: " + local.region + "min/max:" + local.region.min(0) +"/" + local.region.max(0));
mergesort(local.region.minPoint(), local.region.maxPoint(), local, helper);
}
val numbers = new Array[Int](values.region);
finish for (i in values.region) {
async {
numbers(i) = at (dist(i)) distvalues(i);
}
}
val regions = new ArrayList[Region](2);
for(r in dist.regions()){
regions.add(r);
}
val helper = new Array[Int](numbers.region);
/*
while(regions.size() > 1) {
val left = regions.removeFirst();
val right = regions.removeFirst();
assert left.max(0) + 1 == right.min(0);
merge(left.minPoint(), left.max(0), right.max(0), numbers, helper);
}
*/
Console.OUT.println(numbers);
return numbers;
}
private static def mergesort(low : Point(1), high : Point(1), numbers : Array[Int](1), helper : Array[Int](1)) {
if (low < high) {
val middle = (low + high) / 2;
if (high >= low + MIN_ELEMENTS_PARALLEL) {
finish {
async mergesort(low, middle, numbers, helper);
async mergesort(middle + 1, high, numbers, helper);
}
} else {
mergesort(low, middle, numbers, helper);
mergesort(middle + 1, high, numbers, helper);
}
merge(low, middle, high, numbers, helper);
}
}
private static def merge(low : Point(1), middle : Point(1), high : Point(1), numbers : Array[Int](1), helper : Array[Int](1)) {
Console.OUT.println("merge(" + low + ", " + middle + ", " + high + ", " + numbers + ", " + helper + ", ");
// Copy the part to be merged into the helper (from low to high)
val size = (high - low + 1).coords()(0);
Array.copy(numbers, low, helper, low, size);
var left : Point(1) = low;
var right : Point(1) = middle + 1;
var position : Point(1) = low;
while(left <= middle && right <= high) {
if (helper(left) <= helper(right)) {
numbers(position) = helper(left);
position += 1; left +=1;
} else {
numbers(position) = helper(right);
position +=1; right+=1;
}
}
val elementsRemaining : Long = Math.max((middle - left + 1).coords()(0),0);
Array.copy(helper,left,numbers,position,elementsRemaining);
// Nothing needs to be done for the right half, because is still
// is where it was copied from, which happens to be the right
// location.
}
public static def main(args: Rail[String]) {
if (args.size < 1) {
Console.OUT.println("Expect array length as argument");
return;
}
val sort_count = Long.parse(args(0));
val maxVal : Int = 100 as Int;
val to_sort:Array[Int] = new Array[Int](sort_count, (_:Long) => { return rand.nextInt(maxVal); });
for (i in to_sort) {
Console.OUT.print(to_sort(i) + " ");
}
Console.OUT.println();
val start = System.nanoTime();
val sorted = sort(to_sort);
val duration = System.nanoTime() - start;
Console.OUT.println("Sorting took " + duration / 1000000.0 + "ms");
Console.OUT.println("Checking for sortedness...");
for (i in sorted) {
Console.OUT.print(sorted(i) + " ");
}
Console.OUT.println();
}
}
import x10.io.Console;
import x10.util.Random;
import x10.util.ArrayList;
public class MergesortDistributed2 {
private static val rand = new Random();
private static val MIN_ELEMENTS_PARALLEL = 65536;
public static def sort(values : Array[Int](1)) : Array[Int](1) {
val dist <: Dist = Dist.makeBlock(values.region);
val distvalues = DistArray.make[Int](dist, (i:Point(1)) => values(i));
finish for (p in dist.places()) at(p) {
val local = distvalues.getLocalPortion();
val helper = new Array[Int](local.region);
Console.OUT.println("Place: " + here + "Region: " + local.region + "min/max:" + local.region.min(0) +"/" + local.region.max(0));
mergesort(local.region.minPoint(), local.region.maxPoint(), local, helper);
}
val numbers = new Array[Int](values.region);
finish for (i in values.region) {
async {
numbers(i) = at (dist(i)) distvalues(i);
}
}
val regions = new ArrayList[Region](2);
for(r in dist.regions()){
regions.add(r);
}
val helper = new Array[Int](numbers.region);
/*
while(regions.size() > 1) {
val left = regions.removeFirst();
val right = regions.removeFirst();
assert left.max(0) + 1 == right.min(0);
merge(left.minPoint(), left.max(0), right.max(0), numbers, helper);
}
*/
Console.OUT.println(numbers);
return numbers;
}
private static def mergesort(low : Point(1), high : Point(1), numbers : Array[Int](1), helper : Array[Int](1)) {
if (low < high) {
val middle = (low + high) / 2;
if (high >= low + MIN_ELEMENTS_PARALLEL) {
finish {
async mergesort(low, middle, numbers, helper);
async mergesort(middle + 1, high, numbers, helper);
}
} else {
mergesort(low, middle, numbers, helper);
mergesort(middle + 1, high, numbers, helper);
}
merge(low, middle, high, numbers, helper);
}
}
private static def merge(low : Point(1), middle : Point(1), high : Point(1), numbers : Array[Int](1), helper : Array[Int](1)) {
Console.OUT.println("merge(" + low + ", " + middle + ", " + high + ", " + numbers + ", " + helper + ", ");
// Copy the part to be merged into the helper (from low to high)
val size = (high - low + 1).coords()(0);
Array.copy(numbers, low, helper, low, size);
var left : Point(1) = low;
var right : Point(1) = middle + 1;
var position : Point(1) = low;
while(left <= middle && right <= high) {
if (helper(left) <= helper(right)) {
numbers(position) = helper(left);
position += 1; left +=1;
} else {
numbers(position) = helper(right);
position +=1; right+=1;
}
}
val elementsRemaining : Int = Math.max((middle - left + 1).coords()(0),0);
Array.copy(helper,left,numbers,position,elementsRemaining);
// Nothing needs to be done for the right half, because is still
// is where it was copied from, which happens to be the right
// location.
}
public static def main(args:Array[String](1)) {
if (args.size < 1) {
Console.OUT.println("Expect array length as argument");
return;
}
val sort_count = Int.parse(args(0));
val to_sort:Array[Int] = new Array[Int](sort_count, (_:Int) => { return rand.nextInt(100); });
for (i in to_sort) {
Console.OUT.print(to_sort(i) + " ");
}
Console.OUT.println();
val start = System.nanoTime();
val sorted = sort(to_sort);
val duration = System.nanoTime() - start;
Console.OUT.println("Sorting took " + duration / 1000000.0 + "ms");
Console.OUT.println("Checking for sortedness...");
for (i in sorted) {
Console.OUT.print(sorted(i) + " ");
}
Console.OUT.println();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<platform>
<id>3231e5ae-6d49-4646-ab78-63f0af86a42e</id>
<name>x10Examples</name>
<connection is-local="true" use-port-forwarding="false"/>
<communication-interface>
<service-type>x10dt.ui.launch.cpp.rms.provider.sockets</service-type>
<service-mode>org.eclipse.ptp.core.LaunchService</service-mode>
<num-places>2</num-places>
<sockets-host-list>localhost</sockets-host-list>
</communication-interface>
<cpp-compilation>
<target-os>LINUX</target-os>
<bits-arch>E32Arch</bits-arch>
<arch>x86</arch>
<compiler>g++</compiler>
<compiler-opts>-g -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/include -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/include-dbg -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/include -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956 -I. -Wno-long-long -Wno-unused-parameter -msse2 -mfpmath=sse -DX10_USE_BDWGC -pthread</compiler-opts>
<archiver>ar</archiver>
<archiving-opts>cq</archiving-opts>
<linker>g++</linker>
<linking-opts>-g -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/include -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/include-dbg -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/include -I/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956 -I. -Wno-long-long -Wno-unused-parameter -msse2 -mfpmath=sse -DX10_USE_BDWGC -pthread</linking-opts>
<linking-libs>-L/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/lib-dbg -L/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/lib -lx10 -lgc -lm -lpthread -lrt -ldl -L/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/lib -lx10rt_sockets -Wl,--rpath -Wl,/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/lib-dbg -Wl,--rpath -Wl,/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/stdlib/lib -Wl,--rpath -Wl,/home/paradigmen/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/x10.dist.linux.x86.fragment_2.2.1.201202070956/lib -Wl,-export-dynamic</linking-libs>
</cpp-compilation>
<compilation-validation-status>UNKNOWN</compilation-validation-status>
<debugging>
<debugging-port>8888</debugging-port>
</debugging>
</platform>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment