Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status updates and parallel vs single-core implementation #4

Open
nick-youngblut opened this issue Mar 17, 2021 · 1 comment
Open

Comments

@nick-youngblut
Copy link

It would be helpful to have more information than just:

[1] 1
[1] 0

during an mbImpute() run (single core). It appears that this output is simply print(mat_num-1-mat_new) in the data_fit2() function. Using message() with a bit of text along with the value allow for more informative output.


While I was looking at data_fit2(), I noticed that you have different code for parallel == TRUE versus parallel == FALSE:

    if(!parallel){
      for(mat_new in 1:(mat_num-1)){
        print(mat_num-1-mat_new)
        design_mat_fit = sparseMatrix(i = 1, j =1, x = 0, dims = c(size, row_length))
        track = ((mat_new-1)*size+1):(mat_new*size)
        for(i in 1:size){
          if(is.vector(X)){
            result <- design_mat_row_gen2(y_sim, X[1:n], confidence_set[track[i]+1,1], confidence_set[track[i]+1,2], close_taxa)
            design_mat_fit[i,result$nz_idx] <- result$nz_val
          }
          else{
            result <- design_mat_row_gen2(y_sim, X[1:n,], confidence_set[track[i]+1,1], confidence_set[track[i]+1,2], close_taxa)
            design_mat_fit[i,result$nz_idx] <- result$nz_val
          }
        }
        mat_list[[mat_new]] = design_mat_fit
      }
    }else{
      no_cores <- max(ncores, detectCores() - 1)
      registerDoParallel(cores=no_cores)
      cl <- makeCluster(no_cores, "FORK")
      f <- function(mat_new){
        design_mat_fit = sparseMatrix(i = 1, j =1, x = 0, dims = c(size, row_length))
        track = ((mat_new-1)*size+1):(mat_new*size)
        for(i in 1:size){
          if(is.vector(X)){
            result <- design_mat_row_gen2(y_sim, X[1:n], confidence_set[track[i]+1,1], confidence_set[track[i]+1,2], close_taxa)
            design_mat_fit[i,result$nz_idx] <- result$nz_val
          }
          else{
            result <- design_mat_row_gen2(y_sim, X[1:n,], confidence_set[track[i]+1,1], confidence_set[track[i]+1,2], close_taxa)
            design_mat_fit[i,result$nz_idx] <- result$nz_val
          }
        }
        return(design_mat_fit)
      }
      mat_list <- parLapply(cl, 1:(mat_num-1), f)

Why is this separate code instead of using the same f() function for cores=1 versus cores=>1? Do these different implementations generate different results?

@ruochenj
Copy link
Owner

Dear user,

Thank you for your suggestion. I will make the output more interpretable and update the package soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants