Esempio n. 1
0
  static {
    try {
      final Level level = Level.parse(System.getProperty(getLoggerName(), "WARNING"));

      final Handler[] handlers = Logger.getLogger("").getHandlers();
      for (final Handler handler : handlers) {
        handler.setLevel(level);
      }

      logger.setLevel(level);
    } catch (final Exception e) {
      System.out.println("Exception " + e + " in Aparapi logging setup");
      e.printStackTrace();
    }
  };
Esempio n. 2
0
  static {
    if (enableInstructionDecodeViewer
        && ((instructionListenerClassName == null) || instructionListenerClassName.equals(""))) {
      instructionListenerClassName = InstructionViewer.class.getName();
    }

    if ((instructionListenerClassName != null) && !instructionListenerClassName.equals("")) {
      try {
        final Class<?> instructionListenerClass = Class.forName(instructionListenerClassName);
        instructionListener = (InstructionListener) instructionListenerClass.newInstance();
      } catch (final ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (dumpFlags) {
      System.out.println(propPkgName + ".executionMode{GPU|ACC|CPU|JTP|SEQ}=" + executionMode);
      System.out.println(
          propPkgName + ".logLevel{OFF|FINEST|FINER|FINE|WARNING|SEVERE|ALL}=" + logger.getLevel());
      System.out.println(propPkgName + ".enableProfiling{true|false}=" + enableProfiling);
      System.out.println(propPkgName + ".enableProfilingCSV{true|false}=" + enableProfilingCSV);
      System.out.println(propPkgName + ".enableVerboseJNI{true|false}=" + enableVerboseJNI);
      System.out.println(
          propPkgName
              + ".enableVerboseJNIOpenCLResourceTracking{true|false}="
              + enableVerboseJNIOpenCLResourceTracking);
      System.out.println(
          propPkgName + ".enableShowGeneratedOpenCL{true|false}=" + enableShowGeneratedOpenCL);
      System.out.println(
          propPkgName
              + ".enableExecutionModeReporting{true|false}="
              + enableExecutionModeReporting);
      System.out.println(
          propPkgName
              + ".enableInstructionDecodeViewer{true|false}="
              + enableInstructionDecodeViewer);
      System.out.println(
          propPkgName
              + ".instructionListenerClassName{<class name which extends com.amd.aparapi.Config.InstructionListener>}="
              + instructionListenerClassName);
    }
  }
Esempio n. 3
0
/**
 * A central location for holding all runtime configurable properties as well as logging
 * configuration.
 *
 * <p>Ideally we will find all properties used by <code>Aparapi</code> here. Please consider
 * updating this class if you wish to add new properties which control <code>Aparapi</code>s
 * behavior.
 *
 * @author gfrost
 */
public class Config extends ConfigJNI {

  // Logging setup
  private static final String logPropName = propPkgName + ".logLevel";

  private static final Logger logger = Logger.getLogger(Config.getLoggerName());

  /**
   * Allows the user to request to use a jvmti agent to access JNI code rather than loading
   * explicitly.
   *
   * <p>Usage -agentpath=/full/path/to/agent.dll -Dcom.amd.aparapi.useAgent=true
   */
  public static final boolean useAgent = Boolean.getBoolean(propPkgName + ".useAgent");

  /** Disable Unsafe */
  public static final boolean disableUnsafe = Boolean.getBoolean(propPkgName + ".disableUnsafe");

  /**
   * Allows the user to request a specific Kernel.EXECUTION_MODE enum value for all Kernels.
   *
   * <p>Usage -Dcom.amd.aparapi.executionMode={SEQ|JTP|CPU|GPU|ACC}
   *
   * @see com.amd.aparapi.Kernel.EXECUTION_MODE
   */
  public static final String executionMode = System.getProperty(propPkgName + ".executionMode");

  /**
   * Allows the user to request that the execution mode of each kernel invocation be reported to
   * stdout.
   *
   * <p>Usage -Dcom.amd.aparapi.enableExecutionModeReporting={true|false}
   */
  public static final boolean enableExecutionModeReporting =
      Boolean.getBoolean(propPkgName + ".enableExecutionModeReporting");

  /**
   * Allows the user to request that generated OpenCL code is dumped to standard out.
   *
   * <p>Usage -Dcom.amd.aparapi.enableShowGeneratedOpenCL={true|false}
   */
  public static final boolean enableShowGeneratedOpenCL =
      Boolean.getBoolean(propPkgName + ".enableShowGeneratedOpenCL");

  /**
   * Upon exiting the JVM, dumps kernel profiling info to standard out.
   *
   * <p>Usage -Dcom.amd.aparapi.dumpProfilesOnExit={true|false}
   */
  public static final boolean dumpProfilesOnExit =
      Boolean.getBoolean(propPkgName + ".dumpProfilesOnExit");

  /**
   * Dumps profiling info (for a single execution) after every Kernel execution.
   *
   * <p>Usage -Dcom.amd.aparapi.dumpProfileOnExecution={true|false}
   */
  public static final boolean dumpProfileOnExecution =
      Boolean.getBoolean(propPkgName + ".dumpProfileOnExecution");

  // Pragma/OpenCL codegen related flags
  public static final boolean enableAtomic32 = Boolean.getBoolean(propPkgName + ".enableAtomic32");

  public static final boolean enableAtomic64 = Boolean.getBoolean(propPkgName + ".enableAtomic64");

  public static final boolean enableByteWrites =
      Boolean.getBoolean(propPkgName + ".enableByteWrites");

  public static final boolean enableDoubles = Boolean.getBoolean(propPkgName + ".enableDoubles");

  // Debugging related flags
  public static final boolean verboseComparitor =
      Boolean.getBoolean(propPkgName + ".verboseComparitor");

  public static final boolean dumpFlags = Boolean.getBoolean(propPkgName + ".dumpFlags");

  // Individual bytecode support related flags
  public static final boolean enablePUTFIELD = Boolean.getBoolean(propPkgName + ".enable.PUTFIELD");

  public static final boolean enableARETURN = !Boolean.getBoolean(propPkgName + ".disable.ARETURN");

  public static final boolean enablePUTSTATIC =
      Boolean.getBoolean(propPkgName + ".enable.PUTSTATIC");

  // Allow static array accesses
  public static final boolean enableGETSTATIC =
      true; // Boolean.getBoolean(propPkgName + ".enable.GETSTATIC");

  public static final boolean enableINVOKEINTERFACE =
      Boolean.getBoolean(propPkgName + ".enable.INVOKEINTERFACE");

  public static final boolean enableMONITOR = Boolean.getBoolean(propPkgName + ".enable.MONITOR");

  public static final boolean enableNEW = Boolean.getBoolean(propPkgName + ".enable.NEW");

  public static final boolean enableATHROW = Boolean.getBoolean(propPkgName + ".enable.ATHROW");

  public static final boolean enableMETHODARRAYPASSING =
      !Boolean.getBoolean(propPkgName + ".disable.METHODARRAYPASSING");

  public static final boolean enableARRAYLENGTH =
      Boolean.getBoolean(propPkgName + ".enable.ARRAYLENGTH");

  public static final boolean enableSWITCH = Boolean.getBoolean(propPkgName + ".enable.SWITCH");

  public static boolean enableShowFakeLocalVariableTable =
      Boolean.getBoolean(propPkgName + ".enableShowFakeLocalVariableTable");

  public static final boolean enableInstructionDecodeViewer =
      Boolean.getBoolean(propPkgName + ".enableInstructionDecodeViewer");

  public static String instructionListenerClassName =
      System.getProperty(propPkgName + ".instructionListenerClass");

  public static InstructionListener instructionListener = null;

  public interface InstructionListener {
    void showAndTell(String message, Instruction _start, Instruction _instruction);
  }

  static {
    try {
      final Level level = Level.parse(System.getProperty(getLoggerName(), "WARNING"));

      final Handler[] handlers = Logger.getLogger("").getHandlers();
      for (final Handler handler : handlers) {
        handler.setLevel(level);
      }

      logger.setLevel(level);
    } catch (final Exception e) {
      System.out.println("Exception " + e + " in Aparapi logging setup");
      e.printStackTrace();
    }
  };

  static {
    if (enableInstructionDecodeViewer
        && ((instructionListenerClassName == null) || instructionListenerClassName.equals(""))) {
      instructionListenerClassName = InstructionViewer.class.getName();
    }

    if ((instructionListenerClassName != null) && !instructionListenerClassName.equals("")) {
      try {
        final Class<?> instructionListenerClass = Class.forName(instructionListenerClassName);
        instructionListener = (InstructionListener) instructionListenerClass.newInstance();
      } catch (final ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (dumpFlags) {
      System.out.println(propPkgName + ".executionMode{GPU|ACC|CPU|JTP|SEQ}=" + executionMode);
      System.out.println(
          propPkgName + ".logLevel{OFF|FINEST|FINER|FINE|WARNING|SEVERE|ALL}=" + logger.getLevel());
      System.out.println(propPkgName + ".enableProfiling{true|false}=" + enableProfiling);
      System.out.println(propPkgName + ".enableProfilingCSV{true|false}=" + enableProfilingCSV);
      System.out.println(propPkgName + ".enableVerboseJNI{true|false}=" + enableVerboseJNI);
      System.out.println(
          propPkgName
              + ".enableVerboseJNIOpenCLResourceTracking{true|false}="
              + enableVerboseJNIOpenCLResourceTracking);
      System.out.println(
          propPkgName + ".enableShowGeneratedOpenCL{true|false}=" + enableShowGeneratedOpenCL);
      System.out.println(
          propPkgName
              + ".enableExecutionModeReporting{true|false}="
              + enableExecutionModeReporting);
      System.out.println(
          propPkgName
              + ".enableInstructionDecodeViewer{true|false}="
              + enableInstructionDecodeViewer);
      System.out.println(
          propPkgName
              + ".instructionListenerClassName{<class name which extends com.amd.aparapi.Config.InstructionListener>}="
              + instructionListenerClassName);
    }
  }

  public static String getLoggerName() {
    return logPropName;
  }
}