Changeset 14208


Ignore:
Timestamp:
Nov 28, 2019 11:00:39 AM (2 weeks ago)
Author:
Christian Andersson
Message:

Merged ticket:5872 into release branch.

Location:
branches/2.16.x
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2.16.x

  • branches/2.16.x/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalFunction.java

    r13246 r14208  
    1212public interface ExternalFunction<K, V> {
    1313
     14    public static final String EXTERNAL_LOG_PREFIX = "[EXTERNAL_EVALUATION] ";
     15   
    1416    public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException;
    1517
  • branches/2.16.x/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalFunctionImpl.java

    r13826 r14208  
    3939    @Override
    4040    public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {
    41         compiler.log().debug("Evaluating compiled external function: " + ext.getName());
     41        compiler.log().debug(ExternalFunction.EXTERNAL_LOG_PREFIX+"Evaluating compiled external function: " + ext.getName());
    4242        ProcessCommunicator<V, T> com = null;
    4343        try {
  • branches/2.16.x/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/ExternalProcessCacheImpl.java

    r13790 r14208  
    3636
    3737    private final ExternalFunctionCompiler<K, E> mc;
     38   
     39    private String addDebugInfoPrefix(String msg) {
     40        return ExternalFunction.EXTERNAL_LOG_PREFIX + msg;
     41    }
    3842
    3943    public ExternalProcessCacheImpl(ExternalFunctionCompiler<K, E> mc) {
     
    116120                sharedLibrary = "NoSharedLibrary";
    117121            } else {
    118                 mc.log().debug("Could not find a shared library containing '" + functionName + "'. Disabling use of the evaluator...");
     122                mc.log().debug(addDebugInfoPrefix("Could not find a shared library containing '" + functionName + "'. Disabling use of the evaluator..."));
    119123                return false;
    120124            }
     
    122126       
    123127        if (!supportedSignatures.contains(outputArguments+"+"+inputArguments)) {
    124             mc.log().debug("The function signature, outputs '" + outputArguments + "', inputs '" + inputArguments + "', is not supported. Disabling use of the evaluator...");
     128            mc.log().debug(addDebugInfoPrefix("The function signature, outputs '" + outputArguments + "', inputs '" + inputArguments + "', is not supported. Disabling use of the evaluator..."));
    125129            return false;
    126130        }
     
    156160                    extFunctionExecutable = new ExternalFunctionExecutableDynamic(arguments);
    157161                   
    158                     debugMsg = "Succesfully connected external function '" + ext.getName() + "' to the evaluator '"
    159                             + executable + "' with outputs: '" + ext.functionReturnArgSerialized() + "' and inputs: '" + ext.functionArgsSerialized() + "'";
     162                    debugMsg = "Successfully connected external function '" + ext.getName() + "' to the evaluator";
    160163                } else {
    161164                    executable = mc.compileExternal(ext);
     
    163166                    extFunctionExecutable = new ExternalFunctionExecutableGenerated(executable);
    164167                   
    165                     debugMsg = "Succesfully compiled external function '" + ext.getName() + "' to executable '"
    166                             + executable + "' code for evaluation";
     168                    debugMsg = "Successfully compiled external function '" + ext.getName() + "' to executable '"
     169                            + executable + "'";
    167170                }
    168171               
     
    173176                }
    174177                time = System.currentTimeMillis() - time;
    175                 mc.log().debug(debugMsg +", time: " + time + "ms");
     178                mc.log().debug(addDebugInfoPrefix(debugMsg +", time: " + time + "ms"));
    176179            } catch (FileNotFoundException e) {
    177                 ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, "c-code generation failed '" + e.getMessage() + "'", true);
    178                 mc.log().debug(ef.getMessage());
     180                ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, addDebugInfoPrefix("c-code generation failed '" + e.getMessage() + "'"), true);
     181                mc.log().info(ef.getMessage());
    179182            } catch (CcodeCompilationException e) {
    180                 ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, "c-code compilation failed '" + e.getMessage() + "'", true);
    181                 mc.log().debug(ef.getMessage());
    182                 e.printStackTrace(new PrintStream(mc.log().debugStream()));
     183                ef = FailedExternalFunction.<K,V,T,E>failedEval(mc, ext, addDebugInfoPrefix("c-code compilation failed '" + e.getMessage() + "'"), true);
     184                mc.log().info(ef.getMessage());
     185                e.printStackTrace(new PrintStream(mc.log().infoStream()));
    183186            }
    184187            cachedExternals.put(ext.getName(), ef);
  • branches/2.16.x/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/FailedExternalFunction.java

    r13719 r14208  
    3030    public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {
    3131        if (log) {
    32             logContainer.log().debug("Evaluating failed external function: " + ext.getName());
     32            logContainer.log().debug(ExternalFunction.EXTERNAL_LOG_PREFIX + "Evaluating failed external function: " + ext.getName());
    3333        }
    3434        throw new ConstantEvaluationException(null, getMessage());
  • branches/2.16.x/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/evaluation/LiveExternalFunction.java

    r13826 r14208  
    3838    @Override
    3939    public int evaluate(External<K> ext, Map<K, V> values, int timeout) throws IOException {
    40         compiler.log().debug("Evaluating live external function: " + ext.getName());
     40        compiler.log().debug(ExternalFunction.EXTERNAL_LOG_PREFIX+"Evaluating live external function: " + ext.getName());
    4141        try {
    4242            ready(ext, values, timeout);
     
    4444            map.evaluate(ext, values, timeout, com);
    4545            time = System.currentTimeMillis() - time;
    46             compiler.log().debug("Finished evaluating live external function, time: " + time + "ms");
     46            compiler.log().debug(ExternalFunction.EXTERNAL_LOG_PREFIX+"Finished evaluating live external function, time: " + time + "ms");
    4747        } catch (ProcessCommunicator.AbortConstantEvaluationException e) {
    4848            // TODO What does this mean?
     
    6969            map.setup(ext, values, timeout, com);
    7070            long time3 = System.currentTimeMillis();
    71             compiler.log().debug("Setup live external function: " + ext.getName()
     71            compiler.log().debug(ExternalFunction.EXTERNAL_LOG_PREFIX+"Setup live external function: " + ext.getName()
    7272                      + ", createProcessCommunicator() time: " + (time2 - time1)
    7373                      + "ms, setup time: " + (time3 - time2) + "ms");
  • branches/2.16.x/Python/src/tests_jmodelica/general/test_extfunctions.py

    r14056 r14208  
    4949        nbr_of_evaluator_calls = 0
    5050        with open("log.txt") as f:
    51             res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*")
     51            res = fnmatch.filter(f, "*Successfully connected external function '*' to the evaluator*")
    5252            nbr_of_evaluator_calls = len(res)
    5353       
     
    7070        nbr_of_evaluator_calls = 0
    7171        with open("log.txt") as f:
    72             res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*")
     72            res = fnmatch.filter(f, "*Successfully connected external function '*' to the evaluator*")
    7373            nbr_of_evaluator_calls = len(res)
    7474       
     
    102102        matches = 0
    103103        with open("log_unknown_shared.txt") as f:
    104             res = fnmatch.filter(f, "Could not find a shared library containing*")
     104            res = fnmatch.filter(f, "*Could not find a shared library containing*")
    105105            matches = len(res)
    106106       
     
    114114        nbr_of_evaluator_calls = 0
    115115        with open("log.txt") as f:
    116             res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*")
     116            res = fnmatch.filter(f, "*Successfully connected external function '*' to the evaluator*")
    117117            nbr_of_evaluator_calls = len(res)
    118118       
     
    131131        nbr_of_evaluator_calls = 0
    132132        with open("log.txt") as f:
    133             res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*")
     133            res = fnmatch.filter(f, "*Successfully connected external function '*' to the evaluator*")
    134134            nbr_of_evaluator_calls = len(res)
    135135       
     
    147147        nbr_of_evaluator_calls = 0
    148148        with open("log.txt") as f:
    149             res = fnmatch.filter(f, "Succesfully connected external function '*' to the evaluator*")
     149            res = fnmatch.filter(f, "*Successfully connected external function '*' to the evaluator*")
    150150            nbr_of_evaluator_calls = len(res)
    151151       
Note: See TracChangeset for help on using the changeset viewer.