Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:41:43+00:00 2026-05-31T00:41:43+00:00

Assume that I want to draw samples from some probability distribution. In the case

  • 0

Assume that I want to draw samples from some probability distribution. In the case below I draw some uniformly distributed rv’s between 0 and 1 for 10000 times. I do not care about the ordering of the random samples in the vector, after all they are random.

(setf my-vec (make-sequence 'vector 10000 :initial-element 0))
(loop :for i :from 0 :to 9999 :do
   (setf (svref my-vec i) (random 1.0)))

I have a multicore machine and I want to implement the above code in parallel. (i.e. assuming I have 4 cores, sampling 2500 in one core and at the end appending all samples in to one single vector. I have asked before about Common Lisp Parallel Programming
here. Assuming that I am a total newbie in CL and programming in general what should be my approach to this problem? I do not require advanced characteristics in parallelization, I just want to distribute the computational load of the sampling to machine cores equally. If you can point out some steps to do for parallelization or some online tutorial stuff that I can benefit from that would be really nice. Thanks a lot in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:41:46+00:00Added an answer on May 31, 2026 at 12:41 am

    You need a Common Lisp implementation which is multi-core capable. Examples are CCL, LispWorks and on some platforms (IIRC) SBCL.

    A simple example using LispWorks 6.1 and its multiprocessing capabilities follows.
    It uses a construct called a barrier. Processes wait on a barrier until enough processes arrive. Here it means that enough threads have finished their vector initialization.

    The typical function to start a thread is PROCESS-RUN-FUNCTION.

    (defun make-random-vector (&key (size 10000) (n-threads 4))
      (let ((vector  (make-sequence 'vector size :initial-element 0))
            (barrier (mp:make-barrier (1+ n-threads)))
            (delta   (truncate size n-threads)))
        (loop for i below n-threads
              do (mp:process-run-function
                  "init"
                  nil
                  (lambda (barrier vector start end)
                    (loop for i from start below end do
                          (setf (svref vector i) (random 1.0)))
                    (mp:barrier-wait barrier :pass-through t))
                  barrier
                  vector
                  (* i delta)
                  (+ delta (* i delta))))
        (mp:barrier-wait barrier)
        vector))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I want to listen to a non-common port (9090 for example) 24/7
For this question, let us assume that we will want to show the face
Assume that we have N erlang nodes, running same application. I want to share
I want build a sketch pad app on iPhone, I assume that this type
Assume that the following code is being executed by 10 threads. pthread_mutex_lock(&lock) Some trivial
Assume that I have some array of data (a vector to be specific). Can
Assume that I want to exit a console program if the user entered the
I have winform with a TextBox and I want to draw some GDI graphics
Assume that I want to perform parallel computations on a large fixed object, e.g.
I'm just getting used to smart pointers using std::auto_ptr. Assume that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.