Re: [Rd] Catch SIGINT from user in backend C++ code

2013-05-06 Thread Karl Forner
Hello,

I once wrote  a package called RcppProgress, that you can find here:
https://r-forge.r-project.org/R/?group_id=1230
I did not try it for a long time, but it was developed to solve this
exact problem.
You can have a look the its companion package: RcppProgressExample.
Here's a link to the original announcement:
http://tolstoy.newcastle.edu.au/R/e17/devel/12/02/0443.html

Hope it helps.
Karl Forner
Quartz Bio

On Thu, May 2, 2013 at 1:50 AM, Jewell, Chris  wrote:
> Hi,
>
> I was wondering if anybody knew how to trap SIGINTs (ie Ctrl-C) in backend 
> C++ code for R extensions?  I'm writing a package that uses the GPU for some 
> hefty matrix operations in a tightly coupled parallel algorithm implemented 
> in CUDA.
>
> The problem is that once running, the C++ module cannot apparently be 
> interrupted by a SIGINT, leaving the user sat waiting even if they realise 
> they've launched the algorithm with incorrect settings.  Occasionally, the 
> SIGINT gets through and the C++ module stops.  However, this leaves the CUDA 
> context hanging, meaning that if the algorithm is launched again R dies.  If 
> I could trap the SIGINT, then I could make sure a) that the algorithm stops 
> immediately, and b) that the CUDA context is destructed nicely.
>
> Is there a "R-standard" method of doing this?
>
> Thanks,
>
> Chris
>
>
> --
> Dr Chris Jewell
> Lecturer in Biostatistics
> Institute of Fundamental Sciences
> Massey University
> Private Bag 11222
> Palmerston North 4442
> New Zealand
> Tel: +64 (0) 6 350 5701 Extn: 3586
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Avoid entering {} evaluation in debugger

2013-05-06 Thread Josh O'Brien
Vitalie Spinu wrote
> Hi, 
>
>f1 <- function(){
>browser()
>print("aaa")
>}
>
>f2 <- function(){
>a <- 12
>eval(envir = parent.frame(),
> bquote({
>b <- .(a)
>}))
>}
>
> 
> Now do, 
> 
>  f1()
> 
> and enter n RET  and then {1+2}:
> 
> Browse[2]> {1 + 2}
> debug at #1: 1 + 2
> Browse[3]>  
> 
> 
> {} is now being debugged. This was never bothering me till I got into
> unexpected behavior with functions that evaluate in the current
> environment. 
> 
> For example calling f2() starts debugging b <- 12:
> 
> Browse[2]> f2()
> debug: b <- 12
> Browse[4]> 
> 
> Is there some sort of dont-debug-me flag that I can set in f2 to avoid
> this behavior?
> 
> Thanks, 
> Vitalie
>f1 <- function(){
>browser()
>print("aaa")
>}
>
>f2 <- function(){
>a <- 12
>eval(envir = parent.frame(),
> bquote({
>b <- .(a)
>}))
>}
>
> 
> R Under development (unstable) (2013-04-19 r62622)
> Platform: i686-pc-linux-gnu (32-bit)
> 
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8   
>  [7] LC_PAPER=C LC_NAME=C 
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> __

> R-devel@

>  mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

I believe that your sessionInfo() results leave out the most important
detail, which is that you're running R from Emacs/ESS. Is that right?

I get this same, occasionally annoying, behavior when using ESS 13.03 and
Emacs 23.3.1, but not from Rgui, Rterm, etc.

Haven't brought it up there, but this would obviously be a good topic for
ESS-help.

Cheers,

Josh



--
View this message in context: 
http://r.789695.n4.nabble.com/Avoid-entering-evaluation-in-debugger-tp4666350p4666437.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Avoid entering {} evaluation in debugger

2013-05-06 Thread Vitalie Spinu
 >> "Josh O'Brien" 
 >> on Mon, 6 May 2013 15:29:39 -0700 (PDT) wrote:

[...]


 > I believe that your sessionInfo() results leave out the most important
 > detail, which is that you're running R from Emacs/ESS. Is that right?

Nope, I have reported it from R terminal.

 > I get this same, occasionally annoying, behavior when using ESS 13.03 and
 > Emacs 23.3.1, but not from Rgui, Rterm, etc.

In ESS it indeed happens more often because visual debugger sends "n"
commands to R.

Vitalie

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel