Ask a questionAsk a question
 

Questionx64 program using the IScheduler API in HPC Pack 2008 SDK SP1 got errors

  • Tuesday, October 27, 2009 10:30 AMSeifer Lin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi:

    Below is my program. My platform is Windows Server 2008 Enterprise edition + HPC Pack 2008 SP1 (x64) 
    For a x86 build of this program, everything works fine!
    But for a x64 build, I got the error at pJob->put_Name()
    The error is: job->put_Name() failed with 0x80040232.
    Can anyone help? Thanks very much!
    /////////////////////////////////////////////////////////////////////////////////

    #define _WIN32_DCOM

    #include <windows.h>
    #include <stdio.h>
    #include <comutil.h>
    #pragma comment(lib, "comsupp.lib")

    // The Microsoft.Hpc.Scheduler.tlb and Microsoft.Hpc.Scheduler.Properties.tlb type
    // libraries are included in the Microsoft HPC Pack 2008 SDK. The type libraries are
    // located in the "Microsoft HPC Pack 2008 SDK\Lib\i386" or \amd64 folder. Include the rename
    // attributes to avoid name collisions.
    #import <Microsoft.Hpc.Scheduler.tlb> named_guids no_namespace raw_interfaces_only \
        rename("SetEnvironmentVariable","SetHpcEnvironmentVariable") \
        rename("AddJob", "AddHpcJob")
    #import <Microsoft.Hpc.Scheduler.Properties.tlb> named_guids no_namespace raw_interfaces_only

    int main(int argc, char **argv)
    {
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        HRESULT hr = S_OK;
        IScheduler *pScheduler = NULL;
        // Get an instance of the Scheduler object.
        hr = CoCreateInstance(__uuidof(Scheduler), // CLSID_Scheduler,
                              NULL,
                              CLSCTX_INPROC_SERVER,
                              __uuidof(IScheduler), // IID_IScheduler,
                              reinterpret_cast<void **>(&pScheduler));
        if(FAILED(hr))
        {
            wprintf(L"CoCreateInstance() failed with 0x%x.\n", hr);
            if(pScheduler)
            {
                pScheduler->Release();
            }
            exit(-1);
        }
       
        hr = pScheduler->Connect(_bstr_t("localhost"));
        if(FAILED(hr))
        {
            wprintf(L"Connect() failed with 0x%x.\n", hr);
            pScheduler->Release();
            exit(-1);
        }
       
        ISchedulerJob *pJob = NULL;
        hr = pScheduler->CreateJob(&pJob);
        if(FAILED(hr))
        {
            wprintf(L"CreateJob() failed with 0x%x.\n", hr); fflush(stdout);
            pScheduler->Release();
            exit(-1);
        }

        hr = pJob->put_Name(_bstr_t("MyHPCJob"));
        if(FAILED(hr))
        {
            wprintf(L"job->put_Name() failed with 0x%x.\n", hr); fflush(stdout);
            pJob->Release();
            pScheduler->Release();
            exit(-1);
        }

        ISchedulerTask *pTask = NULL;
        hr = pJob->CreateTask(&pTask);
        if(FAILED(hr))
        {
            wprintf(L"CreateTask() failed with 0x%x.\n", hr); fflush(stdout);
            pJob->Release();
            pScheduler->Release();
            exit(-1);
        }

        hr = pTask->put_Name(_bstr_t("MyHPCTask"));
        if(FAILED(hr))
        {
            wprintf(L"task->put_Name() failed with 0x%x.\n", hr); fflush(stdout);
            pTask->Release();
            pJob->Release();
            pScheduler->Release();
            exit(-1);
        }

        hr = pTask->put_CommandLine(_bstr_t("hostname"));
        if(FAILED(hr))
        {
            wprintf(L"put_CommandLine() failed with 0x%x.\n", hr); fflush(stdout);
            pTask->Release();
            pJob->Release();
            pScheduler->Release();
            exit(-1);
        }

        hr = pJob->AddTask(pTask);
        if(FAILED(hr))
        {
            wprintf(L"AddTask() failed with 0x%x.\n", hr); fflush(stdout);
            pTask->Release();
            pJob->Release();
            pScheduler->Release();
            exit(-1);
        }

        hr = pScheduler->SubmitJob(pJob, _bstr_t(argv[1]), _bstr_t(argv[2]));
        if(FAILED(hr))
        {
            wprintf(L"SubmitJob() failed with 0x%x.\n", hr);
            pTask->Release();
            pJob->Release();
            pScheduler->Release();
            exit(-1);       
        }

        pTask->Release();
        pJob->Release();
        pScheduler->Release();

        return 0;
    }

    • Moved byAlex SuttonMSFT, OwnerTuesday, October 27, 2009 11:16 AM (From:Windows HPC Server Developers - General)
    •  

All Replies

  • Tuesday, October 27, 2009 5:40 PMJosh BarnardMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    You say you are running SP1 of the HPC Pack; are you also running the most recent version of the SDK?  There were some issues with COM that we fixed at SP1.  You can get the lastest build here:
    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3fe15731-b1b6-42de-b278-5ccd46c0863b

    Thanks,
    Josh


    -Josh
  • Wednesday, October 28, 2009 1:38 AMSeifer Lin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi:

    I have already used the HPC Pack 2008 SDK SP1 and got this error...

    My program is built on Windows XP Professional 32bit with Visual Studio 2005

  • Thursday, November 19, 2009 1:12 AMJosh BarnardMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I've asked the team to take a look and see if they can provide an answer.

    Thanks,
    Josh


    -Josh
  • Thursday, November 19, 2009 6:56 PMpgarvanMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    VS 2005 C++ has a buggy #import mechanism.
     

    You should be able to work-around the problem by (i) keeping the code 32-bit; or (ii) moving up to VS2008; or (iii) trying this:

     

    [1] First, compile your code for 32-bit using the existing #import’s. The #import mechanism causes the C++ pre-pre-processor to generate the following two temporary .tlh headers into the target directory:

    Microsoft.Hpc.Scheduler.tlh

    Microsoft.Hpc.Scheduler.Properties.tlh

    [2] Now copy these two .tlh files into your source file directory and hang on to them!

    [3] Finally modify your source code to #include the .tlh files (or rename them to .h if you like) instead of #import’ing the typelibs.

    [4] You should now be able to compile in both 32-bit and 64-bit successfully every time, with no need for the .tlbs.