Fracture

Fracture is a Java multi-core utilization library.
Download

Fracture Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Cameron Shelton
  • Publisher web site:
  • http://kccoder.com/fracture/

Fracture Tags


Fracture Description

Fracture is a Java multi-core utilization library. Fracture is a Java multi-core utilization library. It is a Java library which simplifies multi-core development. Currently, this library is very simple, providing a single public class (com.kccoder.fracture.Fracture) which contains the static methods needed to transform your single-core loops into multi-core loops with minimal effort. Future releases will provide solutions for more complex situations as well as reveal the objects present 'under-the-hood' to enable custom solutions.UsageTo use Fracture simply replace a CPU intensive loop with the appropriate Fracture method call. For example:for(DifferentialEquation deq : equations) { solve(deq); }becomesFracture.forEach(equations, new IProcessor() { public void processElement(DifferentialEquation deq) { solve(deq); } }); It should be noted that there is overhead associated with using Fracture (synchronization and coordination). So, if solve() executes very quickly or total loop execution is very quick, you will experience very little gain in performance (you might even experience a degradation). However, for sufficiently lengthy tasks, you should experience a sizable increase in performance. Further examples are included in the distribution (package com.kccoder.fracture.example). Performance MeasurementThe utility class com.kccoder.fracture.util.MethodTimer is provided to help you quantify performance gains (or losses) exhibited with Fracture's use. For example:public static void main(String[] args) { MethodTimer.compareMethods(MandelbrodtExample.class, "normalWay", "fractureWay"); } public static void normalWay() { for(int x = 0; x < 1280; x++) { mandelbrot(x); } }public static void fractureWay() { Fracture.forEach(0, 1280, 1, new IProcessor() { public void processElement(Integer x) { mandelbrot(x); } }); } produces (on my Core2Duo MacBook) Method took millis to completeMethod took millis to completefractureWay executed times faster than normalWay Core ModeBy default Fracture uses all available cores; however, you can configure Fracture to use fewer cores by setting the CoreMode via Fracture.setCoreMode(). The modes available are pretty self explanatory. Future releases will provide more sophisticated (and granular) configuration options. Thread SafetyIt should be noted that objects referenced by your IProcessor must be thread-safe. So, if you are putting/getting things into/out-of a Map, you need to either synchronize on that Map or use a Thread-Safe version (checkout the sycnrhonizedX methods in java.util.Collections). Loop Iteration IndependenceIn addition to thread saftey, you will also need to be sure that the successful processing of loop iteration X is not dependent on X-1. For example the below cannot be simply migrated to Fracture as each loop iteration is dependent on previous iterations: int fibonacci = 0; int t = 1; for(int n = 0; n < 10; n++) { fibonacci = fibonacci + t; t = fibonacci - t; }What's New in This Release:· This release focuses on reducing synchronization overhead for data sets that allow for random access, the addition of rudimentary JUnit test cases, and a few refactorings.


Fracture Related Software