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

  • SEARCH
  • Home
  • 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 8600501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:37:52+00:00 2026-06-12T01:37:52+00:00

I consider an ActivePivot instance to compute CVA (Credit Valuation Adjustment). I have to

  • 0

I consider an ActivePivot instance to compute CVA (Credit Valuation Adjustment).

I have to apply a piece of logic on a large number of cells (20k for each counter-party), each being associated to a float array of size 10k. Even if ActivePivot is massively multithreaded, an ABasicPostProcessor will be applied in a mono-threaded way for each range location. How could I make it compute through my point location in a multi-threaded way?

  • 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-06-12T01:37:53+00:00Added an answer on June 12, 2026 at 1:37 am

    I built the following class, which specialize ABasicPostProcessor (a Core class enabling fast implementation of per-point post-processor) by just adding the calls to doEvaluation in a multi-threaded way.

    Given an ABasicPostProcessor specialisation, one simply has to extend AParallelBasicPostProcessor in order to gain parallel evaluation!

    /**
     * Specialization of ABasicPostProcessor which will call doEvaluation in a
     * multithreaded way
     * 
     * @author BLA
     */
    public abstract class AParallelBasicPostProcessor<OutputType> extends ABasicPostProcessor<OutputType> {
        private static final long serialVersionUID = -3453966549173516186L;
    
        public AParallelBasicPostProcessor(String name, IActivePivot pivot) {
            super(name, pivot);
        }
    
        @Override
        public void evaluate(ILocation location, final IAggregatesRetriever retriever) throws QuartetException {
            // Retrieve required aggregates
            final ICellSet cellSet = retriever.retrieveAggregates(Collections.singleton(location), Arrays.asList(prefetchMeasures));
    
            // Prepare a List
            List<ALocatedRecursiveTask<OutputType>> tasks = new ArrayList<ALocatedRecursiveTask<OutputType>>();
    
            // Create the procedure to hold the parallel sub-tasks
            final ICellsProcedure subTasksGeneration = makeSubTasksGenerationProcedure(tasks);
    
            cellSet.forEachLocation(subTasksGeneration, underlyingMeasures);
    
            ForkJoinTask.invokeAll(tasks);
    
            for (ALocatedRecursiveTask<OutputType> task : tasks) {
                OutputType returnValue;
                try {
                    returnValue = task.get();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                } catch (ExecutionException e) {
                    // re-throw the root cause of the ExecutionException
                    throw new RuntimeException(e.getCause());
                }
    
                // We can write only non-null aggregates
                if (null != returnValue) {
                    writeInRetriever(retriever, task.getLocation(), returnValue);
                }
            }
        }
    
        protected void writeInRetriever(IAggregatesRetriever retriever, ILocation location, OutputType returnValue) {
            retriever.write(location, returnValue);
        }
    
        protected ICellsProcedure makeSubTasksGenerationProcedure(List<ALocatedRecursiveTask<OutputType>> futures) {
            return new SubTasksGenerationProcedure(futures);
        }
    
        /**
         * {@link ICellsProcedure} registering a {@link ALocatedRecursiveTask} per
         * point location
         */
        protected class SubTasksGenerationProcedure implements ICellsProcedure {
    
            protected List<ALocatedRecursiveTask<OutputType>> futures;
    
            public SubTasksGenerationProcedure(List<ALocatedRecursiveTask<OutputType>> futures) {
                this.futures = futures;
            }
    
            @Override
            public boolean execute(final ILocation pointLocation, int rowId, Object[] measures) {
                // clone the array of measures as it is internally used as a buffer
                final Object[] clone = measures.clone();
    
                futures.add(makeLocatedFuture(pointLocation, clone));
    
                return true;
            }
        }
    
        protected ALocatedRecursiveTask<OutputType> makeLocatedFuture(ILocation pointLocation, Object[] measures) {
            return new LocatedRecursiveTask(pointLocation, measures);
        }
    
        /**
         * A specialization of RecursiveTask by associating it to a
         * {@link ILocation}
         * 
         * @author BLA
         * 
         */
        protected static abstract class ALocatedRecursiveTask<T> extends RecursiveTask<T> {
            private static final long serialVersionUID = -6014943980790547011L;
    
            public abstract ILocation getLocation();
        }
    
        /**
         * Default implementation of {@link ALocatedRecursiveTask}
         * 
         * @author BLA
         * 
         */
        protected class LocatedRecursiveTask extends ALocatedRecursiveTask<OutputType> {
            private static final long serialVersionUID = 676859831679236794L;
    
            protected ILocation pointLocation;
            protected Object[] measures;
    
            public LocatedRecursiveTask(ILocation pointLocation, Object[] measures) {
                this.pointLocation = pointLocation;
                this.measures = measures;
    
                if (pointLocation.isRange()) {
                    throw new RuntimeException(this.getClass() + " accepts only point location: " + pointLocation);
                }
            }
    
            @Override
            protected OutputType compute() {
                try {
                    // The custom evaluation will be computed in parallel
                    return AParallelBasicPostProcessor.this.doEvaluation(pointLocation, measures);
                } catch (QuartetException e) {
                    throw new RuntimeException(e);
                }
            }
    
            @Override
            public ILocation getLocation() {
                return pointLocation;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider such html piece: <p>foo</p><p>bar</p> If you run (for example) jQuery text for it
Consider a disk with the following characteristics: Number of surface 16 Number of sectors
Consider this problem: I have a program which should fetch (let's say) 100 records
Consider this folder structure in repository Root |----Plugins |----|-----Plugin1 |----Themes |-----|----Theme1 I have all
Consider this scenario. We have an internal Rails 2 app that connects to a
Consider I have two classes. Professor and TimePerDay. public class TimePerDay { private ObservableCollection<TimeSpan>
Consider the following scenario: I have a page that can open a dialog (jquery
Consider this example - I have a class called Report that has a field
Consider the following example. var obj = function(){}; function apply(target, obj) { if (target
Consider having the following header file (c++): myclass.hpp #ifndef MYCLASSHPP_ #define MYCLASSHPP_ namespace A

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.