Ejemplo n.º 1
0
  static {
    {
      OpenCLProbeLibrary probe = new OpenCLProbeLibrary();
      try {
        if (!probe.isValid()) {
          String alt;
          if (Platform.is64Bits() && BridJ.getNativeLibraryFile(alt = "atiocl64") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl32") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl") != null) {
            log(
                Level.INFO,
                "Hacking around ATI's weird driver bugs (using atiocl library instead of OpenCL)",
                null);
            BridJ.setNativeLibraryActualName("OpenCL", alt);
          }
        }
      } finally {
        probe = null;
        BridJ.unregister(OpenCLProbeLibrary.class);
      }
    }

    if (debug) {
      String debugArgs = System.getenv(JAVACL_DEBUG_COMPILER_FLAGS_PROP);
      if (debugArgs != null) DEBUG_COMPILER_FLAGS = Arrays.asList(debugArgs.split(" "));
      else if (Platform.isMacOSX()) DEBUG_COMPILER_FLAGS = Arrays.asList("-g");
      else DEBUG_COMPILER_FLAGS = Arrays.asList("-O0", "-g");

      int pid = ProcessUtils.getCurrentProcessId();
      log(
          Level.INFO,
          "Debug mode enabled with compiler flags \""
              + StringUtils.implode(DEBUG_COMPILER_FLAGS, " ")
              + "\" (can be overridden with env. var. JAVACL_DEBUG_COMPILER_FLAGS_PROP)");
      log(
          Level.INFO,
          "You can debug your kernels with GDB using one of the following commands :\n"
              + "\tsudo gdb --tui --pid="
              + pid
              + "\n"
              + "\tsudo ddd --debugger \"gdb --pid="
              + pid
              + "\"\n"
              + "More info here :\n"
              + "\thttp://code.google.com/p/javacl/wiki/DebuggingKernels");
    }
    CL = new OpenCLLibrary();
  }
Ejemplo n.º 2
0
  public AVResampleLibrary() throws IOException {
    lib = BridJ.getNativeLibrary(Lib.class);

    int libVersion = avresample_version();

    majorVersion = (libVersion >> 16) & 0xff;
    minorVersion = (libVersion >> 8) & 0xff;
    microVersion = libVersion & 0xff;
    String version = String.format("%d.%d.%d", majorVersion, minorVersion, microVersion);

    File libFile = BridJ.getNativeLibraryFile(LIB_NAME);

    Logger.getLogger(getClass().getName())
        .log(
            Level.INFO,
            "Loading {0} library, version {1}...",
            new Object[] {libFile.getAbsolutePath(), version});

    if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION)
      throw new UnsatisfiedLinkError(
          "Unsupported version of the "
              + LIB_NAME
              + " native library. ("
              + MIN_MAJOR_VERSION
              + ".x.x <= required <= "
              + MAX_MAJOR_VERSION
              + ".x.x, found "
              + version
              + ")");
  }