Displaying 20 results from an estimated 45 matches for "testfunc".
2013 Jan 26
2
[LLVMdev] Code compiling in gcc but not llvm
Hi,
This is my first post, sorry if not in the right format.
I am stuck at a place where I have a code fragment that runs in normal gcc
but fails when I give -fplugin=dragonegg.so
extern int *testfunc();
extern __typeof (testfunc) testfunc __asm__ ("" "__GI_testfunc")
__attribute__ ((visibility ("hidden")));
extern __typeof(testfunc) __testfunc;
extern __typeof (__testfunc) __testfunc __asm__ ("" "__GI___testfunc")
__attribute__ ((visibility (...
2012 Sep 21
2
Parallel Programming
I am trying to do parallel programming and I tried this
library(doSNOW)
library(foreach)
testfunc<-function(x){
x<-x+1
x
}
noc<-2
cl <- makeCluster(do.call(rbind,rep(list("localhost"),noc)), type = "SOCK")
registerDoSNOW(cl)
clusterExport(cl=cl,c("testfunc.r"))
testl<-foreach(pp=1:2) %dopar% {
testfunc(pp)
}
And this works but if I try to enclo...
2009 Sep 21
3
Basic function output/scope question
Hello Group,
I'm trying to learn R and am having a problem getting output from a
function I'm trying to write. The problem is clearly one of scope,
but I can't find the documentation that tells me how to get around the
issue.
Here is an example of my problem.
testfunc<-function(x)
{ y<-10
print(y)
print(x)
}
testfunc(4)
The variables x and y are accessible during execution of the function
"testfunc" but not afterwards. I've read through the Introduction to
R, and the R language definition on functions, but do not see how to
define the outp...
2019 Jun 18
3
Fast way to call an R function from C++?
...T(Rf_lang2(f, x));
SEXP val = R_forceAndCall(call, 1, R_GlobalEnv);
UNPROTECT(1);
return val;
}
// [[Rcpp::export]]
SEXP C_test2(SEXP expr, SEXP env) {
SEXP val = Rf_eval(expr, env);
return val;
}
// [[Rcpp::export]]
SEXP C_test3(SEXP f,SEXP x) {
Function fun(f);
return fun(x);
}
```
R code:
```
testFunc<-function(x){
x=x^2
return(x)
}
evn=new.env()
evn$x=x
expr=quote(testFunc(evn$x))
testFunc(evn$x)
C_test1(testFunc, evn$x)
C_test2(expr,evn)
C_test3(testFunc,evn$x)
```
For the results, I run each function 1,000,000 times:
- testFunc : 0.47 sec
- C_test1 : 2.46 sec
- C_test2 : 2....
2004 Jan 16
1
local variables (PR#6436)
...nlike S-plus) allows assignments to elements of a
vector objects even when the object do not exists locally (inside a
fucntion) in cases where an object of the same name exists globally. I
guess this is not really desired behaviour:
R v1.8.0
> a
Error: Object "a" not found
> testfunc <- function() {a[1]<-1; a}
> testfunc()
Error in testfunc() : Object "a" not found
> a<-2
> testfunc()
[1] 1
> a
[1] 2
S-plus v6.0
> a
Problem: Object "a" not found
> testfunc <- function() {a[1]<-1; a}
> testfunc()
Problem in testfun...
2009 Aug 30
4
[LLVMdev] Perfect forwarding?
...hy, then the class itself is serialized up as if
by value, then passed to the remote function by pointer when
deserialized (on the stack, eh, eh?, has to be default constructable
to support that, or the registerRPCCall below will not even compile,
yes this is completely typesafe in every way)
void _testFunc(int i, someClass *ptr) {
// do something
}
// example syntax
networkWorld::RPCCaller testFunc =
networkWorld->registerRPCCall("testFunc",&testFunc,enumCallOnClientOnly);
networkWorld::RPCCaller someMethod =
networkWorld->registerRPCCall("someMethod",&someClass:...
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: m...
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: m...
2009 Aug 05
0
[LLVMdev] Stack Management in LLVM
First off, thanks for the help so far.
>From what I have been able to tell, emitPrologue kicks in after the arguments
for the function have been copied. For example, consider the function
int testfunc( int foo, int bar );
Emitting assembly code from the llvm-gcc frontend in a small test program
gives the following for the call to testfunc
movl $1338, (%esp)
movl $1339, 4(%esp)
call testfunc
Correct me if I am wrong, but I believe that the hook emitPrologue gives is
before "cal...
2009 Jul 24
2
[LLVMdev] Stack Management in LLVM
On Thu, Jul 23, 2009 at 4:06 PM, Joshua
Moore-Oliva<llvm-dev at chatgris.com> wrote:
> If I could reduce my requirements to the ability to the following:
> * Ability to know how much stack space a function requires
> * Move the stack pointer arbitrarily (the ability to write my own function
> prologue and epilogue, would need to be able to insert assembly/low level
>
2008 Nov 04
1
Help needed using 3rd party C library/functions from within R (Nvidia CUDA)
...eded CUDA
library (cutil.h) and compile this to an .so file using a NVIDIA compiler
(nvcc), called 'myFunc.so' I can load this fine from within R with
dyn.load("myFunc.so").
But, as soon as I want to call it's function I get:
> dyn.load("myFunc.so")
> .C("testFunc")
Error in .C("testFunc") : C symbol name "testFunc" not in load table
The myFunc.c file looks like this:
#include<cutil.h>
#include<stdio.h>
#include<stdlib.h>
#include<R.h>
void testFunc() {
printf("Hello!\n");
}
The problem i...
2008 Nov 10
6
Variable passed to function not used in function in select=... in subset
Hello!
I have the problem that in my function the passed variable is not used, but the variable name of the dataframe itself?- difficult to explain, but an easy example:
TestFunc<-function(df, group) {
??? print(names(subset(df, select=group)))
}
df1<-data.frame(group="G1", visit="V1", value=0.9)
TestFunc(df1, c("group", "visit"))
Result:
[1] "group"
?
But I expected and want to have [1] "group" "visit&...
2017 Apr 05
2
Deopt operand bundle behavior
...tarted to use deopt operand bundle to make our native stacktrace deoptimizable and garbage collectable. We stumbled upon an issue and we don't know if it is really an issue on our side or really a problem within LLVM.
For example, for this input:
declare { i8*, i8* } @getCode()
define void @testFunc() {
entry:
%0 = call { i8*, i8* } @getCode()
%1 = extractvalue { i8*, i8* } %0, 1
%2 = bitcast i8* %1 to void ()*
call void %2() [ "deopt"() ]
ret void
}
We get this output machine code for x86_64:
_testFunc: ## @testFunc
.cfi_startproc
## BB#0:...
2009 Nov 23
2
categorisation of continuous variables in R
...ifelse statements, but that looks rather clumsy. I looked
at switch, but couldn't figure out how to use it for this. I guess
that's not possible, as it only works with characters or integers, not
with intervals.
Basically, I'm looking for a clean way to do :
test <- runif(10,1,100)
testFunc <-function(x){
x <- ifelse(test<10,"lowest",
ifelse(10<=test & test <50,"low",
ifelse(50<=test & test <90,"high",
ifelse(90<=test & test<100,"highest",NA)
)
)
)
retu...
2011 Jan 18
2
[LLVMdev] compiling a call to function in compiler
...html,
to create a call instruction from a function pointer. But I'm
getting...
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"),
function cast, file /usr/local/include/llvm/Support/Casting.h, line 202.
Code snippets...
id testfunc(id a, id b) { ... }
...
FunctionType *fn_type = FunctionType::get(id_type, argtypes, false);
Value *fn = ConstantExpr::getIntToPtr(ConstantInt::get(int64_type,
reinterpret_cast<int64_t>(testfunc)), fn_type);
return builder.CreateCall2(fn, arg0val, arg1val); // <--
assert...
2019 Jun 18
2
Fast way to call an R function from C++?
For reference, your benchmark using UNWIND_PROTECT:
> system.time(test(testFunc, evn$x))
user system elapsed
0.331 0.000 0.331
> system.time(test(C_test1, testFunc, evn$x))
user system elapsed
2.029 0.000 2.036
> system.time(test(C_test2, expr, evn))
user system elapsed
2.307 0.000 2.313
> system.time(test(C_test3, testFunc, evn$x))
us...
2013 Jan 27
0
[LLVMdev] Code compiling in gcc but not llvm
$ gcc -S test.c
$ cat test.s
.file "test.c"
.text
.globl __GI___testfunc
.hidden __GI___testfunc
.type __GI___testfunc, @function
__GI___testfunc:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
re...
2002 Aug 07
0
FW: [R] [ and setMethod conflict?
...9;t seem to arise unless the data frame is large
enough. I parametrized the 5000 rows in your example and couldn't get
the bizarre behavior until the number of rows was larger than 1000.
2. There is some reason to think that nested "[" expressions are
related. After rewriting your testFunc as follows, the random errors
seemed to go away.
testFunc <- function(cur) {
ii <- order(cur[,1])
sorted <- cur[ii,]
ll <- !is.na(sorted[,1])
sorted[ll,]
}
(the change is just to pull out the subset expressions that were
arguments to other "[" expressions.)
I...
2013 May 05
0
[LLVMdev] llvm-c: Types of functions
...tCreate();
LLVMMemoryBufferRef fileMemBuff;
LLVMCreateMemoryBufferWithContentsOfFile(
"test.bin", &fileMemBuff, &msg);
LLVMModuleRef module;
LLVMGetBitcodeModuleInContext(
context, fileMemBuff, &module, &msg);
LLVMValueRef testFunc = LLVMGetNamedFunction(module, "test");
assert(testFunc);
if (LLVMIsAFunction(testFunc)) printf("Is a Function\n"); // <-- I do see this message, so far so good
else printf("Not a Func\n");
LLVMTypeRef testType;
testType = LLVMTypeOf(testFunc)...
2012 Jan 30
2
ode() tries to allocate an absurd amount of memory
...80000 state variables: the amount of
memory trying to be allocated is exactly the same.) I have included a
trivial example below that uses a function that returns a rate of change of
zero for all state variables.
> require(deSolve)
Loading required package: deSolve
> C<-rep(0,34000)
> TestFunc<-function(t,C,para){
+ return(list(rep(0,length(C))))
+ }
> soln<-ode(y=C,times=seq(0,1,0.1),func=TestFunc,parms=c(0),method="vode")
Error in vode(y, times, func, parms, ...) :
cannot allocate memory block of size 137438953456.0 Gb
In addition: Warning message:
In vode(...