Skip to content

Commit

Permalink
Correct interp-tracer, code cleanup, asm.js/wasm libraries recompiled…
Browse files Browse the repository at this point in the history
… with emcc 1.37.35.
  • Loading branch information
sletz committed Mar 6, 2018
1 parent 6cd7bb9 commit c834792
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion architecture/faust/dsp/faust-dynamic-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct dsp_aux {
void createJSON(const string& name_app)
{
// JSON creation
JSONUI json(name_app, fDSP->getNumInputs(), fDSP->getNumOutputs());
JSONUI json(name_app, "", fDSP->getNumInputs(), fDSP->getNumOutputs());
fDSP->buildUserInterface(&json);
fDSP->metadata(&json);
fJSON = json.JSON();
Expand Down
2 changes: 1 addition & 1 deletion architecture/webaudio/libfaust.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion architecture/webaudio/libfaustworker.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions compiler/generator/llvm/llvm_dsp_aux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
#endif

using namespace llvm;
using namespace std;

// Factories instances management
int llvm_dsp_factory_aux::gInstance = 0;
Expand Down
130 changes: 64 additions & 66 deletions compiler/generator/llvm/llvm_dsp_aux.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
#define LLVM_MAX_OPT_LEVEL 4
#endif

using namespace std;

namespace llvm
{
class LLVMContext;
Expand Down Expand Up @@ -108,29 +106,29 @@ class EXPORT llvm_dsp : public dsp {
#if (defined(LLVM_34) || defined(LLVM_35)) && !defined(_MSC_VER)
class FaustObjectCache : public llvm::ObjectCache {

private:

string fMachineCode;

public:

FaustObjectCache(const string& machine_code = "") : fMachineCode(machine_code)
{}

virtual ~FaustObjectCache()
{}

void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj)
{
fMachineCode = Obj->getBuffer().str();
}

MemoryBuffer* getObject(const Module* M)
{
return (fMachineCode == "") ? NULL : MemoryBuffer::getMemBuffer(StringRef(fMachineCode));
}

string getMachineCode() { return fMachineCode; }
private:
std::string fMachineCode;
public:
FaustObjectCache(const std::string& machine_code = "") : fMachineCode(machine_code)
{}
virtual ~FaustObjectCache()
{}
void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj)
{
fMachineCode = Obj->getBuffer().str();
}
MemoryBuffer* getObject(const Module* M)
{
return (fMachineCode == "") ? NULL : MemoryBuffer::getMemBuffer(StringRef(fMachineCode));
}
std::string getMachineCode() { return fMachineCode; }

};
#endif
Expand Down Expand Up @@ -164,29 +162,29 @@ void ObjectCache::anchor() {}

class FaustObjectCache : public llvm::ObjectCache {

private:

string fMachineCode;

public:

FaustObjectCache(const string& machine_code = "") : fMachineCode(machine_code)
{}

virtual ~FaustObjectCache()
{}

virtual void notifyObjectCompiled(const llvm::Module *M, llvm::MemoryBufferRef Obj)
{
fMachineCode = Obj.getBuffer().str();
}

virtual unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* M)
{
return (fMachineCode == "") ? NULL : llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(fMachineCode));
}

string getMachineCode() { return fMachineCode; }
private:
std::string fMachineCode;
public:
FaustObjectCache(const std::string& machine_code = "") : fMachineCode(machine_code)
{}
virtual ~FaustObjectCache()
{}
virtual void notifyObjectCompiled(const llvm::Module *M, llvm::MemoryBufferRef Obj)
{
fMachineCode = Obj.getBuffer().str();
}
virtual std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* M)
{
return (fMachineCode == "") ? NULL : llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(fMachineCode));
}
std::string getMachineCode() { return fMachineCode; }

};
#endif
Expand All @@ -209,9 +207,9 @@ class llvm_dsp_factory_aux : public dsp_factory_imp {
llvm::LLVMContext* fContext;

int fOptLevel;
string fTarget;
string fClassName;
string fTypeName;
std::string fTarget;
std::string fClassName;
std::string fTypeName;

newDspFun fNew;
deleteDspFun fDelete;
Expand All @@ -229,9 +227,9 @@ class llvm_dsp_factory_aux : public dsp_factory_imp {
metadataFun fMetadata;
getSampleSizeFun fGetSampleSize;

void* loadOptimize(const string& function);
void* loadOptimize(const std::string& function);

void init(const string& dsp_name, const string& type_name);
void init(const std::string& dsp_name, const std::string& type_name);

bool crossCompile(const std::string& target);

Expand All @@ -242,19 +240,19 @@ class llvm_dsp_factory_aux : public dsp_factory_imp {
void startLLVMLibrary();
void stopLLVMLibrary();

string writeDSPFactoryToMachineAux(const string& target);
std::string writeDSPFactoryToMachineAux(const std::string& target);

public:

llvm_dsp_factory_aux(const string& sha_key,
llvm_dsp_factory_aux(const std::string& sha_key,
const std::vector<std::string>& pathname_list,
llvm::Module* module,
llvm::LLVMContext* context,
const string& target,
const std::string& target,
int opt_level = 0);

#if (defined(LLVM_34) || defined(LLVM_35) || defined(LLVM_36) || defined(LLVM_37) || defined(LLVM_38) || defined(LLVM_39) || defined(LLVM_40) || defined(LLVM_50) || defined(LLVM_60)) && !defined(_MSC_VER)
llvm_dsp_factory_aux(const string& sha_key, const string& machine_code, const string& target);
llvm_dsp_factory_aux(const std::string& sha_key, const std::string& machine_code, const std::string& target);
#endif

llvm_dsp_factory_aux(const std::string& name,
Expand All @@ -265,21 +263,21 @@ class llvm_dsp_factory_aux : public dsp_factory_imp {
{}

virtual ~llvm_dsp_factory_aux();

// Bitcode
virtual string writeDSPFactoryToBitcode() { return ""; }
virtual std::string writeDSPFactoryToBitcode() { return ""; }

virtual void writeDSPFactoryToBitcodeFile(const string& bit_code_path) {}
virtual void writeDSPFactoryToBitcodeFile(const std::string& bit_code_path) {}

// IR
virtual string writeDSPFactoryToIR() { return ""; }
virtual std::string writeDSPFactoryToIR() { return ""; }

virtual void writeDSPFactoryToIRFile(const string& ir_code_path) {}
virtual void writeDSPFactoryToIRFile(const std::string& ir_code_path) {}

// Machine
virtual string writeDSPFactoryToMachine(const string& target);
virtual std::string writeDSPFactoryToMachine(const std::string& target);

virtual void writeDSPFactoryToMachineFile(const string& machine_code_path, const string& target);
virtual void writeDSPFactoryToMachineFile(const std::string& machine_code_path, const std::string& target);

bool initJIT(std::string& error_msg);

Expand All @@ -289,7 +287,7 @@ class llvm_dsp_factory_aux : public dsp_factory_imp {
int getOptlevel();
void setOptlevel(int opt_level) { fOptLevel = ((opt_level == -1) || (opt_level > LLVM_MAX_OPT_LEVEL)) ? LLVM_MAX_OPT_LEVEL : opt_level; }

void setClassName(const string& class_name) { fClassName = class_name; }
void setClassName(const std::string& class_name) { fClassName = class_name; }

llvm_dsp* createDSPInstance(dsp_factory* factory);

Expand Down Expand Up @@ -354,7 +352,7 @@ class EXPORT llvm_dsp_factory : public dsp_factory, public faust_smartable {

std::string writeDSPFactoryToBitcode() { return fFactory->writeDSPFactoryToBitcode(); }

void writeDSPFactoryToBitcodeFile(const string& bit_code_path) { fFactory->writeDSPFactoryToBitcodeFile(bit_code_path); }
void writeDSPFactoryToBitcodeFile(const std::string& bit_code_path) { fFactory->writeDSPFactoryToBitcodeFile(bit_code_path); }

std::string writeDSPFactoryToIR() { return fFactory->writeDSPFactoryToIR(); }

Expand Down
14 changes: 7 additions & 7 deletions compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
#endif

using namespace llvm;
using namespace std;

static void splitTarget(const string& target, string& triple, string& cpu)
{
Expand All @@ -184,15 +185,14 @@ static bool isParam(int argc, const char* argv[], const string& param)
return false;
}

static void DUMP(Module* module)
static void dumpModule(Module* module)
{
string res;
raw_string_ostream out_str(res);
out_str << *module;
std::cout << out_str.str();
}


#if defined(LLVM_35) || defined(LLVM_36)
// LLVM 3.5 has parseBitcodeFile(). Must emulate ParseBitcodeFile. -ag
static Module* ParseBitcodeFile(MEMORY_BUFFER Buffer,
Expand Down Expand Up @@ -471,7 +471,7 @@ bool llvm_dsp_factory_aux::initJIT(string& error_msg)

TargetOptions targetOptions;

// -fastmath is activated at IR level, and needs to be setup at JIT level also
// -fastmath is activated at IR level, and has to be setup at JIT level also

#if defined(LLVM_36) || defined(LLVM_37) || defined(LLVM_38) || defined(LLVM_39) || defined(LLVM_40) || defined(LLVM_50) || defined(LLVM_60)
#if !defined(LLVM_50) && !defined(LLVM_60)
Expand Down Expand Up @@ -551,7 +551,7 @@ bool llvm_dsp_factory_aux::initJIT(string& error_msg)
#else
TargetRegistry::printRegisteredTargetsForVersion();
#endif
DUMP(fModule);
dumpModule(fModule);
}

fpm.doInitialization();
Expand All @@ -574,7 +574,7 @@ bool llvm_dsp_factory_aux::initJIT(string& error_msg)
pm.run(*fModule);

if ((debug_var != "") && (debug_var.find("FAUST_LLVM2") != string::npos)) {
DUMP(fModule);
dumpModule(fModule);
}
}

Expand Down Expand Up @@ -699,14 +699,14 @@ bool llvm_dynamic_dsp_factory_aux::initJIT(string& error_msg)
string debug_var = (getenv("FAUST_DEBUG")) ? string(getenv("FAUST_DEBUG")) : "";

if ((debug_var != "") && (debug_var.find("FAUST_LLVM1") != string::npos)) {
DUMP(fModule);
dumpModule(fModule);
}

// Now that we have all of the passes ready, run them.
pm.run(*fModule);

if ((debug_var != "") && (debug_var.find("FAUST_LLVM2") != string::npos)) {
DUMP(fModule);
dumpModule(fModule);
}
}

Expand Down
18 changes: 9 additions & 9 deletions compiler/generator/llvm/llvm_dynamic_dsp_aux.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ class llvm_dynamic_dsp_factory_aux : public llvm_dsp_factory_aux {

public:

llvm_dynamic_dsp_factory_aux(const string& sha_key,
llvm_dynamic_dsp_factory_aux(const std::string& sha_key,
const std::vector<std::string>& pathname_list,
llvm::Module* module,
llvm::LLVMContext* context,
const string& target,
const std::string& target,
int opt_level = 0);

#if (defined(LLVM_34) || defined(LLVM_35) || defined(LLVM_36) || defined(LLVM_37) || defined(LLVM_38) || defined(LLVM_39) || defined(LLVM_40) || defined(LLVM_50) || defined(LLVM_60)) && !defined(_MSC_VER)
llvm_dynamic_dsp_factory_aux(const string& sha_key, const string& machine_code, const string& target)
llvm_dynamic_dsp_factory_aux(const std::string& sha_key,
const std::string& machine_code,
const std::string& target)
:llvm_dsp_factory_aux(sha_key, machine_code, target)
{}
#endif

// Bitcode
string writeDSPFactoryToBitcode();
std::string writeDSPFactoryToBitcode();

void writeDSPFactoryToBitcodeFile(const string& bit_code_path);
void writeDSPFactoryToBitcodeFile(const std::string& bit_code_path);

// IR
virtual string writeDSPFactoryToIR();
virtual std::string writeDSPFactoryToIR();

virtual void writeDSPFactoryToIRFile(const string& ir_code_path);
virtual void writeDSPFactoryToIRFile(const std::string& ir_code_path);

};

Expand Down
2 changes: 1 addition & 1 deletion embedded/faustgen/src/faustgen~.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "faust/dsp/poly-dsp.h"

#ifndef WIN32
#include "faust/sound-file.h"
//#include "faust/sound-file.h"
#endif

int faustgen_factory::gFaustCounter = 0;
Expand Down
1 change: 1 addition & 0 deletions embedded/faustremote/RemoteServer/remote_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void dsp_server_connection_info::getJson(dsp_factory* factory)

string code = factory->getDSPCode();
JSONUI json(fNameApp,
"",
tmp_dsp->getNumInputs(),
tmp_dsp->getNumOutputs(),
factory->getSHAKey(),
Expand Down
6 changes: 3 additions & 3 deletions tools/benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Here are the available options:

Additional Faust compiler options can be given. Note that the Interpreter backend can be launched in *trace* mode, so that various statistics on the running code are collected and displayed while running and/or when closing the application. For developers, the *FAUST_INTERP_TRACE* environment variable can be set to values from 1 to 5 (see the **interp-trace** tool).

## interp-trace
## interp-tracer

The **interp-trace** tool runs and instruments the compiled program using the Interpreter backend. Various statistics on the code are collected and displayed while running and/or when closing the application, typically FP_SUBNORMAL, FP_INFINITE and FP_NAN values, or INTEGER_OVERFLOW and DIV_BY_ZERO operations. Mode 4 and 5 allow to display the stack trace of the running code when FP_INFINITE, FP_NAN or INTEGER_OVERFLOW values are produced. The -control mode allows to check control parameters, by explicitly setting their *min* and *max* values (for now).
The **interp-tracer** tool runs and instruments the compiled program using the Interpreter backend. Various statistics on the code are collected and displayed while running and/or when closing the application, typically FP_SUBNORMAL, FP_INFINITE and FP_NAN values, or INTEGER_OVERFLOW and DIV_BY_ZERO operations. Mode 4 and 5 allow to display the stack trace of the running code when FP_INFINITE, FP_NAN or INTEGER_OVERFLOW values are produced. The -control mode allows to check control parameters, by explicitly setting their *min* and *max* values (for now).

`interp-trace -trace <1-5> [additional Faust options (-ftz xx)] foo.dsp`
`interp-tracer -trace <1-5> -control [additional Faust options (-ftz xx)] foo.dsp`

Here are the available options:

Expand Down
2 changes: 1 addition & 1 deletion tools/benchmark/interp-tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int main(int argc, char* argv[])
bool is_control = isopt(argv, "-control");

if (isopt(argv, "-h") || isopt(argv, "-help") || trace_mode < 0 || trace_mode > 5) {
cout << "interp-trace -trace <1-5> -control [additional Faust options (-ftz xx)] foo.dsp" << endl;
cout << "interp-tracer -trace <1-5> -control [additional Faust options (-ftz xx)] foo.dsp" << endl;
cout << "-control to activate min/max control check\n";
cout << "-trace 1 to collect FP_SUBNORMAL only\n";
cout << "-trace 2 to collect FP_SUBNORMAL, FP_INFINITE and FP_NAN\n";
Expand Down

0 comments on commit c834792

Please sign in to comment.