- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have been looking for an MKL version of elementwise matrix multiplication that works based on a condional approach.While Vmult can be used it is for only a 1D vector rather than a matrix.
Below is the code I would like to rewrite with MKL version if possible.
logical(log_kind) check(2000,2000) do i=1,2000 do j=1,2000 if ( check(i,j) ) c(i,j) = a(i,j) * b(i,j) enddo enddo
I know Vmult helps, but it has no conditional operation.
Is there is a conditional Vector library or elementwise matrix library.
Can this be done by a combination of MKL library operations?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the check array has a large number of .TRUE., then consider replacing the logical check array with an array of values 0.0 for false and 1.0 for true. Then use
real :: use_this(2000,2000) ... do j=1,2000 ! outer loop to be rightmost index do i=1,2000 ! inner loop to be the leftmost index c(i,j) = c(i,j) + a(i,j) * b(i,j) * use_this(i, j) enddo enddo
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The original code, with corrected syntax (either f66 one-line if or inserting endif) should work well, at least since SSE4, possibly with the addition of a directive such as !dir$ vector always in order to relax the constraint about exceptions. At -O3, ifort should fix the backward loop nesting automatically.
The (different) case which Jim quotes can be handled efficiently by e.g.
c(i,j) = c(i,j) + a(i,j) * merge(b(i,j), 0., check(i,j))
(again, SSE4 or later would help)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page