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 7768269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:52:41+00:00 2026-06-01T15:52:41+00:00

I implemented a simple matrix vector multiplication for sparse matrices in CRS using an

  • 0

I implemented a simple matrix vector multiplication for sparse matrices in CRS using an implicit openMP directive in the multiplication loop.

The complete code is in GitHub: https://github.com/torbjoernk/openMP-Examples/blob/icc_gcc_problem/matxvec_sparse/matxvec_sparse.cpp
Note: It’s ugly 😉

To control the private and shared memory I’m using restrict pointers. Compiling it with GCC 4.6.3 on 64bit Linux works fine (besides two warnings about %u and unsigned int in a printf command, but that’s not the point).

However, compiling it with ICC 12.1.0 on 64bit Linux failes with the error:

matxvec_sparse.cpp(79): error: "default_n_row" must be specified in a variable list at enclosing OpenMP parallel pragma
    #pragma omp parallel \
    ^

with the definition of the variable and pointer in question

int default_n_row = 4;
int *n_row = &default_n_row;

and the openMP directive defined as

#pragma omp parallel \
  default(none) \
  shared(n_row, aval, acolind, arowpt, vval, yval) \
  private(x, y)
{
  #pragma omp for \
    schedule(static)
  for ( x = 0; x < *n_row; x++ ) {
    yval[x] = 0;
    for ( y = arowpt[x]; y < arowpt[x+1]; y++ ) {
      yval[x] += aval[y] * vval[ acolind[y] ];
    }
  }
} /* end PARALLEL */

Compiled with g++:

c++ -fopenmp -O0 -g -std=c++0x -Wall -o matxvec_sparse matxvec_sparse.cpp

Compiled with icc:

icc -openmp -O0 -g -std=c++0x -Wall -restrict -o matxvec_sparse matxvec_sparse.cpp

  • Is it an error in usage of GCC/ICC?
  • Is this a design issue in my code causing undefined behaviour?
    If so, which line(s) is/are causing it?
  • Is it just inconsistency between ICC and GCC?
    If so, what would be a good way to achieve compiler independence and compatibility?
  • 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-01T15:52:42+00:00Added an answer on June 1, 2026 at 3:52 pm

    Huh. Looking at the code, it’s clear what icpc thinks the problem is, but I’m not sure without going through the specification which compiler is doing the right thing here, g++ or icpc.

    The issue isn’t the restrict keyword; if you take all those out and lose the -restrict option to icpc, the problem remains. The issue is that you’ve got in that parallel section default(none) shared(n_row...), but n_row is, at the start of the program, a pointer to default_n_row. And icpc is requiring that default_n_row also be shared (or, at least, something) in that omp parallel section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented a simple sitemap class using Django's default sitemap application. As it was
I've implemented a TreeCellRenderer that returns a JCheckBox (simple code that the renderer extends
I have implemented simple com.sun.net.httpserver.HttpServer application using one of examples in the internet. Server
I've implemented a simple app using a listview From jQuery-mobile, it appears as hyperlink
I implemented a simple C# application which inserts about 350000 records into the database.
I've implemented a simple UDP ping/pong protocol to discover other computers connected to the
I have implemented a simple linux shell in c. Now, I am adding some
I have implemented a simple RSS reader in Java. I hit a URL and
Very simple Qt GUI application: On the scene I have multiple circles implemented as
I am creating a simple messaging system in WCF and have implemented a minimal

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.