Questions tagged [reduction]

481 questions
-1
votes
1 answer

Search Minimum/Maximum from n Arrays parallel in CUDA (Reduction Problem)

Is there a performant way in CUDA to get out of multiple arrays (which exist in different structures) to find the maximum/minimum in parallel? The structures are structured according to the Structure of Arrays format. A simple idea would be to…
Compty_
  • 1
  • 1
  • 1
-1
votes
1 answer

Construct a ciruct from a graph that outputs 1 if the graph has an independent set

Let's say I have a graph, and from this graph I want to create a circuit K whose inputs can be set so that K outputs true iff the graph has an independent set of size ≥2. I've seen some decent stuff on the internet / youtube about how to go about…
David Dennis
  • 702
  • 2
  • 9
  • 26
-1
votes
1 answer

How do I refactor this code to make it shorter?

import math def roundup(x): return int(math.ceil(x / 10.0)) * 10 w=0 while w == 5: print("Would you like to *work out* a missing letter in a GTIN-8 code, or *check* a code?") response = input(":") if response == 'work out': print("Input a 7…
-1
votes
1 answer

comparing Matlab vs CUDA correlation and reduction on a 2D array

I am trying to compare cross-correlation using FFT vs using windowing method. My Matlab code is: isize = 20; n = 7; for i = 1:n %%7x7 xcorr for j = 1:n xcout(i,j) = sum(sum(ffcorr1 .* ref(i:i+isize-1,j:j+isize-1))); %%ref is 676 element array…
vivekv80
  • 119
  • 5
  • 16
-1
votes
1 answer

How to use reduction vector variable in OpenMP?

I want to use the reduction directive in openmp, but it's not working. Compiler error says: "reduction: OpenMP 'parallel for' empty factor in directive" (Visual studio 2015 community) or "reduction:^ needed scalar variable" This is my code…
-1
votes
2 answers

N largest elements of a vector along with their indices

I have a thrust::device_vector vec. Assume that vec.size() = L and that N < L. I want to find the largest N elements in vec along with their indices. How can we do this efficiently using raw CUDA or thrust?
Hieu Pham
  • 97
  • 1
  • 8
-1
votes
1 answer

OpenMP Dot Product and Pointers

I'm trying to implement dotproduct in OpenMP with large arrays allocated with malloc. However, when I use reduction(+:result) it produces different results for each program run. Why do I get different results? How can I remedy that? And how can this…
neckutrek
  • 353
  • 2
  • 14
-1
votes
1 answer

R: Reducing data set and creating a conditional mean

So I have a large data set, with many columns(10) and 100,000 rows. One of the columns is the date of observation with two other corresponding columns, one species and the other year. First, I want to create a new column that will give me the mean…
John
  • 59
  • 1
  • 9
-1
votes
2 answers

array_walk only partially removes matches

Ran into a weird situation were using array_walk() will only partially remove matches from my method, not certain exactly what is going on. I am currently using PHP v5.6.4. The issue almost seems to be that it is only removing every secondary…
ehime
  • 8,025
  • 14
  • 51
  • 110
-1
votes
2 answers

Can I use OpenMP reduction when the variable is an array element?

The OpenMP manual says A type name in a declare reduction directive cannot be a function type, an array type, a reference type, or a type qualified with const, volatile or restrict. What can I do to produce my results into array elements? I…
YOung
  • 938
  • 2
  • 10
  • 14
-2
votes
1 answer

Blockwise/Strided reduction using CUDA

TLDR: I am trying to write a GPU code that computes a blockwise reduction on an array. The input looks like [block_0, trash_0, block_1, trash_1, ..., block_n, trash_n], and I want to compute block_0 + block_1 + ... + block_n. Relevant sizes: each…
s769
  • 3
  • 3
-2
votes
1 answer

GPU reduction code only runs one time

I have been using the code sample supplied by Robert Crovella: thrust::max_element slow in comparison cublasIsamax - More efficient implementation? Which is a very fast reduction code. I modified it to also return the index of the max in the input…
brumby
  • 1
  • 1
-2
votes
1 answer

Cuda Reduction in 2d Array

I want to calculate the average of the values over the whole image in Cuda. To test how reduction in 2D array work, I write this kernel below. The final output o should be the sum of all the image values. The input g is a 2D array with value 1 in…
Lv Zhaoyang
  • 107
  • 1
  • 4
  • 10
-3
votes
2 answers

reducing a fraction in c

#include #include int main(){ system("color f0"); int a,b,c,d,e,f,g,h,z; printf("First numerator:"); scanf("%d",&a); printf("First denominator:"); scanf("%d",&b); printf("Second numerator:"); …
-3
votes
1 answer

LU Decomposition Crout Reduction

This is my code for LU Decomposition Crout Method: function [L, U] = croutreduction(A) [row,column]=size(A); L=eye(row,column); //A = 3x3 if row==3 then U(1,1)=A(1,1); U(1,2)=A(1,2); U(1,3)=A(1,3); …
Elra Ghifary
  • 113
  • 1
  • 14
1 2 3
32
33